Skip to content

Commit f114acf

Browse files
committed
add unused NormalizesTo predicate
1 parent b4ba7c4 commit f114acf

File tree

26 files changed

+100
-41
lines changed

26 files changed

+100
-41
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15191519
ty::Clause::RegionOutlives(_) | ty::Clause::ConstArgHasType(..) => bug!(),
15201520
},
15211521
ty::PredicateKind::WellFormed(_)
1522+
| ty::PredicateKind::NormalizesTo(..)
15221523
| ty::PredicateKind::AliasRelate(..)
15231524
| ty::PredicateKind::ObjectSafe(_)
15241525
| ty::PredicateKind::ClosureKind(_, _, _)

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
@@ -541,6 +541,7 @@ fn trait_predicate_kind<'tcx>(
541541
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(_))
542542
| ty::PredicateKind::Clause(ty::Clause::Projection(_))
543543
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
544+
| ty::PredicateKind::NormalizesTo(..)
544545
| ty::PredicateKind::AliasRelate(..)
545546
| ty::PredicateKind::WellFormed(_)
546547
| ty::PredicateKind::Subtype(_)

compiler/rustc_hir_analysis/src/outlives/explicit.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,20 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
5656
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
5757
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
5858
| ty::PredicateKind::WellFormed(..)
59-
| ty::PredicateKind::AliasRelate(..)
60-
| ty::PredicateKind::ObjectSafe(..)
59+
| ty::PredicateKind::ConstEvaluatable(..) => (),
60+
ty::PredicateKind::ObjectSafe(_)
6161
| ty::PredicateKind::ClosureKind(..)
6262
| ty::PredicateKind::Subtype(..)
6363
| ty::PredicateKind::Coerce(..)
64-
| ty::PredicateKind::ConstEvaluatable(..)
6564
| ty::PredicateKind::ConstEquate(..)
6665
| ty::PredicateKind::Ambiguous
67-
| ty::PredicateKind::TypeWellFormedFromEnv(..) => (),
66+
| ty::PredicateKind::NormalizesTo(..)
67+
| ty::PredicateKind::AliasRelate(..)
68+
| ty::PredicateKind::TypeWellFormedFromEnv(..) => {
69+
bug!(
70+
"`explicit_predicates_of` should only deal with clauses: {predicate:?}"
71+
)
72+
}
6873
}
6974
}
7075

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
670670
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..))
671671
| ty::PredicateKind::WellFormed(..)
672672
| ty::PredicateKind::ObjectSafe(..)
673+
| ty::PredicateKind::NormalizesTo(..)
673674
| ty::PredicateKind::AliasRelate(..)
674675
| ty::PredicateKind::ConstEvaluatable(..)
675676
| ty::PredicateKind::ConstEquate(..)

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
845845
| ty::PredicateKind::ConstEvaluatable(..)
846846
| ty::PredicateKind::ConstEquate(..)
847847
| ty::PredicateKind::Ambiguous
848+
| ty::PredicateKind::NormalizesTo(..)
848849
| ty::PredicateKind::AliasRelate(..)
849850
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
850851
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub fn explicit_outlives_bounds<'tcx>(
2626
ty::PredicateKind::Clause(ty::Clause::Projection(..))
2727
| ty::PredicateKind::Clause(ty::Clause::Trait(..))
2828
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..))
29+
| ty::PredicateKind::NormalizesTo(..)
2930
| ty::PredicateKind::AliasRelate(..)
3031
| ty::PredicateKind::Coerce(..)
3132
| ty::PredicateKind::Subtype(..)

compiler/rustc_infer/src/traits/util.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,11 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
327327
.map(|predicate| elaboratable.child(predicate)),
328328
);
329329
}
330-
ty::PredicateKind::TypeWellFormedFromEnv(..) => {
331-
// Nothing to elaborate
332-
}
333-
ty::PredicateKind::Ambiguous => {}
334-
ty::PredicateKind::AliasRelate(..) => {
335-
// No
336-
}
337-
ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) => {
330+
ty::PredicateKind::TypeWellFormedFromEnv(..)
331+
| ty::PredicateKind::Ambiguous
332+
| ty::PredicateKind::NormalizesTo(..)
333+
| ty::PredicateKind::AliasRelate(..)
334+
| ty::PredicateKind::Clause(ty::Clause::ConstArgHasType(..)) => {
338335
// Nothing to elaborate
339336
}
340337
}

compiler/rustc_lint/src/builtin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,7 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
16081608
// Ignore projections, as they can only be global
16091609
// if the trait bound is global
16101610
Clause(Clause::Projection(..)) |
1611+
NormalizesTo(..) |
16111612
AliasRelate(..) |
16121613
// Ignore bounds that a user can't type
16131614
WellFormed(..) |

compiler/rustc_middle/src/ty/flags.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ impl FlagComputation {
288288
self.add_ty(ty);
289289
}
290290
ty::PredicateKind::Ambiguous => {}
291-
ty::PredicateKind::AliasRelate(t1, t2, _) => {
291+
ty::PredicateKind::NormalizesTo(ty::ProjectionPredicate { projection_ty, term }) => {
292+
self.add_alias_ty(projection_ty);
293+
self.add_term(term);
294+
}
295+
ty::PredicateKind::AliasRelate(t1, t2, _direction) => {
292296
self.add_term(t1);
293297
self.add_term(t2);
294298
}

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,14 @@ impl<'tcx> Predicate<'tcx> {
537537
pub fn allow_normalization(self) -> bool {
538538
match self.kind().skip_binder() {
539539
PredicateKind::WellFormed(_) => false,
540+
// Only used by the new solver where we should not
541+
// normalize any goals.
542+
PredicateKind::NormalizesTo(..) | PredicateKind::AliasRelate(..) => false,
540543
PredicateKind::Clause(Clause::Trait(_))
541544
| PredicateKind::Clause(Clause::RegionOutlives(_))
542545
| PredicateKind::Clause(Clause::TypeOutlives(_))
543546
| PredicateKind::Clause(Clause::Projection(_))
544547
| PredicateKind::Clause(Clause::ConstArgHasType(..))
545-
| PredicateKind::AliasRelate(..)
546548
| PredicateKind::ObjectSafe(_)
547549
| PredicateKind::ClosureKind(_, _, _)
548550
| PredicateKind::Subtype(_)
@@ -653,10 +655,19 @@ pub enum PredicateKind<'tcx> {
653655
/// Used for coherence to mark opaque types as possibly equal to each other but ambiguous.
654656
Ambiguous,
655657

658+
/// The alias normalizes to `term`. Unlike `Projection`, this always fails if the alias
659+
/// cannot be normalized in the current context.
660+
///
661+
/// `Projection(<T as Trait>::Assoc, ?x)` results in `?x == <T as Trait>::Assoc` while
662+
/// `NormalizesTo(<T as Trait>::Assoc, ?x)` results in `NoSolution`.
663+
///
664+
/// Only used in the new solver.
665+
NormalizesTo(ProjectionPredicate<'tcx>),
666+
656667
/// Separate from `Clause::Projection` which is used for normalization in new solver.
657668
/// This predicate requires two terms to be equal to eachother.
658669
///
659-
/// Only used for new solver
670+
/// Only used in the new solver.
660671
AliasRelate(Term<'tcx>, Term<'tcx>, AliasRelationDirection),
661672
}
662673

@@ -1320,6 +1331,7 @@ impl<'tcx> Predicate<'tcx> {
13201331
PredicateKind::Clause(Clause::Trait(t)) => Some(predicate.rebind(t)),
13211332
PredicateKind::Clause(Clause::Projection(..))
13221333
| PredicateKind::Clause(Clause::ConstArgHasType(..))
1334+
| PredicateKind::NormalizesTo(..)
13231335
| PredicateKind::AliasRelate(..)
13241336
| PredicateKind::Subtype(..)
13251337
| PredicateKind::Coerce(..)
@@ -1341,6 +1353,7 @@ impl<'tcx> Predicate<'tcx> {
13411353
PredicateKind::Clause(Clause::Projection(t)) => Some(predicate.rebind(t)),
13421354
PredicateKind::Clause(Clause::Trait(..))
13431355
| PredicateKind::Clause(Clause::ConstArgHasType(..))
1356+
| PredicateKind::NormalizesTo(..)
13441357
| PredicateKind::AliasRelate(..)
13451358
| PredicateKind::Subtype(..)
13461359
| PredicateKind::Coerce(..)
@@ -1363,6 +1376,7 @@ impl<'tcx> Predicate<'tcx> {
13631376
PredicateKind::Clause(Clause::Trait(..))
13641377
| PredicateKind::Clause(Clause::ConstArgHasType(..))
13651378
| PredicateKind::Clause(Clause::Projection(..))
1379+
| PredicateKind::NormalizesTo(..)
13661380
| PredicateKind::AliasRelate(..)
13671381
| PredicateKind::Subtype(..)
13681382
| PredicateKind::Coerce(..)

0 commit comments

Comments
 (0)