1
Fork 0

Disallow non-monomorphic calls to needs_drop in interpreter

otherwise evaluation could change after further substitutions.
This commit is contained in:
Tomasz Miąsko 2021-06-04 00:00:00 +00:00
parent 5ea19239d9
commit 894b42c861
3 changed files with 41 additions and 1 deletions

View file

@ -56,7 +56,10 @@ crate fn eval_nullary_intrinsic<'tcx>(
let alloc = type_name::alloc_type_name(tcx, tp_ty);
ConstValue::Slice { data: alloc, start: 0, end: alloc.len() }
}
sym::needs_drop => ConstValue::from_bool(tp_ty.needs_drop(tcx, param_env)),
sym::needs_drop => {
ensure_monomorphic_enough(tcx, tp_ty)?;
ConstValue::from_bool(tp_ty.needs_drop(tcx, param_env))
}
sym::min_align_of | sym::pref_align_of => {
let layout = tcx.layout_of(param_env.and(tp_ty)).map_err(|e| err_inval!(Layout(e)))?;
let n = match name {