Skip to content
Permalink
Browse files

rustc_mir: disallow non-monomorphic reifications.

  • Loading branch information...
eddyb committed Aug 12, 2019
1 parent ceabe0d commit 7d9af83ffcc1543deebb7b91725981314c7af8c2
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/librustc_mir/interpret/cast.rs
@@ -1,4 +1,4 @@
use rustc::ty::{self, Ty, TypeAndMut};
use rustc::ty::{self, Ty, TypeAndMut, TypeFoldable};
use rustc::ty::layout::{self, TyLayout, Size};
use rustc::ty::adjustment::{PointerCast};
use syntax::ast::FloatTy;
@@ -36,6 +36,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// The src operand does not matter, just its type
match src.layout.ty.sty {
ty::FnDef(def_id, substs) => {
// All reifications must be monomorphic, bail out otherwise.
if src.layout.ty.needs_subst() {
throw_inval!(TooGeneric);
}

if self.tcx.has_attr(def_id, sym::rustc_args_required_const) {
bug!("reifying a fn ptr that requires const arguments");
}
@@ -62,6 +67,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// The src operand does not matter, just its type
match src.layout.ty.sty {
ty::Closure(def_id, substs) => {
// All reifications must be monomorphic, bail out otherwise.
if src.layout.ty.needs_subst() {
throw_inval!(TooGeneric);
}

let instance = ty::Instance::resolve_closure(
*self.tcx,
def_id,

0 comments on commit 7d9af83

Please sign in to comment.
You can’t perform that action at this time.