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

Fix: non_exhaustive_omitted_patterns by filtering unstable and doc hidden variants #89105

Merged
merged 1 commit into from
Oct 12, 2021

Conversation

DevinR528
Copy link
Contributor

Fixes: #89042

Now that #86809 has been merged there are cases (std::io::ErrorKind) where unstable feature gated variants were included in warning/error messages when the feature was not turned on. This filters those variants out of the return of SplitWildcard::new.

Variants marked doc(hidden) are filtered out of the witnesses list in Usefulness::apply_constructor.

Probably worth a perf run 🤷 since this area can be sensitive.

@rust-highfive
Copy link
Collaborator

r? @jackh726

(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 Sep 19, 2021
@Nadrieril
Copy link
Member

Nice, that was quick! I'd just ask for separate tests for the unstable part and the doc(hidden) part. It's cleaner to define our enum than to rely on ErrorKind since it will change over time.

unstable is tricky because it can normally only be defined within std. This seems to work:

#![feature(staged_api)]
#![stable(feature = "stable_test_feature", since = "1.0.0")]

#[unstable(feature = "unstable_test_feature", issue = "none")]
pub enum Foo {
	...
}

Look at e.g. src/test/ui/pattern/usefulness/empty-match.rs and src/test/ui/pattern/usefulness/auxiliary/empty.rs for how to use an external file (which will be compiled as a different crate) in a test.

@Nadrieril
Copy link
Member

Nadrieril commented Sep 19, 2021

Btw I'm only revieweing the logic, I don't feel competent to review the actual diagnostic change.
Actually, could you add the tests first, so we see the diagnostic changes in the following commits (you seem quite competent at editing commits; if not don't worry)?

@rust-log-analyzer

This comment has been minimized.

@DevinR528 DevinR528 force-pushed the reachable-fix branch 2 times, most recently from 330e369 to 6cd3f8a Compare September 21, 2021 13:27
@DevinR528
Copy link
Contributor Author

Hopefully, these commits are clear enough and I didn't go the other way (splitting them too much so they are hard to interpret as a whole).

@Nadrieril
Copy link
Member

Woo, great! LGTM.

I expect a perf degradation because of the extra stability test. The doc(hidden) test is on a diagnostics-only path so won't matter. I expect that match-stress-enum will particularly suffer because it has a ton of variants.
Given that this is a correctness fix we might have to accept the perf regression anyway.

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 21, 2021
@bors
Copy link
Contributor

bors commented Sep 21, 2021

⌛ Trying commit 6cd3f8afa896b6ad831e7ed202a34ef13a35371c with merge 7504632cc026b5926702afbf29cbd36579ad93fb...

@bors
Copy link
Contributor

bors commented Sep 22, 2021

☀️ Try build successful - checks-actions
Build commit: 7504632cc026b5926702afbf29cbd36579ad93fb (7504632cc026b5926702afbf29cbd36579ad93fb)

@rust-timer
Copy link
Collaborator

Queued 7504632cc026b5926702afbf29cbd36579ad93fb with parent ac2d9fc, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7504632cc026b5926702afbf29cbd36579ad93fb): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking 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 led to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 22, 2021
@Nadrieril
Copy link
Member

Nadrieril commented Sep 22, 2021

@DevinR528 if you're curious, my general rules for splitting commits: each commit should compile and make sense on its own (I also commit the test outputs), and if two changes make sense individually I commit them separately. So I often end up with a ton of small commits ^^'. I haven't completely figured out how to limit that

@DevinR528
Copy link
Contributor Author

@Nadrieril cool thanks for the commt feedback/ideas! I will defiantly keep that in mind/try to use that as a guide.

Of course, no perf problems when we both expect them 🙄, you just never know.

@Nadrieril
Copy link
Member

Merge conflict incoming because of #88950 . It's a rather massive change, but the main difference for this PR is that I've replaced Fields::wildcards(pcx, ctor).apply(pcx, ctor) with DeconstructedPat::wild_from_ctor(pcx, ctor) and Pat::wildcard_from_ty(ty) with DeconstructedPat::wildcard(ty). That PR replaces Pat with my own version that knows about constructors and fields, which should make things simpler.

@DevinR528
Copy link
Contributor Author

I started rebasing will hopefully have time to finish it today and I'll check out #89382 (comment) (but open separate PR to fix it)

@rust-timer
Copy link
Collaborator

Queued aa7536dbf98257fbaa2f6b38c1acb694f6c3cf9a with parent 9a75781, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (aa7536dbf98257fbaa2f6b38c1acb694f6c3cf9a): comparison url.

Summary: This change led to small relevant regressions 😿 in compiler performance.

  • Small regression in instruction counts (up to 0.4% on full builds of cranelift-codegen)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking 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 led to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf +perf-regression

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 11, 2021
@oli-obk oli-obk removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 11, 2021
@rust-log-analyzer

This comment has been minimized.

@Nadrieril
Copy link
Member

Phew, took us a lot of tries but we're there. Any remaining comments @oli-obk? Otherwise r=me after squashing the commits.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 12, 2021

@bors r=Nadrieril

@bors
Copy link
Contributor

bors commented Oct 12, 2021

📌 Commit 1c88c9463d1b2a2962485387e8b6d0e85f0a0c0d has been approved by Nadrieril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 12, 2021
Add test cases for unstable variants
Add test cases for doc hidden variants
Move is_doc_hidden to method on TyCtxt
Add unstable variants test to reachable-patterns ui test
Rename reachable-patterns -> omitted-patterns
@Nadrieril
Copy link
Member

Hm you pushed the squashed commits after bors recorded approval. I think this should unaccept the PR but bors hasn't noticed yet. Let's unaccept and reaccept.

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 12, 2021
@Nadrieril
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 12, 2021

📌 Commit 2a042d6 has been approved by Nadrieril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 12, 2021
@DevinR528
Copy link
Contributor Author

Should I have done something differently or did bors mess up?

@Nadrieril
Copy link
Member

🤷‍♀️ Neither, I just clarified a potential confusion around which commit is getting merged.

@bors
Copy link
Contributor

bors commented Oct 12, 2021

⌛ Testing commit 2a042d6 with merge d7c97a0...

@bors
Copy link
Contributor

bors commented Oct 12, 2021

☀️ Test successful - checks-actions
Approved by: Nadrieril
Pushing d7c97a0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 12, 2021
@bors bors merged commit d7c97a0 into rust-lang:master Oct 12, 2021
@rustbot rustbot added this to the 1.57.0 milestone Oct 12, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d7c97a0): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

@rustbot rustbot removed the perf-regression Performance regression. label Oct 13, 2021
@DevinR528 DevinR528 deleted the reachable-fix branch October 14, 2021 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-non_exhaustive_omitted_patterns_lint `#![feature(non_exhaustive_omitted_patterns_lint)]` merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New non_exhaustive_omitted_patterns lint exposes unstable and hidden enum variants.
9 participants