Skip to content

feat: Add -Zhint-msrv flag#17106

Open
clubby789 wants to merge 1 commit into
rust-lang:masterfrom
clubby789:lint-rust-version
Open

feat: Add -Zhint-msrv flag#17106
clubby789 wants to merge 1 commit into
rust-lang:masterfrom
clubby789:lint-rust-version

Conversation

@clubby789

@clubby789 clubby789 commented Jun 16, 2026

Copy link
Copy Markdown

Pass -Zhint-msrv={package.rust-version} to rustc when -Zhint-msrv is passed to Cargo, and the rust-version field is set.
This flag was implemented at rust-lang/rust#157707, renamed in rust-lang/rust#158134

Tracking issue: rust-lang/rust#157574

@rustbot rustbot added the A-build-execution Area: anything dealing with executing the compiler label Jun 16, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 16, 2026
@rustbot

rustbot commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @weihanglo (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

@clubby789 clubby789 force-pushed the lint-rust-version branch from 2486c65 to 701d42c Compare June 16, 2026 11:02
Comment thread src/cargo/core/compiler/mod.rs Outdated
}

if let Some(version) = unit.pkg.manifest().rust_version()
&& bcx.gctx.nightly_features_allowed

@epage epage Jun 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we normally implicitly opt-in to unstable features based on the channel (note the name "allowed"). If/when we do, it is part of pre-stabilization.

View changes since the review

@clubby789 clubby789 Jun 16, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I could put this behind a cargo unstable flag, the only worry would be that that wouldn't result in a lot of real world testing of the flag.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the only worry would be that that wouldn't result in a lot of real world testing of the flag.

That is a valid concern, as this is less likely a flag people would opt-in. I knew you implemented it. How confident are you in the implementation and do we have a clear schedule of incoming stabilization?

The other approach we have is crater run. While the actual lint report varies, crater at least ensure things is not broken.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The implementation is reasonably simple. I think the main concerns WRT stabilisation would be

  • Applying MSRV to a wider set of lints
  • More discussion around the exact semantics of the flag (i.e. the linked comment in the tracking issue)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Encouraging use of this through config would make it easier for more people to opt-in

@clubby789 clubby789 force-pushed the lint-rust-version branch from 701d42c to 96724af Compare June 16, 2026 12:11
@rustbot rustbot added the A-unstable Area: nightly unstable support label Jun 16, 2026
@clubby789 clubby789 changed the title feat: Set -Zlint-rust-version on nightly feat: Add -Zlint-rust-version flag Jun 16, 2026
Comment thread src/cargo/core/features.rs Outdated
@rustbot rustbot added the A-documenting-cargo-itself Area: Cargo's documentation label Jun 16, 2026
@clubby789

Copy link
Copy Markdown
Author

It might be good to wait on possible renaming (rust-lang/rust#157574 (comment)) before I push this forward

@clubby789 clubby789 marked this pull request as draft June 16, 2026 17:40
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 16, 2026
@weihanglo

Copy link
Copy Markdown
Member

Would love to see some tests when you get back on this :)

@rustbot

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. label Jun 18, 2026
@clubby789 clubby789 force-pushed the lint-rust-version branch 3 times, most recently from cc59ffa to 24c8147 Compare June 22, 2026 18:49
@clubby789 clubby789 changed the title feat: Add -Zlint-rust-version flag feat: Add -Zhint-msrv flag Jun 22, 2026
@clubby789 clubby789 marked this pull request as ready for review June 22, 2026 18:50
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 22, 2026
@clubby789

Copy link
Copy Markdown
Author

I couldn't figure out how to test what args are passed, and right now no lints make use of this flag

@weihanglo

Copy link
Copy Markdown
Member

I couldn't figure out how to test what args are passed, and right now no lints make use of this flag

Passing --verbose. For example, this

@clubby789 clubby789 force-pushed the lint-rust-version branch from 24c8147 to a5d4476 Compare June 22, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-execution Area: anything dealing with executing the compiler A-documenting-cargo-itself Area: Cargo's documentation A-unstable Area: nightly unstable support S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. 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.

4 participants