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 |
@@ -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); |
oli-obk
May 17, 2018
Collaborator
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.
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
c473221
to
cb2f507
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