1
Fork 0

treat host effect params as erased generics in codegen

This fixes the changes brought to codegen tests when effect params are
added to libcore, by not attempting to monomorphize functions that get
the host param by being `const fn`.
This commit is contained in:
Deadbeef 2023-09-13 13:55:23 +00:00
parent 7e0261e7ea
commit a0a801cd38
17 changed files with 71 additions and 41 deletions

View file

@ -459,7 +459,7 @@ fn collect_items_rec<'tcx>(
// Check for PMEs and emit a diagnostic if one happened. To try to show relevant edges of the
// mono item graph.
if tcx.sess.diagnostic().err_count() > error_count
&& starting_item.node.is_generic_fn()
&& starting_item.node.is_generic_fn(tcx)
&& starting_item.node.is_user_defined()
{
let formatted_item = with_no_trimmed_paths!(starting_item.node.to_string());
@ -1315,6 +1315,7 @@ fn create_mono_items_for_default_impls<'tcx>(
// it, to validate whether or not the impl is legal to instantiate at all.
let only_region_params = |param: &ty::GenericParamDef, _: &_| match param.kind {
GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(),
GenericParamDefKind::Const { is_host_effect: true, .. } => tcx.consts.true_.into(),
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => {
unreachable!(
"`own_requires_monomorphization` check means that \

View file

@ -221,7 +221,7 @@ where
}
let characteristic_def_id = characteristic_def_id_of_mono_item(cx.tcx, mono_item);
let is_volatile = is_incremental_build && mono_item.is_generic_fn();
let is_volatile = is_incremental_build && mono_item.is_generic_fn(cx.tcx);
let cgu_name = match characteristic_def_id {
Some(def_id) => compute_codegen_unit_name(
@ -801,7 +801,7 @@ fn mono_item_visibility<'tcx>(
return Visibility::Hidden;
}
let is_generic = instance.args.non_erasable_generics().next().is_some();
let is_generic = instance.args.non_erasable_generics(tcx, def_id).next().is_some();
// Upstream `DefId` instances get different handling than local ones.
let Some(def_id) = def_id.as_local() else {