Skip to content

update readme for specifying msrv #6379

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

Merged
merged 3 commits into from
Nov 25, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,32 @@ cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...
```
Note that if you've run clippy before, this may only take effect after you've modified a file or ran `cargo clean`.

### Specifying the minimum supported Rust version

Projects that intend to support old versions of Rust can disable lints pertaining to newer features by
specifying the minimum supported Rust version (MSRV) in the clippy configuration file.

```toml
msrv = "1.30.0"
Copy link
Member

Choose a reason for hiding this comment

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

IIUC the #6201 implementation does not consider the exact patch version, so I think it is preferable to always omit the patch version in the documentation.

Copy link
Member

@flip1995 flip1995 Nov 26, 2020

Choose a reason for hiding this comment

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

It does, if you specify it. So if you specify msrv = 1.30.0 and a lint is marked as 1.30.1 this lint will not trigger. The thing is, that features don't usually get stabilized in a patch version, so no lint will probably ever have a patch version >0

Copy link
Member

Choose a reason for hiding this comment

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

It does, if you specify it. So if you specify msrv = 1.30.0 and a lint is marked as 1.30.1 this lint will not trigger.

Oh, I didn't realize it was possible with the current implementation. Thanks for pointing it out.

The thing is, that features don't usually get stabilized in a patch version, so no lint will probably ever have a patch version >0

Yeah, this is what I actually wanted to say. (There was a case where stabilization was reverted in a patch version due to a security vulnerability, but I don't think there were any cases where new APIs were stabilized.)

```

The MSRV can also be specified as an inner attribute, like below.

```rust
#![feature(custom_inner_attributes)]
#![clippy::msrv = "1.30.0"]

fn main() {
...
}
```

Tilde/Caret version requirements(like `^1.0` or `~1.2`) can be specified as well.

Note: `custom_inner_attributes` is an unstable feature so it has to be enabled explicitly.

Lints that recognize this configuration option can be found [here](https://rust-lang.github.io/rust-clippy/master/index.html#msrv)

## Contributing

If you want to contribute to Clippy, you can find more information in [CONTRIBUTING.md](https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md).
Expand Down