@@ -181,16 +181,23 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
181
181
if ( src, dest) . has_opaque_types ( ) {
182
182
return true ;
183
183
}
184
- // Normalize projections and things like that.
185
- let param_env = self . param_env . with_reveal_all_normalized ( self . tcx ) ;
186
- let src = self . tcx . normalize_erasing_regions ( param_env, src) ;
187
- let dest = self . tcx . normalize_erasing_regions ( param_env, dest) ;
188
184
185
+ // Normalize projections and things like that.
189
186
// Type-changing assignments can happen when subtyping is used. While
190
187
// all normal lifetimes are erased, higher-ranked types with their
191
188
// late-bound lifetimes are still around and can lead to type
192
189
// differences. So we compare ignoring lifetimes.
193
- equal_up_to_regions ( self . tcx , param_env, src, dest)
190
+
191
+ // First, try with reveal_all. This might not work in some cases, as the predicates
192
+ // can be cleared in reveal_all mode. We try the reveal first anyways as it is used
193
+ // by some other passes like inlining as well.
194
+ let param_env = self . param_env . with_reveal_all_normalized ( self . tcx ) ;
195
+ if equal_up_to_regions ( self . tcx , param_env, src, dest) {
196
+ return true ;
197
+ }
198
+
199
+ // If this fails, we can try it without the reveal.
200
+ equal_up_to_regions ( self . tcx , self . param_env , src, dest)
194
201
}
195
202
}
196
203
0 commit comments