-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the `#[deprecated]` attribute to functions, enums, struct items, enum variants and propagate deprecation check exhaustively throughout expressions variants. Partially addresses #6942. Support for deprecating traits, abis and the methods thereof in their definitions is still missing, as well as scrutinees and storage fields.
- Loading branch information
Showing
4 changed files
with
268 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 36 additions & 5 deletions
41
test/src/e2e_vm_tests/test_programs/should_pass/language/deprecated/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,46 @@ | ||
library; | ||
script; | ||
|
||
#[deprecated] | ||
struct A { | ||
#[deprecated] | ||
a: u64, | ||
b: u64, | ||
} | ||
|
||
impl A { | ||
#[deprecated] | ||
fn fun(self) {} | ||
} | ||
|
||
#[deprecated] | ||
enum B { | ||
A: () | ||
A: (), | ||
#[deprecated] | ||
B: (), | ||
} | ||
|
||
pub fn f() { | ||
let _ = A {}; | ||
|
||
#[deprecated] | ||
fn depr(_a: A) {} | ||
|
||
fn fun(_a: A) {} | ||
|
||
#[deprecated] | ||
fn depr_b(_b: B) {} | ||
|
||
// TODO: support for traits, abis and their methods | ||
pub fn main() { | ||
let a = A { a: 0, b: 0 }; | ||
let b = B::A; | ||
depr(a); | ||
depr(A { a: 0, b: 0 }); | ||
depr_b(b); | ||
depr_b(B::A); | ||
fun(a); | ||
fun(A { a: 0, b: 0 }); | ||
let _ = a.a; | ||
let _ = a.b; | ||
let _ = B::A; | ||
} | ||
let _ = B::B; | ||
a.fun(); | ||
} |
21 changes: 20 additions & 1 deletion
21
test/src/e2e_vm_tests/test_programs/should_pass/language/deprecated/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,23 @@ | ||
category = "compile" | ||
expected_warnings = 1 | ||
expected_warnings = 20 | ||
|
||
# check: $()deprecated struct field | ||
# check: $()deprecated struct | ||
# check: $()deprecated enum | ||
# check: $()deprecated enum | ||
# check: $()deprecated enum variant | ||
# check: $()deprecated struct | ||
# check: $()deprecated enum | ||
# check: $()deprecated function | ||
# check: $()deprecated struct | ||
# check: $()deprecated function | ||
# check: $()deprecated function | ||
# check: $()deprecated enum | ||
# check: $()deprecated function | ||
# check: $()deprecated struct | ||
# check: $()deprecated struct field | ||
# check: $()deprecated enum | ||
# check: $()deprecated enum | ||
# check: $()deprecated enum variant | ||
# check: $()deprecated struct | ||
# check: $()deprecated function |