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

update readme for specifying msrv #6379

Merged
merged 3 commits into from
Nov 25, 2020
Merged

update readme for specifying msrv #6379

merged 3 commits into from
Nov 25, 2020

Conversation

suyashb95
Copy link
Contributor

@suyashb95 suyashb95 commented Nov 25, 2020

changelog: add some documentation for the msrv feature (#6097)
related PR: #6201

@rust-highfive
Copy link

r? @ebroto

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 25, 2020
@suyashb95
Copy link
Contributor Author

r? @flip1995

@rust-highfive rust-highfive assigned flip1995 and unassigned ebroto Nov 25, 2020
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

I would put this section below the section about allowing/denying lints.

Please also add a link to the supported lints: https://rust-lang.github.io/rust-clippy/master/index.html#msrv

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@flip1995
Copy link
Member

If you add the other lints mentioned in #6097, can you write a step-by-step instruction documentation inside doc on how to add lints to this configuration, please?

@suyashb95
Copy link
Contributor Author

If you add the other lints mentioned in #6097, can you write a step-by-step instruction documentation inside doc on how to add lints to this configuration, please?

Sure, I'll add that along in a different PR

README.md Outdated Show resolved Hide resolved
@flip1995
Copy link
Member

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented Nov 25, 2020

📌 Commit b2eb55b has been approved by flip1995

@bors
Copy link
Contributor

bors commented Nov 25, 2020

⌛ Testing commit b2eb55b with merge 3affffc...

bors added a commit that referenced this pull request Nov 25, 2020
update readme for specifying msrv

add some documentation for the `msrv` feature (#6097)
related PR: #6201
@bors
Copy link
Contributor

bors commented Nov 25, 2020

💔 Test failed - checks-action_test

@flip1995
Copy link
Member

@bors retry

@bors
Copy link
Contributor

bors commented Nov 25, 2020

⌛ Testing commit b2eb55b with merge 71f7dd8...

@bors
Copy link
Contributor

bors commented Nov 25, 2020

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing 71f7dd8 to master...

@bors bors merged commit 71f7dd8 into rust-lang:master Nov 25, 2020
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.)

}
```

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

Choose a reason for hiding this comment

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

IIRC semver::VersionReq treats 1.1 as ^1.1 without ^, right? If so, these requirements are verbose and I recommend not to mention them. Also, I don't think it is necessary to mention ~. MSRV is a specific version and is not a range. (I think it means strictly "it can be compiled with all stable versions after the specified version", but ~x.y and some requirements are not the correct requirements to express this so I think should ideally be rejected.)

Copy link
Member

Choose a reason for hiding this comment

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

~x.y and some requirements are not the correct requirements to express this so I think should ideally be rejected.

I looked at how rustc's cfg(version) parses this, but it is worse: rust-lang/rust#79436

I've commented about an alternative parser implementation, but I think that is probably sufficient for Clippy's use cases as well. If so, it may be preferable to use that instead of VersionReq.
(I'm not the maintainer of Clippy, so I'll leave the decision to maintainers, but I believe we shouldn't accept the extra requirement syntax that doesn't really make sense here.)

Copy link
Member

Choose a reason for hiding this comment

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

I don't see why the additional options to specify a version should be problematic. If you want to misuse those, that's on you. But I agree, that we should not mention that this is possible, otherwise it invites people to misuse it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@taiki-e yeah, the MSRV should definitely not be a range so tilde requirements don't make sense but, I don't think VersionReq treats 1.1 and ^1.1 the same way

e.g. In the snippet below, switching between 1.30 and ^1.30 produces different results

use semver::{Version, VersionReq};

fn main() {
  const MANUAL_STRIP_MSRV: Version = Version {
      major: 1,
      minor: 45,
      patch: 0,
      pre: Vec::new(),
      build: Vec::new(),
  };
  match VersionReq::parse("1.30") {
    Ok(vReq) => {
      if !vReq.matches(&MANUAL_STRIP_MSRV) {
        println!("Will lint!")
      } else {
        println!("Won't lint!")
      }
    },
    Err(_) => println!("Error")
  }
}

Copy link
Member

@taiki-e taiki-e Nov 26, 2020

Choose a reason for hiding this comment

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

@suyash458: Good catch! I didn't know that behavior. Given that cargo treats them as the same requirements, I think it's preferable to treat the same as cargo.

@flip1995: I agree with it is a user issue, but the more things that can be accepted, the more complicated the test will be. I think it is preferable to accept only the minimum necessary things if possible.
In fact, @suyash458 found that msrv = "major.minor" didn't seem to be working as expected. (Seems #6201 had tests for msrv = "major.minor.patch", msrv = "=major.minor.patch", msrv = "^major.minor", etc., but not for msrv = "major.minor".)

Copy link
Member

Choose a reason for hiding this comment

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

the more complicated the test will be. I think it is preferable to accept only the minimum necessary things if possible.

Well we use the semver crate, so this crate should have the tests, that the version matching works, so we can just assume, that it works. (And semver has indeed many unit tests)

Contrary to that: The semver documentation for VersionReq claims, that 1.30 is just an alias for ^1.30 and should therefore behave the same 😅

Copy link
Contributor Author

@suyashb95 suyashb95 Nov 26, 2020

Choose a reason for hiding this comment

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

@taiki-e, @flip1995 ^1.30, 1.30 and 1.30.0 are treated the same way in semver v0.9 but this behavior is broken in v0.11. Weird

bors added a commit that referenced this pull request Nov 27, 2020
Remove mention of possibility to specify the MSRV with a tilde/caret

As `@taiki-e` explained in #6379 (comment), mentioning this might be problematic.

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants