Skip to content

What's up with attributes? #8

Closed

Description

@matklad

I have no idea how the attribute grammar should look like. Is it still key-value pairs, or have we gone full token-trees? The letter would be unfortunate: token trees means zero support from IDEs: no extend selection for cases like #[foo= 1 + 2 + 3], because we don't know that 1 + 2 + 3 is an exression.

Activity

  1. mystor commented on Jan 11, 2018

    @mystor
    Contributor

    The answer is that an attribute can contain arbitrary token trees (though that's behind a feature flag right now). That being said, most attributes take the form of a "Meta". (e.g. in syn: https://docs.rs/syn/0.12.3/syn/enum.Meta.html). I imagine that we could add support, like in syn, a mechanism for interpreting the token trees as an Option<Meta>. IDEs could then take advantage of meta-like attributes to provide good support.

  2. matklad commented on Jan 11, 2018

    @matklad
    ContributorAuthor

    Great! Is there any RFC for this? I know about RFC for meta(and this is what currently suppported here) but token trees in the source code were a surprise for me.

    Pinning down structure of attributes to meta is very useful, because you actually can show syntax errors...

  3. mystor commented on Jan 11, 2018

    @mystor
    Contributor

    It's part of the procedural macros work. See rust-lang/rust#40346 for the commentary on the PR to rustc.

  4. matklad commented on Jan 11, 2018

    @matklad
    ContributorAuthor

    Excellent, thanks a lot @mystor for this and for other comments as well, they are really helpful! ❤️

  5. added a commit that references this issue on Apr 3, 2022
  6. added 2 commits that reference this issue on Nov 7, 2025
    fe7ac06
    3d5a1ba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions