-
Notifications
You must be signed in to change notification settings - Fork 13k
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
never patterns: Check bindings wrt never patterns #119610
Conversation
This comment has been minimized.
This comment has been minimized.
18d6c43
to
997103a
Compare
I'm computing the binding map for all patterns now (instead of just those that have or-patterns), this could affect perf. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…<try> never patterns: Check bindings wrt never patterns Never patterns: - Shouldn't contain bindings since they never match anything; - Don't count when checking that or-patterns have consistent bindings. r? `@compiler-errors`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
997103a
to
ad1bf5d
Compare
Alright, is this faster @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…<try> never patterns: Check bindings wrt never patterns Never patterns: - Shouldn't contain bindings since they never match anything; - Don't count when checking that or-patterns have consistent bindings. r? `@compiler-errors`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (1a3eeaf): comparison URL. Overall result: ✅ improvements - no 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. @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)This benchmark run did not return any relevant results for this metric. 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: 669.803s -> 670.085s (0.04%) |
// 1) Compute the binding maps of all arms. | ||
let maps = pats.iter().map(|pat| self.binding_mode_map(pat)).collect::<Vec<_>>(); | ||
// 1) Compute the binding maps of all arms; never patterns don't participate in this. | ||
let not_never_pats = pats |
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.
I wonder if we should use partition
here. It would be nice to collect never pats even if we don't use them... 🤷
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.
What would we do with them? Just store them in a Vec
and drop it? I'm not sure I find that clearer; I could add more comments if you think this is confusing
compiler/rustc_resolve/src/late.rs
Outdated
// 5) Finally bubble up all the binding maps. | ||
maps | ||
// 5) Bubble up the final binding map. | ||
let is_never_pat = not_never_pats.is_empty(); |
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.
This is a bit... confusing IMO
So an or-pat is "never" if all of its constituents are never? This feels easy to mess up.
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.
Yeah, Ok(x) | Err(!)
works anywhere a normal pattern would. Compare with Ok(!) | Err(!)
, which is unreachable and doesn't take a body.
Unless you meant that the implementation is confusing?
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.
No, I just mean the invariants feel subtle because what makes the product of patterns a never pattern is if one is never, but what makes a sum of patterns a never pattern is if all are never.
I think this should be made more clear, preferably with documentation and examples, because we really shouldn't be making resolve more complicated without helping future readers out, lol.
@rustbot ready |
7945588
to
5ccd29d
Compare
@bors r+ |
…compiler-errors never patterns: Check bindings wrt never patterns Never patterns: - Shouldn't contain bindings since they never match anything; - Don't count when checking that or-patterns have consistent bindings. r? `@compiler-errors`
💥 Test timed out |
@bors retry |
☀️ Test successful - checks-actions |
Finished benchmarking commit (714b29a): 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: 667.719s -> 667.744s (0.00%) |
@rustbot label: +perf-regression-triaged |
Never patterns:
r? @compiler-errors