-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 SourceScope
for if let
bindings.
#97931
Conversation
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
2231462
to
dbcc102
Compare
This comment has been minimized.
This comment has been minimized.
dbcc102
to
18d0f97
Compare
if let Some(scope) = scope { | ||
self.source_scope = scope; | ||
} |
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 done in lower_match
for match
statements, so I do the same here.
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, this seems insufficient to solve the underlying issue, though its close.
77896a7
to
fe0dedc
Compare
This reverts commit fe0dedcb06947317d41a8570b7fff7f8690dcbff.
af8713a
to
e39c92e
Compare
scope 1 { | ||
} |
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'm not super happy about this, but only creating a scope
when we actually created bindings would require much more invasive changes since we need to bubble up the scope from declare_bindings
in lower_let_expr
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.
The other option would be to create a scope only for if let
statements regardless of if they have bindings.
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.
@nagisa do you consider this to be an issue? I've reduced it to only introduce scopes for if let
but it can still happen
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 haven't had an opportunity to give this PR a thorough look yet. I'll need to think about the implications of this approach too, so I can't promise I'll be able to get back to you this week.
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.
That's fine, this bug is a blocker for some of my work but I'll be at a conference next week anyways
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 think it is perfectly fine to create scopes liberally if it serves some purpose (such as simplifying the code) – it seems like it would likely be much more straightfoward to clean this up as a MIR transformation pass after the fact if this ever came up as a sticking point.
This comment has been minimized.
This comment has been minimized.
There is one failing test (is ignored on my local machine?) but I would like some validation of the approach anyways if possible. |
A test for this sort of issue would go into |
6cc4cf2
to
a5e27a1
Compare
Thanks for working on this @xldenis! I took the liberty of pushing a debuginfo test into your PR branch. |
I feel there might be some nice way to make @bors r+ |
📌 Commit a434e4c has been approved by |
I also think this, but more broadly I think the whole logic including |
☀️ Test successful - checks-actions |
Finished benchmarking commit (9a0b774): comparison url. Instruction count
Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Footnotes |
Fixes #97799.
I'm not sure how to test this properly, is there any way to observe the difference in behavior apart from
ui
tests? I'm worried that they would be overlooked in the case of a regression.