Skip to content

Commit f1f8dee

Browse files
authored
Rollup merge of #152396 - ShoyuVanilla:uplift-allow-normalize, r=lcnr
Uplift `Predicate::allow_normalization` to `rustc_type_ir` Found this FIXME comment while fixing a bug in rust-analyzer 😄 cc rust-lang/rust-analyzer#21611 r? types
2 parents 48e093f + 20f65fc commit f1f8dee

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

compiler/rustc_middle/src/ty/predicate.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ impl<'tcx> rustc_type_ir::inherent::Predicate<TyCtxt<'tcx>> for Predicate<'tcx>
4949
fn as_clause(self) -> Option<ty::Clause<'tcx>> {
5050
self.as_clause()
5151
}
52-
53-
fn allow_normalization(self) -> bool {
54-
self.allow_normalization()
55-
}
5652
}
5753

5854
impl<'tcx> rustc_type_ir::inherent::IntoKind for Predicate<'tcx> {
@@ -121,25 +117,7 @@ impl<'tcx> Predicate<'tcx> {
121117
/// unsoundly accept some programs. See #91068.
122118
#[inline]
123119
pub fn allow_normalization(self) -> bool {
124-
match self.kind().skip_binder() {
125-
PredicateKind::Clause(ClauseKind::WellFormed(_)) | PredicateKind::AliasRelate(..) => {
126-
false
127-
}
128-
PredicateKind::Clause(ClauseKind::Trait(_))
129-
| PredicateKind::Clause(ClauseKind::HostEffect(..))
130-
| PredicateKind::Clause(ClauseKind::RegionOutlives(_))
131-
| PredicateKind::Clause(ClauseKind::TypeOutlives(_))
132-
| PredicateKind::Clause(ClauseKind::Projection(_))
133-
| PredicateKind::Clause(ClauseKind::ConstArgHasType(..))
134-
| PredicateKind::Clause(ClauseKind::UnstableFeature(_))
135-
| PredicateKind::DynCompatible(_)
136-
| PredicateKind::Subtype(_)
137-
| PredicateKind::Coerce(_)
138-
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(_))
139-
| PredicateKind::ConstEquate(_, _)
140-
| PredicateKind::NormalizesTo(..)
141-
| PredicateKind::Ambiguous => true,
142-
}
120+
rustc_type_ir::inherent::Predicate::allow_normalization(self)
143121
}
144122
}
145123

compiler/rustc_type_ir/src/inherent.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::fold::{TypeFoldable, TypeSuperFoldable};
1313
use crate::relate::Relate;
1414
use crate::solve::{AdtDestructorKind, SizedTraitKind};
1515
use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable};
16-
use crate::{self as ty, CollectAndApply, Interner, UpcastFrom};
16+
use crate::{self as ty, ClauseKind, CollectAndApply, Interner, PredicateKind, UpcastFrom};
1717

1818
pub trait Ty<I: Interner<Ty = Self>>:
1919
Copy
@@ -478,8 +478,27 @@ pub trait Predicate<I: Interner<Predicate = Self>>:
478478
}
479479
}
480480

481-
// FIXME: Eventually uplift the impl out of rustc and make this defaulted.
482-
fn allow_normalization(self) -> bool;
481+
fn allow_normalization(self) -> bool {
482+
match self.kind().skip_binder() {
483+
PredicateKind::Clause(ClauseKind::WellFormed(_)) | PredicateKind::AliasRelate(..) => {
484+
false
485+
}
486+
PredicateKind::Clause(ClauseKind::Trait(_))
487+
| PredicateKind::Clause(ClauseKind::HostEffect(..))
488+
| PredicateKind::Clause(ClauseKind::RegionOutlives(_))
489+
| PredicateKind::Clause(ClauseKind::TypeOutlives(_))
490+
| PredicateKind::Clause(ClauseKind::Projection(_))
491+
| PredicateKind::Clause(ClauseKind::ConstArgHasType(..))
492+
| PredicateKind::Clause(ClauseKind::UnstableFeature(_))
493+
| PredicateKind::DynCompatible(_)
494+
| PredicateKind::Subtype(_)
495+
| PredicateKind::Coerce(_)
496+
| PredicateKind::Clause(ClauseKind::ConstEvaluatable(_))
497+
| PredicateKind::ConstEquate(_, _)
498+
| PredicateKind::NormalizesTo(..)
499+
| PredicateKind::Ambiguous => true,
500+
}
501+
}
483502
}
484503

485504
pub trait Clause<I: Interner<Clause = Self>>:

0 commit comments

Comments
 (0)