Skip to content

Commit

Permalink
Explain that ensure_monomorphic_enough omission is intentional
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiasko committed Jun 5, 2021
1 parent 894b42c commit 07a03b0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_mir/src/interpret/intrinsics.rs
Expand Up @@ -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(),
Expand All @@ -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(_, _)
Expand Down

0 comments on commit 07a03b0

Please sign in to comment.