-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Warn users who set non_exhaustive_omitted_patterns
lint level on a match arm
#117094
Conversation
This comment has been minimized.
This comment has been minimized.
18e7783
to
d53f545
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
(the only clippy change is a test output) |
I realized this will likely regress the match-stress bench because it has 8000 arms. Very much a case where this bench is not representative of the world @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Warn users who set `non_exhaustive_omitted_patterns` lint level on a match arm Before rust-lang#116734, the recommended usage of the [`non_exhaustive_omitted_patterns` lint](rust-lang#89554) was: ```rust match Bar::A { Bar::A => {}, #[warn(non_exhaustive_omitted_patterns)] _ => {}, } ``` After rust-lang#116734 this no longer makes sense, and recommended usage is now: ```rust #[warn(non_exhaustive_omitted_patterns)] match Bar::A { Bar::A => {}, _ => {}, } ``` As you can guess, this silently breaks all uses of the lint that used the previous form. This is a problem in particular because `syn` recommends usage of this lint to its users in the old way. This PR emits a warning when the previous form is used so users can update. r? `@cjgillot`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
d53f545
to
485b566
Compare
Finished benchmarking commit (c6ca96d): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 636.074s -> 636.231s (0.02%) |
arm.hir_id, | ||
arm.pat.span(), | ||
NonExhaustiveOmittedPatternLintOnArm, | ||
); |
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.
Should we add a suggestion to move the attribute on the match itself?
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.
Oh yes good idea, I'll look into it!
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.
Done!
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.
Well, I added a suggestion to add the lint on the match, I didn't find how to add a suggestion to remove the lint on the arm. Should I do this too?
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.
You need to suggest an empty string in place of the current lint attribute's span.
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.
Hmm, I can get the span for the lint level, but it's not the span of the whole attribute; removing it does:
- #[deny(non_exhaustive_omitted_patterns)]
+ #[deny()]
_ => {}
It seems lint_level_at_node
does not return anything else than this span to identify where the lint was set. Can I use the span to get to the span of the whole attribute somehow? Or use the arm HirId
? It's not helping that rustc internal docs are missing atm :'(
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.
Turns out that even with a better span, it's pretty hard to make clear that I'm suggesting to remove the line. Instead I added a "remove this" span label, it's a lot clearer ^^
This comment was marked as outdated.
This comment was marked as outdated.
feac3b9
to
64577dc
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #117564) made this pull request unmergeable. Please resolve the merge conflicts. |
64577dc
to
f0e8330
Compare
@bors r+ |
Thank u! |
☀️ Test successful - checks-actions |
Finished benchmarking commit (f81d6f0): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 635.472s -> 635.521s (0.01%) |
84: Automated pull from upstream `master` r=Dajamante a=github-actions[bot] This PR pulls the following changes from the upstream repository: * rust-lang/rust#117585 * rust-lang/rust#117576 * rust-lang/rust#96979 * rust-lang/rust#117191 * rust-lang/rust#117179 * rust-lang/rust#117574 * rust-lang/rust#117537 * rust-lang/rust#117608 * rust-lang/rust#117596 * rust-lang/rust#117588 * rust-lang/rust#117524 * rust-lang/rust#116017 * rust-lang/rust#117504 * rust-lang/rust#117469 * rust-lang/rust#116218 * rust-lang/rust#117589 * rust-lang/rust#117581 * rust-lang/rust#117503 * rust-lang/rust#117590 * rust-lang/rust#117583 * rust-lang/rust#117570 * rust-lang/rust#117562 * rust-lang/rust#117534 * rust-lang/rust#116894 * rust-lang/rust#110340 * rust-lang/rust#113343 * rust-lang/rust#117579 * rust-lang/rust#117094 * rust-lang/rust#117566 * rust-lang/rust#117564 * rust-lang/rust#117554 * rust-lang/rust#117550 * rust-lang/rust#117343 * rust-lang/rust#115274 * rust-lang/rust#117540 * rust-lang/rust#116412 * rust-lang/rust#115333 * rust-lang/rust#117507 * rust-lang/rust#117538 * rust-lang/rust#117533 * rust-lang/rust#117523 * rust-lang/rust#117520 * rust-lang/rust#117505 * rust-lang/rust#117434 * rust-lang/rust#117535 * rust-lang/rust#117510 * rust-lang/rust#116439 * rust-lang/rust#117508 Co-authored-by: Ben Wiederhake <BenWiederhake.GitHub@gmx.de> Co-authored-by: SabrinaJewson <sejewson@gmail.com> Co-authored-by: J-ZhengLi <lizheng135@huawei.com> Co-authored-by: koka <koka.code@gmail.com> Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com> Co-authored-by: Joshua Liebow-Feeser <joshlf@users.noreply.github.com> Co-authored-by: lengyijun <sjtu5140809011@gmail.com> Co-authored-by: Zalathar <Zalathar@users.noreply.github.com> Co-authored-by: Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> Co-authored-by: Philipp Krones <hello@philkrones.com> Co-authored-by: y21 <30553356+y21@users.noreply.github.com> Co-authored-by: bors <bors@rust-lang.org> Co-authored-by: bohan <bohan-zhang@foxmail.com>
@rustbot label: +perf-regression-triaged |
Before #116734, the recommended usage of the
non_exhaustive_omitted_patterns
lint was:After #116734 this no longer makes sense, and recommended usage is now:
As you can guess, this silently breaks all uses of the lint that used the previous form. This is a problem in particular because
syn
recommends usage of this lint to its users in the old way. This PR emits a warning when the previous form is used so users can update.r? @cjgillot