summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_hir_analysis/src/bounds.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /compiler/rustc_hir_analysis/src/bounds.rs
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_hir_analysis/src/bounds.rs')
-rw-r--r--compiler/rustc_hir_analysis/src/bounds.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/bounds.rs b/compiler/rustc_hir_analysis/src/bounds.rs
index 1d9ae2b9c..b6688e0ce 100644
--- a/compiler/rustc_hir_analysis/src/bounds.rs
+++ b/compiler/rustc_hir_analysis/src/bounds.rs
@@ -44,6 +44,34 @@ impl<'tcx> Bounds<'tcx> {
span: Span,
polarity: ty::ImplPolarity,
) {
+ self.push_trait_bound_inner(tcx, trait_ref, span, polarity);
+
+ // push a non-const (`host = true`) version of the bound if it is `~const`.
+ if tcx.features().effects
+ && let Some(host_effect_idx) = tcx.generics_of(trait_ref.def_id()).host_effect_index
+ && trait_ref.skip_binder().args.const_at(host_effect_idx) != tcx.consts.true_
+ {
+ let generics = tcx.generics_of(trait_ref.def_id());
+ let Some(host_index) = generics.host_effect_index else { return };
+ let trait_ref = trait_ref.map_bound(|mut trait_ref| {
+ trait_ref.args =
+ tcx.mk_args_from_iter(trait_ref.args.iter().enumerate().map(|(n, arg)| {
+ if host_index == n { tcx.consts.true_.into() } else { arg }
+ }));
+ trait_ref
+ });
+
+ self.push_trait_bound_inner(tcx, trait_ref, span, polarity);
+ }
+ }
+
+ fn push_trait_bound_inner(
+ &mut self,
+ tcx: TyCtxt<'tcx>,
+ trait_ref: ty::PolyTraitRef<'tcx>,
+ span: Span,
+ polarity: ty::ImplPolarity,
+ ) {
self.clauses.push((
trait_ref
.map_bound(|trait_ref| {