Do not ICE when casting polymorphic values.
This commit is contained in:
parent
5d7234abb6
commit
858eab6391
1 changed files with 22 additions and 13 deletions
|
@ -67,12 +67,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Pointer(PointerCast::ReifyFnPointer) => {
|
Pointer(PointerCast::ReifyFnPointer) => {
|
||||||
// The src operand does not matter, just its type
|
|
||||||
match *src.layout.ty.kind() {
|
|
||||||
ty::FnDef(def_id, substs) => {
|
|
||||||
// All reifications must be monomorphic, bail out otherwise.
|
// All reifications must be monomorphic, bail out otherwise.
|
||||||
ensure_monomorphic_enough(*self.tcx, src.layout.ty)?;
|
ensure_monomorphic_enough(*self.tcx, src.layout.ty)?;
|
||||||
|
|
||||||
|
// The src operand does not matter, just its type
|
||||||
|
match *src.layout.ty.kind() {
|
||||||
|
ty::FnDef(def_id, substs) => {
|
||||||
let instance = ty::Instance::resolve_for_fn_ptr(
|
let instance = ty::Instance::resolve_for_fn_ptr(
|
||||||
*self.tcx,
|
*self.tcx,
|
||||||
self.param_env,
|
self.param_env,
|
||||||
|
@ -100,12 +100,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Pointer(PointerCast::ClosureFnPointer(_)) => {
|
Pointer(PointerCast::ClosureFnPointer(_)) => {
|
||||||
// The src operand does not matter, just its type
|
|
||||||
match *src.layout.ty.kind() {
|
|
||||||
ty::Closure(def_id, substs) => {
|
|
||||||
// All reifications must be monomorphic, bail out otherwise.
|
// All reifications must be monomorphic, bail out otherwise.
|
||||||
ensure_monomorphic_enough(*self.tcx, src.layout.ty)?;
|
ensure_monomorphic_enough(*self.tcx, src.layout.ty)?;
|
||||||
|
|
||||||
|
// The src operand does not matter, just its type
|
||||||
|
match *src.layout.ty.kind() {
|
||||||
|
ty::Closure(def_id, substs) => {
|
||||||
let instance = ty::Instance::resolve_closure(
|
let instance = ty::Instance::resolve_closure(
|
||||||
*self.tcx,
|
*self.tcx,
|
||||||
def_id,
|
def_id,
|
||||||
|
@ -359,8 +359,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
let val = Immediate::new_dyn_trait(ptr, vtable, &*self.tcx);
|
let val = Immediate::new_dyn_trait(ptr, vtable, &*self.tcx);
|
||||||
self.write_immediate(val, dest)
|
self.write_immediate(val, dest)
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
|
// Do not ICE if we are not monomorphic enough.
|
||||||
|
ensure_monomorphic_enough(*self.tcx, src.layout.ty)?;
|
||||||
|
ensure_monomorphic_enough(*self.tcx, cast_ty)?;
|
||||||
|
|
||||||
span_bug!(
|
span_bug!(
|
||||||
self.cur_span(),
|
self.cur_span(),
|
||||||
"invalid pointer unsizing {:?} -> {:?}",
|
"invalid pointer unsizing {:?} -> {:?}",
|
||||||
|
@ -404,12 +407,18 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => span_bug!(
|
_ => {
|
||||||
|
// Do not ICE if we are not monomorphic enough.
|
||||||
|
ensure_monomorphic_enough(*self.tcx, src.layout.ty)?;
|
||||||
|
ensure_monomorphic_enough(*self.tcx, cast_ty.ty)?;
|
||||||
|
|
||||||
|
span_bug!(
|
||||||
self.cur_span(),
|
self.cur_span(),
|
||||||
"unsize_into: invalid conversion: {:?} -> {:?}",
|
"unsize_into: invalid conversion: {:?} -> {:?}",
|
||||||
src.layout,
|
src.layout,
|
||||||
dest.layout
|
dest.layout
|
||||||
),
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue