@@ -67,12 +67,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
67
67
}
68
68
69
69
Pointer ( PointerCast :: ReifyFnPointer ) => {
70
+ // All reifications must be monomorphic, bail out otherwise.
71
+ ensure_monomorphic_enough ( * self . tcx , src. layout . ty ) ?;
72
+
70
73
// The src operand does not matter, just its type
71
74
match * src. layout . ty . kind ( ) {
72
75
ty:: FnDef ( def_id, substs) => {
73
- // All reifications must be monomorphic, bail out otherwise.
74
- ensure_monomorphic_enough ( * self . tcx , src. layout . ty ) ?;
75
-
76
76
let instance = ty:: Instance :: resolve_for_fn_ptr (
77
77
* self . tcx ,
78
78
self . param_env ,
@@ -100,12 +100,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
100
100
}
101
101
102
102
Pointer ( PointerCast :: ClosureFnPointer ( _) ) => {
103
+ // All reifications must be monomorphic, bail out otherwise.
104
+ ensure_monomorphic_enough ( * self . tcx , src. layout . ty ) ?;
105
+
103
106
// The src operand does not matter, just its type
104
107
match * src. layout . ty . kind ( ) {
105
108
ty:: Closure ( def_id, substs) => {
106
- // All reifications must be monomorphic, bail out otherwise.
107
- ensure_monomorphic_enough ( * self . tcx , src. layout . ty ) ?;
108
-
109
109
let instance = ty:: Instance :: resolve_closure (
110
110
* self . tcx ,
111
111
def_id,
@@ -359,8 +359,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
359
359
let val = Immediate :: new_dyn_trait ( ptr, vtable, & * self . tcx ) ;
360
360
self . write_immediate ( val, dest)
361
361
}
362
-
363
362
_ => {
363
+ // Do not ICE if we are not monomorphic enough.
364
+ ensure_monomorphic_enough ( * self . tcx , src. layout . ty ) ?;
365
+ ensure_monomorphic_enough ( * self . tcx , cast_ty) ?;
366
+
364
367
span_bug ! (
365
368
self . cur_span( ) ,
366
369
"invalid pointer unsizing {:?} -> {:?}" ,
@@ -404,12 +407,18 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
404
407
}
405
408
Ok ( ( ) )
406
409
}
407
- _ => span_bug ! (
408
- self . cur_span( ) ,
409
- "unsize_into: invalid conversion: {:?} -> {:?}" ,
410
- src. layout,
411
- dest. layout
412
- ) ,
410
+ _ => {
411
+ // Do not ICE if we are not monomorphic enough.
412
+ ensure_monomorphic_enough ( * self . tcx , src. layout . ty ) ?;
413
+ ensure_monomorphic_enough ( * self . tcx , cast_ty. ty ) ?;
414
+
415
+ span_bug ! (
416
+ self . cur_span( ) ,
417
+ "unsize_into: invalid conversion: {:?} -> {:?}" ,
418
+ src. layout,
419
+ dest. layout
420
+ )
421
+ }
413
422
}
414
423
}
415
424
}
0 commit comments