Skip to content

Commit ceabe0d

Browse files
committed
rustc_mir: disallow non-monomorphic vtables.
1 parent 4149964 commit ceabe0d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/librustc_mir/interpret/traits.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc::ty::{self, Ty, Instance};
1+
use rustc::ty::{self, Ty, Instance, TypeFoldable};
22
use rustc::ty::layout::{Size, Align, LayoutOf};
33
use rustc::mir::interpret::{Scalar, Pointer, InterpResult, PointerArithmetic,};
44

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

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

23+
// All vtables must be monomorphic, bail out otherwise.
24+
if ty.needs_subst() || poly_trait_ref.needs_subst() {
25+
throw_inval!(TooGeneric);
26+
}
27+
2328
if let Some(&vtable) = self.vtables.get(&(ty, poly_trait_ref)) {
2429
// This means we guarantee that there are no duplicate vtables, we will
2530
// always use the same vtable for the same (Type, Trait) combination.

0 commit comments

Comments
 (0)