Skip to content
Permalink
Browse files

rustc_mir: disallow non-monomorphic vtables.

  • Loading branch information...
eddyb committed Aug 12, 2019
1 parent 4149964 commit ceabe0dc54996a89eaa40a26df39527893988be5
Showing with 6 additions and 1 deletion.
  1. +6 −1 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,};

@@ -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.

0 comments on commit ceabe0d

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