Skip to content

Commit

Permalink
Made unsupported attribute error not happen on dropped elements. (#4323)
Browse files Browse the repository at this point in the history
  • Loading branch information
orizi authored Oct 30, 2023
2 parents 5deb0f6 + a2e9e94 commit 3f776cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
14 changes: 7 additions & 7 deletions crates/cairo-lang-defs/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,6 @@ fn priv_module_data(db: &dyn DefsGroup, module_id: ModuleId) -> Maybe<ModuleData
files.push(module_file);

for item_ast in item_asts.elements(syntax_db) {
validate_attributes(
syntax_db,
&allowed_attributes,
module_file_id,
&item_ast,
&mut plugin_diagnostics,
);
let mut remove_original_item = false;
// Iterate the plugins by their order. The first one to change something (either
// generate new code, remove the original code, or both), breaks the loop. If more
Expand Down Expand Up @@ -405,6 +398,13 @@ fn priv_module_data(db: &dyn DefsGroup, module_id: ModuleId) -> Maybe<ModuleData
// Don't add the original item to the module data.
continue;
}
validate_attributes(
syntax_db,
&allowed_attributes,
module_file_id,
&item_ast,
&mut plugin_diagnostics,
);
match item_ast {
ast::Item::Constant(constant) => {
let item_id =
Expand Down
4 changes: 4 additions & 0 deletions crates/cairo-lang-plugins/src/test_data/config
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ fn f9() -> felt252 { 0 }
#[cfg(b)]
fn f10() -> felt252 { 0 }

#[cfg(no_cfg)]
#[unsupported_attr]
fn f11() -> felt252 { 0 }

trait RemoveTraitItem {
fn f0();
#[cfg(a)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1956,12 +1956,12 @@ trait ContractAbi {
}

//! > expected_diagnostics
error: Plugin diagnostic: Unsupported attribute.
error: Plugin diagnostic: The 'contract' attribute was deprecated, please use `starknet::contract` instead.
--> lib.cairo:1:1
#[contract]
^*********^

error: Plugin diagnostic: The 'contract' attribute was deprecated, please use `starknet::contract` instead.
error: Plugin diagnostic: Unsupported attribute.
--> lib.cairo:1:1
#[contract]
^*********^
Expand Down

0 comments on commit 3f776cc

Please sign in to comment.