1
Fork 0

Be better at enforcing that const_conditions is only called on const items

This commit is contained in:
Michael Goulet 2024-10-23 16:53:59 +00:00
parent 25c9253379
commit 0f5a47d088
12 changed files with 126 additions and 120 deletions

View file

@ -152,12 +152,13 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
// We extend the param-env of our item with the const conditions of the item,
// since we're allowed to assume `~const` bounds hold within the item itself.
predicates.extend(
tcx.const_conditions(def_id)
.instantiate_identity(tcx)
.into_iter()
.map(|(trait_ref, _)| trait_ref.to_host_effect_clause(tcx, ty::HostPolarity::Maybe)),
);
if tcx.is_conditionally_const(def_id) {
predicates.extend(
tcx.const_conditions(def_id).instantiate_identity(tcx).into_iter().map(
|(trait_ref, _)| trait_ref.to_host_effect_clause(tcx, ty::HostPolarity::Maybe),
),
);
}
let local_did = def_id.as_local();