Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/next_solver/predicate.rs')
| -rw-r--r-- | crates/hir-ty/src/next_solver/predicate.rs | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/crates/hir-ty/src/next_solver/predicate.rs b/crates/hir-ty/src/next_solver/predicate.rs index 9dda9d06da..3438b755fb 100644 --- a/crates/hir-ty/src/next_solver/predicate.rs +++ b/crates/hir-ty/src/next_solver/predicate.rs @@ -2,21 +2,18 @@ use std::cmp::Ordering; -use intern::Interned; use macros::{TypeFoldable, TypeVisitable}; -use rustc_ast_ir::try_visit; use rustc_type_ir::{ self as ty, CollectAndApply, DebruijnIndex, EarlyBinder, FlagComputation, Flags, PredicatePolarity, TypeFlags, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, - TypeVisitable, Upcast, UpcastFrom, VisitorResult, WithCachedTypeInfo, + TypeVisitable, Upcast, UpcastFrom, WithCachedTypeInfo, elaborate::Elaboratable, error::{ExpectedFound, TypeError}, inherent::{IntoKind, SliceLike}, - relate::Relate, }; -use smallvec::{SmallVec, smallvec}; +use smallvec::SmallVec; -use crate::next_solver::TraitIdWrapper; +use crate::next_solver::{InternedWrapperNoDebug, TraitIdWrapper}; use super::{Binder, BoundVarKinds, DbInterner, Region, Ty, interned_vec_db}; @@ -56,11 +53,11 @@ fn stable_cmp_existential_predicate<'db>( // FIXME: this is actual unstable - see impl in predicate.rs in `rustc_middle` match (a, b) { (ExistentialPredicate::Trait(_), ExistentialPredicate::Trait(_)) => Ordering::Equal, - (ExistentialPredicate::Projection(a), ExistentialPredicate::Projection(b)) => { + (ExistentialPredicate::Projection(_a), ExistentialPredicate::Projection(_b)) => { // Should sort by def path hash Ordering::Equal } - (ExistentialPredicate::AutoTrait(a), ExistentialPredicate::AutoTrait(b)) => { + (ExistentialPredicate::AutoTrait(_a), ExistentialPredicate::AutoTrait(_b)) => { // Should sort by def path hash Ordering::Equal } @@ -174,9 +171,6 @@ impl<'db> rustc_type_ir::relate::Relate<DbInterner<'db>> for BoundExistentialPre } } -#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Clone)] -pub struct InternedWrapperNoDebug<T>(pub(crate) T); - #[salsa::interned(constructor = new_)] pub struct Predicate<'db> { #[returns(ref)] @@ -283,8 +277,6 @@ impl<'db> std::hash::Hash for InternedClausesWrapper<'db> { } } -type InternedClauses<'db> = Interned<InternedClausesWrapper<'db>>; - #[salsa::interned(constructor = new_)] pub struct Clauses<'db> { #[returns(ref)] @@ -647,6 +639,26 @@ impl<'db> UpcastFrom<DbInterner<'db>, ty::OutlivesPredicate<DbInterner<'db>, Reg PredicateKind::Clause(ClauseKind::RegionOutlives(from)).upcast(interner) } } +impl<'db> UpcastFrom<DbInterner<'db>, ty::OutlivesPredicate<DbInterner<'db>, Ty<'db>>> + for Clause<'db> +{ + fn upcast_from( + from: ty::OutlivesPredicate<DbInterner<'db>, Ty<'db>>, + interner: DbInterner<'db>, + ) -> Self { + Clause(from.upcast(interner)) + } +} +impl<'db> UpcastFrom<DbInterner<'db>, ty::OutlivesPredicate<DbInterner<'db>, Region<'db>>> + for Clause<'db> +{ + fn upcast_from( + from: ty::OutlivesPredicate<DbInterner<'db>, Region<'db>>, + interner: DbInterner<'db>, + ) -> Self { + Clause(from.upcast(interner)) + } +} impl<'db> UpcastFrom<DbInterner<'db>, PolyRegionOutlivesPredicate<'db>> for Predicate<'db> { fn upcast_from(from: PolyRegionOutlivesPredicate<'db>, tcx: DbInterner<'db>) -> Self { |