Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allow_attr attribute for allowing additional attributes #7253

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

DelevoXDG
Copy link

@DelevoXDG DelevoXDG commented Feb 10, 2025

Adds allow_attr attribute that allows specifying certain attributes that are available only in given scope. This may be useful for marking certain elements of larger entity, e.g. marking enum variant as default:

#[allow_attr(default)]
enum MyEnum {
    Variant0: Type0,
    
    #[default]
    Variant1: Type1,
    ...
}

@reviewable-StarkWare
Copy link

This change is Reviewable

@maciektr maciektr requested review from orizi and maciektr February 10, 2025 14:29
@DelevoXDG DelevoXDG marked this pull request as ready for review February 11, 2025 14:35
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 6 files at r1, 1 of 1 files at r4, all commit messages.
Reviewable status: 2 of 6 files reviewed, 1 unresolved discussion (waiting on @maciektr)


crates/cairo-lang-defs/src/test.rs line 488 at r4 (raw file):

}

cairo_lang_test_utils::test_file_test!(

Why can't this be with any other test group?

@DelevoXDG
Copy link
Author

Why can't this be with any other test group?

Can you please clarify what you mean? Which test group do you think it should be in?

@DelevoXDG DelevoXDG requested a review from orizi February 12, 2025 11:33
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment only on https://reviewable.io/reviews/starkware-libs/cairo/7253#-.

Reviewable status: 2 of 6 files reviewed, 1 unresolved discussion (waiting on @DelevoXDG and @maciektr)


crates/cairo-lang-defs/src/test.rs line 488 at r4 (raw file):

Previously, orizi wrote…

Why can't this be with any other test group?

this seems to prevent a semantic diagnostic - so maybe just add it as part of the semanitc tests.
(despite the fact it is handled in defs db)

Copy link
Author

@DelevoXDG DelevoXDG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 7 files reviewed, 1 unresolved discussion (waiting on @maciektr and @orizi)


crates/cairo-lang-defs/src/test.rs line 488 at r4 (raw file):

Previously, orizi wrote…

this seems to prevent a semantic diagnostic - so maybe just add it as part of the semanitc tests.
(despite the fact it is handled in defs db)

Done.

@maciektr maciektr requested a review from orizi February 12, 2025 20:00
@DelevoXDG DelevoXDG force-pushed the zdobnikau/allow-attr branch from fd7ea79 to e27dcc8 Compare February 12, 2025 20:22
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 6 files at r1, 5 of 6 files at r5, all commit messages.
Reviewable status: 6 of 7 files reviewed, 2 unresolved discussions (waiting on @maciektr)


crates/cairo-lang-defs/src/db.rs line 736 at r5 (raw file):

) -> OrderedHashSet<String> {
    let mut empty_args_diagnostics = Vec::new();
    let mut identifier_diadnostics = Vec::new();

do a for with continues instead of creating intermediary vectors.

Code quote:

) -> OrderedHashSet<String> {
    let mut empty_args_diagnostics = Vec::new();
    let mut identifier_diadnostics = Vec::new();

crates/cairo-lang-defs/src/db.rs line 779 at r5 (raw file):

    plugin_diagnostics.extend(identifier_diadnostics);

    base_allowed_attributes.union(&additional_attributes).cloned().collect()

this cloning of the set seems like it could get quite costly in some cases.

maybe just return another set and check both?

Code quote:

    base_allowed_attributes.union(&additional_attributes).cloned().collect()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants