-
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
Visit expressions in-order when resolving pattern bindings #92237
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
3469479
to
99fa18c
Compare
compiler/rustc_resolve/src/late.rs
Outdated
@@ -1603,97 +1603,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { | |||
pat_src: PatternSource, | |||
bindings: &mut SmallVec<[(PatBoundCtx, FxHashSet<Ident>); 1]>, | |||
) { | |||
self.resolve_pattern_inner(pat, pat_src, bindings); | |||
ResolvePatternWalker { late: self, pat_src, bindings }.visit_pat(pat); |
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.
Do we really need another visitor? We may risk forgetting part forwarding newly added methods between the two visitors.
Could the same results be achieved by calling walk_pat
earlier?
Or could we have the ResolvePatternWalker
restricted to patterns and not forwarding anything else?
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.
Actually that's a very good point. We can achieve the same behavior by calling walk_pat first, then declaring the bindings. Fixed up the PR to be much simpler.
99fa18c
to
b6756fd
Compare
r? @cjgillot |
b6756fd
to
b1529a6
Compare
@rustbot label -S-waiting-on-author +S-waiting-on-review |
@bors r+ |
📌 Commit b1529a6 has been approved by |
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#92075 (rustdoc: Only special case struct fields for intra-doc links, not enum variants) - rust-lang#92118 (Parse and suggest moving where clauses after equals for type aliases) - rust-lang#92237 (Visit expressions in-order when resolving pattern bindings) - rust-lang#92340 (rustdoc: Start cleaning up search index generation) - rust-lang#92351 (Add long error explanation for E0227) - rust-lang#92371 (Remove pretty printer space inside block with only outer attrs) - rust-lang#92372 (Print space after formal generic params in fn type) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…n-DPC Regression test for rust-lang#82866 Saw that this issue was open when i was cleaning my old branch for rust-lang#92237. I am also not opposed to not adding an extra test and just closing rust-lang#82866. Fixes rust-lang#82866
[edited:] Visit the pattern's sub-expressions before defining any bindings.
Otherwise, we might get into a case where a Lit/Range expression in a pattern has a qpath pointing to a Ident pattern that is defined after it, causing an ICE when lowering to HIR. I have a more detailed explanation in the issue linked.
Fixes #92100