mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-05 05:04:24 +00:00
rustc_mir: disallow non-monomorphic vtables.
This commit is contained in:
parent
4149964ae4
commit
ceabe0dc54
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user