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

Allow parsing ItemMod in inner attribute #591

Closed
wants to merge 3 commits into from

Conversation

nhynes
Copy link

@nhynes nhynes commented Mar 7, 2019

Syn assumes that every ItemMod has an ident (i.e. pub mod $ident { ... }, but this is not the case when adding an inner attribute to a file mod:

#![feature(custom_inner_attributes, proc_macro_hygiene)]
#![MyCustomAttribute]

// ...

This PR remedies this by making ItemMod.ident an Option.

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Rustc does not support crate-level and module-level inner attributes, so I am not going to accept syntax tree changes based on what invalid tokens the current implementation happens to pass. The behavior of passing a mod with missing name should be considered an accident arising from the implementation of some other feature. Once there is an RFC or substantial discussion affirming some behavior as the intended behavior, then we can consider making syntax tree changes if necessary.

@dtolnay dtolnay closed this Mar 8, 2019
@nhynes nhynes deleted the mod-inner-attr branch March 8, 2019 06:18
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.

2 participants