Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/cairo-lang-semantic/src/expr/test_data/attributes
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,22 @@ error[E2019]: Can not create instances of phantom types.
--> lib.cairo:10:5
MyEnum::a(3);
^^^^^^^^^^^^

//! > ==========================================================================

//! > Attribute argument with modifier keyword.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: false)

//! > function_code
fn foo() {}

//! > function_name
foo

//! > module_code
#[cfg(ref x)]
fn f() {}

//! > expected_diagnostics
12 changes: 5 additions & 7 deletions crates/cairo-lang-syntax/src/attribute/structured.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,10 @@ impl<'a> AttributeArg<'a> {
impl<'a> Modifier<'a> {
/// Builds [`Modifier`] from [`ast::Modifier`].
fn from(modifier: ast::Modifier<'a>, db: &'a dyn Database) -> Modifier<'a> {
Modifier {
stable_ptr: modifier.stable_ptr(db),
text: modifier
.as_syntax_node()
.text(db)
.expect("Modifier should always have underlying text"),
}
let text = match &modifier {
ast::Modifier::Ref(r) => r.text(db),
ast::Modifier::Mut(m) => m.text(db),
};
Modifier { stable_ptr: modifier.stable_ptr(db), text }
}
}
Loading