-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
142 additions
and
0 deletions.
There are no files selected for viewing
142 changes: 142 additions & 0 deletions
142
crates/cairo-lang-semantic/src/diagnostic_test_data/allow_attr
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 |
---|---|---|
@@ -0,0 +1,142 @@ | ||
//! > Test allow_attr attribute | ||
|
||
//! > test_runner_name | ||
test_expr_diagnostics(expect_diagnostics: true) | ||
|
||
//! > expr_code | ||
{} | ||
|
||
//! > module_code | ||
#[allow_attr(some)] | ||
#[some] | ||
fn foo() {} | ||
|
||
#[some] | ||
fn bar() {} | ||
|
||
#[allow_attr] | ||
fn empty() {} | ||
|
||
#[allow_attr(my_attr = "value")] | ||
fn named_arg() {} | ||
|
||
#[allow_attr(1234)] | ||
fn number() {} | ||
|
||
#[allow_attr("string")] | ||
fn string() {} | ||
|
||
#[allow_attr(a::b)] | ||
fn path() {} | ||
|
||
#[allow_attr(attr1, attr2, attr3)] | ||
struct MultiAttr { | ||
#[attr1] | ||
x: felt252, | ||
#[attr2] | ||
y: felt252, | ||
#[attr3] | ||
z: felt252, | ||
#[attr4] | ||
w: felt252, | ||
} | ||
|
||
#[allow_attr(outer)] | ||
struct MyStruct { | ||
#[allow_attr(inner)] | ||
#[inner] | ||
x: felt252, | ||
#[outer] | ||
y: felt252, | ||
#[other] | ||
z: felt252, | ||
} | ||
|
||
//! > generated_cairo_code | ||
#[allow_attr(some)] | ||
#[some] | ||
fn foo() {} | ||
|
||
#[some] | ||
fn bar() {} | ||
|
||
#[allow_attr] | ||
fn empty() {} | ||
|
||
#[allow_attr(my_attr = "value")] | ||
fn named_arg() {} | ||
|
||
#[allow_attr(1234)] | ||
fn number() {} | ||
|
||
#[allow_attr("string")] | ||
fn string() {} | ||
|
||
#[allow_attr(a::b)] | ||
fn path() {} | ||
|
||
#[allow_attr(attr1, attr2, attr3)] | ||
struct MultiAttr { | ||
#[attr1] | ||
x: felt252, | ||
#[attr2] | ||
y: felt252, | ||
#[attr3] | ||
z: felt252, | ||
#[attr4] | ||
w: felt252, | ||
} | ||
|
||
#[allow_attr(outer)] | ||
struct MyStruct { | ||
#[allow_attr(inner)] | ||
#[inner] | ||
x: felt252, | ||
#[outer] | ||
y: felt252, | ||
#[other] | ||
z: felt252, | ||
} | ||
|
||
//! > function_body | ||
|
||
//! > expected_diagnostics | ||
error: Plugin diagnostic: Unsupported attribute. | ||
--> lib.cairo:5:1 | ||
#[some] | ||
^^^^^^^ | ||
|
||
error: Plugin diagnostic: Expected arguments. | ||
--> lib.cairo:8:1 | ||
#[allow_attr] | ||
^^^^^^^^^^^^^ | ||
|
||
error: Plugin diagnostic: Expected simple identifier. | ||
--> lib.cairo:11:14 | ||
#[allow_attr(my_attr = "value")] | ||
^^^^^^^^^^^^^^^^^ | ||
|
||
error: Plugin diagnostic: Expected simple identifier. | ||
--> lib.cairo:14:14 | ||
#[allow_attr(1234)] | ||
^^^^ | ||
|
||
error: Plugin diagnostic: Expected simple identifier. | ||
--> lib.cairo:17:14 | ||
#[allow_attr("string")] | ||
^^^^^^^^ | ||
|
||
error: Plugin diagnostic: Expected simple identifier. | ||
--> lib.cairo:20:14 | ||
#[allow_attr(a::b)] | ||
^^^^ | ||
|
||
error: Plugin diagnostic: Unsupported attribute. | ||
--> lib.cairo:31:5 | ||
#[attr4] | ||
^^^^^^^^ | ||
|
||
error: Plugin diagnostic: Unsupported attribute. | ||
--> lib.cairo:42:5 | ||
#[other] | ||
^^^^^^^^ |