Skip to content

Commit

Permalink
rustc_mir: disallow non-monomorphic vtables.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Aug 19, 2019
1 parent 4149964 commit ceabe0d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/librustc_mir/interpret/traits.rs
@@ -1,4 +1,4 @@
use rustc::ty::{self, Ty, Instance};
use rustc::ty::{self, Ty, Instance, TypeFoldable};
use rustc::ty::layout::{Size, Align, LayoutOf};
use rustc::mir::interpret::{Scalar, Pointer, InterpResult, PointerArithmetic,};

Expand All @@ -20,6 +20,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {

let (ty, poly_trait_ref) = self.tcx.erase_regions(&(ty, poly_trait_ref));

// All vtables must be monomorphic, bail out otherwise.
if ty.needs_subst() || poly_trait_ref.needs_subst() {
throw_inval!(TooGeneric);
}

if let Some(&vtable) = self.vtables.get(&(ty, poly_trait_ref)) {
// This means we guarantee that there are no duplicate vtables, we will
// always use the same vtable for the same (Type, Trait) combination.
Expand Down

0 comments on commit ceabe0d

Please sign in to comment.