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

no_implicit_prelude attribute is not validated properly with unused_attributes lint #81104

Open
ehuss opened this issue Jan 17, 2021 · 0 comments
Labels
A-attributes Area: #[attributes(..)] A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ehuss
Copy link
Contributor

ehuss commented Jan 17, 2021

The no_implicit_prelude attribute can only be applied to modules and the crate root. However, it seems to be silently ignored in all other positions:

#[no_implicit_prelude]
fn f() {
    #[no_implicit_prelude]
    {
        #[no_implicit_prelude]
        let s = String::new(); // OK
    }
}

I expected to see this happen: The UNUSED_ATTRIBUTES lint should trigger for all positions where it is ignored (with a future-incompatible note, since this should never have been allowed), possibly transitioned to a hard error in the future.

Instead, this happened: Attribute is ignored without a warning.

NOTE: There is a test which checks this, but it is only firing because there is already a crate-level no_implicit_prelude attribute.

rustc 1.51.0-nightly (c97f11af7 2021-01-10)

@ehuss ehuss added the C-bug Category: This is a bug. label Jan 17, 2021
@jonas-schievink jonas-schievink added A-attributes Area: #[attributes(..)] A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: #[attributes(..)] A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants