-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 SpanlessHash and SpanlessEq tables #2763
Conversation
Oh, it's in a different body table because it's a constant ;). The expression variant (ExprRepeat) has a field of type BodyId. Try calling |
Thanks! The code slowly starts to make sense to me 👀 8fdf2a8#diff-facf8838686f92b7be75999cfbe7e987R493 fixes the SpanlessHash ICE. However it feels not correct to me, because it will set the table to the table of the constant for the following iterations, which could potentially cause other lookup issues. And actually it does change the debug output for |
clippy_lints/src/utils/hir_utils.rs
Outdated
@@ -490,6 +490,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { | |||
let c: fn(_, _) -> _ = ExprRepeat; | |||
c.hash(&mut self.s); | |||
self.hash_expr(e); | |||
self.tables = self.cx.tcx.body_tables(l_id); | |||
self.hash_expr(&self.cx.tcx.hir.body(l_id).value); |
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 can store the old tables in a temporary variable and restore them afterwards. This is essentially how rustc does it for LateContext
. We should probably abstract that feature in some generic form so all the cases where we or rustc do it can be made correct in a way that can't be accidentally forgotten.
1d0105e
to
a9e09ba
Compare
c473221
to
cb2f507
Compare
Ok, I think this is ready for review @oli-obk |
Thanks very much for this! |
This makes sure the correct tables are used for constant lookup around
SpanlessHash
andSpanlessEq
Fixes #2767
Fixes #2594
Fixes #2499
Closes #1783
Fixes #1782