Skip to content

Warn about types not meeting MSRV #15296

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 1 commit into from
Jul 17, 2025

Conversation

samueltardieu
Copy link
Member

For example, the Duration type from the standard library was only introduced in Rust 1.3.0.

changelog: [incompatible_msrv]: recognize types exceeding MSRV as well

r? Jarcho @rustbot label +C-bug +I-false-negative

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Jul 16, 2025
Copy link

github-actions bot commented Jul 16, 2025

Lintcheck changes for 11bfeca

Lint Added Removed Changed
clippy::incompatible_msrv 67 0 9

This comment will be updated if you push new changes

Copy link
Contributor

@Jarcho Jarcho left a comment

Choose a reason for hiding this comment

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

Thank you.

@Jarcho Jarcho added this pull request to the merge queue Jul 16, 2025
@Jarcho Jarcho removed this pull request from the merge queue due to a manual request Jul 16, 2025
@samueltardieu
Copy link
Member Author

Yeah, I'll investigate the number of new hits!
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jul 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 16, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@Jarcho
Copy link
Contributor

Jarcho commented Jul 16, 2025

CStr and CString are using their core and alloc paths for the msrv. We had to handle this when Error moved to core so you should be able to copy that part. The rest are cfg dependant violations.

@samueltardieu
Copy link
Member Author

The main issue here is that if a MSRV-incompatible type is aliased, or is imported, then every use of it will trigger the lint as it resolves to the same DefId on which the stability information is recorded. And when it's cfg-gated, then one would have to trace the origin of the import and warn only on this.

I'll make the const part, which might be the less problematic one, independent of this one.

@Jarcho
Copy link
Contributor

Jarcho commented Jul 17, 2025

Looks like we didn't need to do anything with Error since the module was marked. You could just special case the two types as a quick fix since the lint doesn't handle paths anyways.

@samueltardieu samueltardieu force-pushed the incompatible-msrv-type branch from 921e9dc to 4fcd3d2 Compare July 17, 2025 09:47
@samueltardieu
Copy link
Member Author

Looks like we didn't need to do anything with Error since the module was marked. You could just special case the two types as a quick fix since the lint doesn't handle paths anyways.

Done.

For example, the `Duration` type from the standard library was only
introduced in Rust 1.3.0.
@samueltardieu samueltardieu force-pushed the incompatible-msrv-type branch from 4fcd3d2 to 11bfeca Compare July 17, 2025 09:53
@Jarcho Jarcho added this pull request to the merge queue Jul 17, 2025
Merged via the queue into rust-lang:master with commit e62e27b Jul 17, 2025
11 checks passed
@samueltardieu
Copy link
Member Author

I'll rebase #15297 on top.

@samueltardieu samueltardieu deleted the incompatible-msrv-type branch July 17, 2025 12:45
github-merge-queue bot pushed a commit that referenced this pull request Jul 18, 2025
This makes `const` contexts use the `const`-stability version
information instead of the regular stability one, as `const`-stability
may happen much later than stability in non-`const` contexts.

~~It includes the content of PR #15296 as its first
commit. I separated them because this one is more complex, and
#15296 may be merged more rapidly.~~

changelog: [`incompatible_msrv`]: check the right MSRV when in a `const`
context

r? Jarcho @rustbot label +C-bug +I-false-negative
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 I-false-negative Issue: The lint should have been triggered on code, but wasn't S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants