-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Inner tool attributes emit spurious unused attribute warning #81661
Comments
I believe that in other positions, tool attributes like I imagine @petrochenkov might have a suggestion how how that should be handled. I'm uncertain if it makes sense to somehow just mark all tool attributes as used from within the resolver, or if the unused attributes lint should ignore tool attributes (I'm guessing the latter is harder because only the resolver knows the set of tool names AFAIK). More details: |
Inner attributes on file-based modules should certainly participate in expansion. Could someone check whether this is a regression from #69838 or a pre-existing issue? |
Before 1.44 this hits |
The regression seems pretty bad because it creates a hole in the |
Checking some more dates; |
Ah. So just to be clear, here's the behavior that I see: Inner attribute on file-based moduleProc-macro attribute: rustfmt::skip: Inner attributes on inline modulesProc-macro attribute: rustfmt::skip: It is not immediately clear to me how #69838 changed that (obviously it is touching the relevant code, but I'm uncertain how it worked prior to that, and I don't have time right now to investigate more). |
Assigning |
ast: Keep expansion status for out-of-line module items I.e. whether a module `mod foo;` is already loaded from a file or not. This is a pre-requisite to correctly treating inner attributes on such modules (rust-lang#81661). With this change AST structures for `mod` items diverge even more for AST structure for the crate root, which previously used `ast::Mod`. Therefore this PR removes `ast::Mod` from `ast::Crate` in the first commit, these two things are sufficiently different from each other, at least at syntactic level. Customization points for visiting a "`mod` item or crate root" were also removed from AST visitors (`fn visit_mod`). `ast::Mod` itself was refactored away in the second commit in favor of `ItemKind::Mod(Unsafe, ModKind)`.
Fixed in #82399. |
expand: Resolve and expand inner attributes on out-of-line modules Fixes rust-lang#81661 r? `@Aaron1011`
expand: Resolve and expand inner attributes on out-of-line modules Fixes rust-lang#81661 r? ``@Aaron1011``
ast: Keep expansion status for out-of-line module items I.e. whether a module `mod foo;` is already loaded from a file or not. This is a pre-requisite to correctly treating inner attributes on such modules (rust-lang/rust#81661). With this change AST structures for `mod` items diverge even more for AST structure for the crate root, which previously used `ast::Mod`. Therefore this PR removes `ast::Mod` from `ast::Crate` in the first commit, these two things are sufficiently different from each other, at least at syntactic level. Customization points for visiting a "`mod` item or crate root" were also removed from AST visitors (`fn visit_mod`). `ast::Mod` itself was refactored away in the second commit in favor of `ItemKind::Mod(Unsafe, ModKind)`.
expand: Resolve and expand inner attributes on out-of-line modules Fixes rust-lang#81661 r? `@Aaron1011`
I tried this code:
I expected to see this happen: No warnings and
bar.rs
will not get formatted bycargo fmt
.Instead, this happened:
cargo build
emits a warning,bar.rs
is correctly not formatted bycargo fmt
.While trying to minimize I changed
mod bar
to be an inline module, but that hits the unstablecustom_inner_attributes
feature (#54726). So mayberustfmt
shouldn't be obeying this attribute? Either way there's an inconsistency here with whetherrustc
orrustfmt
believe the attribute is active or not.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: