Skip to content

Commit 23ab246

Browse files
committed
add AliasEq to PredicateKind
1 parent 9b8dbd5 commit 23ab246

File tree

25 files changed

+80
-5
lines changed

25 files changed

+80
-5
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
13281328
ty::Clause::RegionOutlives(_) => bug!(),
13291329
},
13301330
ty::PredicateKind::WellFormed(_)
1331+
| ty::PredicateKind::AliasEq(..)
13311332
| ty::PredicateKind::ObjectSafe(_)
13321333
| ty::PredicateKind::ClosureKind(_, _, _)
13331334
| ty::PredicateKind::Subtype(_)

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ fn trait_predicate_kind<'tcx>(
517517
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(_))
518518
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_))
519519
| ty::PredicateKind::Clause(ty::Clause::Projection(_))
520+
| ty::PredicateKind::AliasEq(..)
520521
| ty::PredicateKind::WellFormed(_)
521522
| ty::PredicateKind::Subtype(_)
522523
| ty::PredicateKind::Coerce(_)

compiler/rustc_hir_analysis/src/outlives/explicit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
5555
ty::PredicateKind::Clause(ty::Clause::Trait(..))
5656
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
5757
| ty::PredicateKind::WellFormed(..)
58+
| ty::PredicateKind::AliasEq(..)
5859
| ty::PredicateKind::ObjectSafe(..)
5960
| ty::PredicateKind::ClosureKind(..)
6061
| ty::PredicateKind::Subtype(..)

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
669669
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
670670
| ty::PredicateKind::WellFormed(..)
671671
| ty::PredicateKind::ObjectSafe(..)
672+
| ty::PredicateKind::AliasEq(..)
672673
| ty::PredicateKind::ConstEvaluatable(..)
673674
| ty::PredicateKind::ConstEquate(..)
674675
// N.B., this predicate is created by breaking down a

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
837837
| ty::PredicateKind::ConstEvaluatable(..)
838838
| ty::PredicateKind::ConstEquate(..)
839839
| ty::PredicateKind::Ambiguous
840+
| ty::PredicateKind::AliasEq(..)
840841
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
841842
}
842843
});

compiler/rustc_infer/src/infer/outlives/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub fn explicit_outlives_bounds<'tcx>(
2121
.filter_map(move |kind| match kind {
2222
ty::PredicateKind::Clause(ty::Clause::Projection(..))
2323
| ty::PredicateKind::Clause(ty::Clause::Trait(..))
24+
| ty::PredicateKind::AliasEq(..)
2425
| ty::PredicateKind::Coerce(..)
2526
| ty::PredicateKind::Subtype(..)
2627
| ty::PredicateKind::WellFormed(..)

compiler/rustc_infer/src/traits/util.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ impl<'tcx> Elaborator<'tcx> {
294294
// Nothing to elaborate
295295
}
296296
ty::PredicateKind::Ambiguous => {}
297+
ty::PredicateKind::AliasEq(..) => {
298+
// No
299+
}
297300
}
298301
}
299302
}

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,12 +1594,14 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
15941594
// Ignore projections, as they can only be global
15951595
// if the trait bound is global
15961596
Clause(Clause::Projection(..)) |
1597+
AliasEq(..) |
15971598
// Ignore bounds that a user can't type
15981599
WellFormed(..) |
15991600
ObjectSafe(..) |
16001601
ClosureKind(..) |
16011602
Subtype(..) |
16021603
Coerce(..) |
1604+
// FIXME(generic_const_exprs): `ConstEvaluatable` can be written
16031605
ConstEvaluatable(..) |
16041606
ConstEquate(..) |
16051607
Ambiguous |

compiler/rustc_middle/src/ty/flags.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,7 @@ impl FlagComputation {
264264
term,
265265
})) => {
266266
self.add_projection_ty(projection_ty);
267-
match term.unpack() {
268-
ty::TermKind::Ty(ty) => self.add_ty(ty),
269-
ty::TermKind::Const(c) => self.add_const(c),
270-
}
267+
self.add_term(term);
271268
}
272269
ty::PredicateKind::WellFormed(arg) => {
273270
self.add_substs(slice::from_ref(&arg));
@@ -287,6 +284,10 @@ impl FlagComputation {
287284
self.add_ty(ty);
288285
}
289286
ty::PredicateKind::Ambiguous => {}
287+
ty::PredicateKind::AliasEq(t1, t2) => {
288+
self.add_term(t1);
289+
self.add_term(t2);
290+
}
290291
}
291292
}
292293

@@ -380,4 +381,11 @@ impl FlagComputation {
380381
}
381382
}
382383
}
384+
385+
fn add_term(&mut self, term: ty::Term<'_>) {
386+
match term.unpack() {
387+
ty::TermKind::Ty(ty) => self.add_ty(ty),
388+
ty::TermKind::Const(ct) => self.add_const(ct),
389+
}
390+
}
383391
}

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ impl<'tcx> Predicate<'tcx> {
545545
| PredicateKind::Clause(Clause::RegionOutlives(_))
546546
| PredicateKind::Clause(Clause::TypeOutlives(_))
547547
| PredicateKind::Clause(Clause::Projection(_))
548+
| PredicateKind::AliasEq(..)
548549
| PredicateKind::ObjectSafe(_)
549550
| PredicateKind::ClosureKind(_, _, _)
550551
| PredicateKind::Subtype(_)
@@ -632,6 +633,12 @@ pub enum PredicateKind<'tcx> {
632633
/// A marker predicate that is always ambiguous.
633634
/// Used for coherence to mark opaque types as possibly equal to each other but ambiguous.
634635
Ambiguous,
636+
637+
/// Separate from `Clause::Projection` which is used for normalization in new solver.
638+
/// This predicate requires two terms to be equal to eachother.
639+
///
640+
/// Only used for new solver
641+
AliasEq(Term<'tcx>, Term<'tcx>),
635642
}
636643

637644
/// The crate outlives map is computed during typeck and contains the
@@ -1152,6 +1159,7 @@ impl<'tcx> Predicate<'tcx> {
11521159
match predicate.skip_binder() {
11531160
PredicateKind::Clause(Clause::Trait(t)) => Some(predicate.rebind(t)),
11541161
PredicateKind::Clause(Clause::Projection(..))
1162+
| PredicateKind::AliasEq(..)
11551163
| PredicateKind::Subtype(..)
11561164
| PredicateKind::Coerce(..)
11571165
| PredicateKind::Clause(Clause::RegionOutlives(..))
@@ -1171,6 +1179,7 @@ impl<'tcx> Predicate<'tcx> {
11711179
match predicate.skip_binder() {
11721180
PredicateKind::Clause(Clause::Projection(t)) => Some(predicate.rebind(t)),
11731181
PredicateKind::Clause(Clause::Trait(..))
1182+
| PredicateKind::AliasEq(..)
11741183
| PredicateKind::Subtype(..)
11751184
| PredicateKind::Coerce(..)
11761185
| PredicateKind::Clause(Clause::RegionOutlives(..))
@@ -1191,6 +1200,7 @@ impl<'tcx> Predicate<'tcx> {
11911200
PredicateKind::Clause(Clause::TypeOutlives(data)) => Some(predicate.rebind(data)),
11921201
PredicateKind::Clause(Clause::Trait(..))
11931202
| PredicateKind::Clause(Clause::Projection(..))
1203+
| PredicateKind::AliasEq(..)
11941204
| PredicateKind::Subtype(..)
11951205
| PredicateKind::Coerce(..)
11961206
| PredicateKind::Clause(Clause::RegionOutlives(..))

0 commit comments

Comments
 (0)