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

MSRV attribute is not scoped #6920

Closed
camsteffen opened this issue Mar 16, 2021 · 1 comment · Fixed by #9924
Closed

MSRV attribute is not scoped #6920

camsteffen opened this issue Mar 16, 2021 · 1 comment · Fixed by #9924
Labels
C-bug Category: Clippy is not doing the correct thing E-medium Call for participation: Medium difficulty level problem and requires some initial experience.

Comments

@camsteffen
Copy link
Contributor

Example:

#![feature(custom_inner_attributes)]

mod my_mod {
    #![clippy::msrv = "1.0.0"]
}

fn hi() {
    // the `manual_strip` lint is suppressed by the attribute in `my_mod`
    let s = "hello, world!";
    if s.starts_with("hello, ") {
        assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
    }
}

If we don't want to support this sort of usage, maybe we can just warn or error when the attribute is found in a non-crate.

@camsteffen camsteffen added the C-bug Category: Clippy is not doing the correct thing label Mar 16, 2021
@camsteffen camsteffen added E-hard Call for participation: This a hard problem and requires more experience or effort to work on E-medium Call for participation: Medium difficulty level problem and requires some initial experience. and removed E-hard Call for participation: This a hard problem and requires more experience or effort to work on labels Mar 29, 2021
@hellow554
Copy link
Contributor

hellow554 commented May 10, 2022

There's this testfile https://github.com/rust-lang/rust-clippy/blob/master/tests/ui/min_rust_version_attr.rs and it seems that scoping is supported in some way.

It seems, that the inner attribute starts from that line on in the code, because if I move your hi function above my_mod the lint is triggered correctly.

I'm not sure if that's a restriction of the custom_inner_attributes feature or clippys fault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing E-medium Call for participation: Medium difficulty level problem and requires some initial experience.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants