Explain that ensure_monomorphic_enough omission is intentional

This commit is contained in:
Tomasz Miąsko 2021-06-05 00:00:00 +00:00
parent 894b42c861
commit 07a03b0a58

View file

@ -61,6 +61,7 @@ crate fn eval_nullary_intrinsic<'tcx>(
ConstValue::from_bool(tp_ty.needs_drop(tcx, param_env))
}
sym::min_align_of | sym::pref_align_of => {
// Correctly handles non-monomorphic calls, so there is no need for ensure_monomorphic_enough.
let layout = tcx.layout_of(param_env.and(tp_ty)).map_err(|e| err_inval!(Layout(e)))?;
let n = match name {
sym::pref_align_of => layout.align.pref.bytes(),
@ -74,6 +75,7 @@ crate fn eval_nullary_intrinsic<'tcx>(
ConstValue::from_u64(tcx.type_id_hash(tp_ty))
}
sym::variant_count => match tp_ty.kind() {
// Correctly handles non-monomorphic calls, so there is no need for ensure_monomorphic_enough.
ty::Adt(ref adt, _) => ConstValue::from_machine_usize(adt.variants.len() as u64, &tcx),
ty::Projection(_)
| ty::Opaque(_, _)