summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_hir_analysis/src/bounds.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /compiler/rustc_hir_analysis/src/bounds.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+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.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/compiler/rustc_hir_analysis/src/bounds.rs b/compiler/rustc_hir_analysis/src/bounds.rs
index 686066abb..531100e1f 100644
--- a/compiler/rustc_hir_analysis/src/bounds.rs
+++ b/compiler/rustc_hir_analysis/src/bounds.rs
@@ -23,7 +23,7 @@ use rustc_span::Span;
/// include the self type (e.g., `trait_bounds`) but in others we do not
#[derive(Default, PartialEq, Eq, Clone, Debug)]
pub struct Bounds<'tcx> {
- pub predicates: Vec<(ty::Predicate<'tcx>, Span)>,
+ pub clauses: Vec<(ty::Clause<'tcx>, Span)>,
}
impl<'tcx> Bounds<'tcx> {
@@ -33,7 +33,8 @@ impl<'tcx> Bounds<'tcx> {
region: ty::PolyTypeOutlivesPredicate<'tcx>,
span: Span,
) {
- self.predicates.push((region.to_predicate(tcx), span));
+ self.clauses
+ .push((region.map_bound(|p| ty::ClauseKind::TypeOutlives(p)).to_predicate(tcx), span));
}
pub fn push_trait_bound(
@@ -44,9 +45,11 @@ impl<'tcx> Bounds<'tcx> {
constness: ty::BoundConstness,
polarity: ty::ImplPolarity,
) {
- self.predicates.push((
+ self.clauses.push((
trait_ref
- .map_bound(|trait_ref| ty::TraitPredicate { trait_ref, constness, polarity })
+ .map_bound(|trait_ref| {
+ ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, constness, polarity })
+ })
.to_predicate(tcx),
span,
));
@@ -58,17 +61,20 @@ impl<'tcx> Bounds<'tcx> {
projection: ty::PolyProjectionPredicate<'tcx>,
span: Span,
) {
- self.predicates.push((projection.to_predicate(tcx), span));
+ self.clauses.push((
+ projection.map_bound(|proj| ty::ClauseKind::Projection(proj)).to_predicate(tcx),
+ span,
+ ));
}
pub fn push_sized(&mut self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) {
let sized_def_id = tcx.require_lang_item(LangItem::Sized, Some(span));
let trait_ref = ty::TraitRef::new(tcx, sized_def_id, [ty]);
// Preferable to put this obligation first, since we report better errors for sized ambiguity.
- self.predicates.insert(0, (trait_ref.without_const().to_predicate(tcx), span));
+ self.clauses.insert(0, (trait_ref.to_predicate(tcx), span));
}
- pub fn predicates(&self) -> impl Iterator<Item = (ty::Predicate<'tcx>, Span)> + '_ {
- self.predicates.iter().cloned()
+ pub fn clauses(&self) -> impl Iterator<Item = (ty::Clause<'tcx>, Span)> + '_ {
+ self.clauses.iter().cloned()
}
}