@@ -225,28 +225,17 @@ pub(super) fn mir_assign_valid_types<'tcx>(
225
225
src : TyAndLayout < ' tcx > ,
226
226
dest : TyAndLayout < ' tcx > ,
227
227
) -> bool {
228
- if src. ty == dest. ty {
229
- // Equal types, all is good. Layout will also be equal.
230
- // (Enum variants would be an exception here as they have the type of the enum but different layout.
231
- // However, those are never the type of an assignment.)
232
- return true ;
233
- }
234
- if src. layout != dest. layout {
235
- // Layout differs, definitely not equal.
236
- // We do this here because Miri would *do the wrong thing* if we allowed layout-changing
237
- // assignments.
238
- return false ;
239
- }
240
-
241
228
// Type-changing assignments can happen when subtyping is used. While
242
229
// all normal lifetimes are erased, higher-ranked types with their
243
230
// late-bound lifetimes are still around and can lead to type
244
231
// differences. So we compare ignoring lifetimes.
245
- //
246
- // Note that this is not fully correct (FIXME):
247
- // lifetimes in invariant positions could matter (e.g. through associated types).
248
- // We rely on the fact that layout was confirmed to be equal above.
249
- equal_up_to_regions ( tcx, param_env, src. ty , dest. ty )
232
+ if equal_up_to_regions ( tcx, param_env, src. ty , dest. ty ) {
233
+ // Make sure the layout is equal, too -- just to be safe. Miri really needs layout equality.
234
+ assert_eq ! ( src. layout, dest. layout) ;
235
+ true
236
+ } else {
237
+ false
238
+ }
250
239
}
251
240
252
241
/// Use the already known layout if given (but sanity check in debug mode),
0 commit comments