diff options
| author | Michael Goulet <michael@errs.io> | 2024-10-23 16:53:59 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-10-24 09:46:36 +0000 |
| commit | 0f5a47d0884d9d3966f0f4a54e9e9a02cb5f482d (patch) | |
| tree | 07b3c259ec56fdea10eaef6f718114c04c1fd586 /compiler/rustc_ty_utils/src/ty.rs | |
| parent | 25c9253379fa89ae2b45bb6359ef4243ee77345b (diff) | |
| download | rust-0f5a47d0884d9d3966f0f4a54e9e9a02cb5f482d.tar.gz rust-0f5a47d0884d9d3966f0f4a54e9e9a02cb5f482d.zip | |
Be better at enforcing that const_conditions is only called on const items
Diffstat (limited to 'compiler/rustc_ty_utils/src/ty.rs')
| -rw-r--r-- | compiler/rustc_ty_utils/src/ty.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index ac2708a29f4..aa499995bcb 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -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(); |
