1
- use rustc:: ty:: { self , Ty , TypeAndMut } ;
1
+ use rustc:: ty:: { self , Ty , TypeAndMut , TypeFoldable } ;
2
2
use rustc:: ty:: layout:: { self , TyLayout , Size } ;
3
3
use rustc:: ty:: adjustment:: { PointerCast } ;
4
4
use syntax:: ast:: FloatTy ;
@@ -36,6 +36,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
36
36
// The src operand does not matter, just its type
37
37
match src. layout . ty . sty {
38
38
ty:: FnDef ( def_id, substs) => {
39
+ // All reifications must be monomorphic, bail out otherwise.
40
+ if src. layout . ty . needs_subst ( ) {
41
+ throw_inval ! ( TooGeneric ) ;
42
+ }
43
+
39
44
if self . tcx . has_attr ( def_id, sym:: rustc_args_required_const) {
40
45
bug ! ( "reifying a fn ptr that requires const arguments" ) ;
41
46
}
@@ -62,6 +67,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
62
67
// The src operand does not matter, just its type
63
68
match src. layout . ty . sty {
64
69
ty:: Closure ( def_id, substs) => {
70
+ // All reifications must be monomorphic, bail out otherwise.
71
+ if src. layout . ty . needs_subst ( ) {
72
+ throw_inval ! ( TooGeneric ) ;
73
+ }
74
+
65
75
let instance = ty:: Instance :: resolve_closure (
66
76
* self . tcx ,
67
77
def_id,
0 commit comments