-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Automatically set MSRV for code under #[cfg(version)]
#14940
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @samueltardieu. Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM with the nit and the extra test. I'll let @flip1995 do the final check since he wants to be involved the the book is modified.
clippy_utils/src/msrvs.rs
Outdated
return Some(version); | ||
let mut first_clippy_attr = None; | ||
let mut clippy_msrv = None; | ||
let mut cfg_version: Option<RustcVersion> = None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, this looks strange to have only one ascribed variable.
let mut cfg_version: Option<RustcVersion> = None; | |
let mut cfg_version = None; |
tests/ui/cfg_version_msrv.rs
Outdated
#[clippy::msrv = "1.40"] | ||
#[cfg(version("1.80"))] | ||
fn both_attributes(i: i32) { | ||
// if both are specified on the same node then `clippy::msrv` takes precedence | ||
let _ = i.isqrt(); | ||
//~^ ERROR: is `1.40.0` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a non-regression test, could you duplicate this test and reverse both versions (because here clippy::msrv
is also the smaller one)?
r? @flip1995 |
Thanks. |
Sorry, I forgot I wanted to let @flip1995 weight in. |
Fixes #14827
Semantics:
#[clippy::msrv]
and#[cfg(version)]
applying to the same node#[clippy::msrv]
winsnot()
version bounds are ignored (if double/quad/etc negated it will be applied once more)all
/any
the lowest found version is usedWhen the feature is stable we can go back and improve the docs a bit more with a better example
changelog: code using
#[cfg(version)]
will have the MSRV automatically detected