mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Construct dyn* during const interp
This commit is contained in:
parent
12353c11ca
commit
12ec2f0e34
@ -907,7 +907,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
llargs.push(data_ptr);
|
||||
continue;
|
||||
}
|
||||
_ => span_bug!(span, "can't codegen a virtual call on {:?}", op),
|
||||
_ => span_bug!(span, "can't codegen a virtual call on {:#?}", op),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,18 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
}
|
||||
|
||||
DynStar => {
|
||||
unimplemented!()
|
||||
if let ty::Dynamic(data, _, ty::TraitObjectRepresentation::Sized) = cast_ty.kind() {
|
||||
// Initial cast from sized to dyn trait
|
||||
let vtable = self.get_vtable_ptr(src.layout.ty, data.principal())?;
|
||||
let ptr = self.read_immediate(src)?.to_scalar();
|
||||
// FIXME(dyn-star): This should not use new_dyn_trait, but
|
||||
// it does exactly the same thing (makes a scalar pair)...
|
||||
// so maybe we should just duplicate/rename the function.
|
||||
let val = Immediate::new_dyn_trait(ptr, vtable, &*self.tcx);
|
||||
self.write_immediate(val, dest)?;
|
||||
} else {
|
||||
bug!()
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -2545,15 +2545,9 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// dyn*
|
||||
// dyn* (both fields are usize-sized)
|
||||
ty::Dynamic(_, _, TraitObjectRepresentation::Sized) => {
|
||||
TyMaybeWithLayout::TyAndLayout(
|
||||
tcx.layout_of(
|
||||
ty::ParamEnv::reveal_all()
|
||||
.and(tcx.mk_tup([tcx.types.usize, tcx.types.usize].into_iter())),
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
TyMaybeWithLayout::Ty(tcx.types.usize)
|
||||
}
|
||||
|
||||
ty::Projection(_)
|
||||
|
@ -1,6 +1,6 @@
|
||||
// run-pass
|
||||
// ignore-test
|
||||
#![feature(async_fn_in_traits)]
|
||||
#![allow(unused)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user