Skip to content

Commit 63ca855

Browse files
authored
Rollup merge of rust-lang#145009 - jackh726:ra-next-solver-changes, r=compiler-errors
A couple small changes for rust-analyzer next-solver work Originally written by `@flodiebold`
2 parents dad85cf + a8f6528 commit 63ca855

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

compiler/rustc_middle/src/ty/predicate.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use rustc_macros::{HashStable, extension};
66
use rustc_type_ir as ir;
77

88
use crate::ty::{
9-
self, DebruijnIndex, EarlyBinder, PredicatePolarity, Ty, TyCtxt, TypeFlags, Upcast, UpcastFrom,
10-
WithCachedTypeInfo,
9+
self, DebruijnIndex, EarlyBinder, Ty, TyCtxt, TypeFlags, Upcast, UpcastFrom, WithCachedTypeInfo,
1110
};
1211

1312
pub type TraitRef<'tcx> = ir::TraitRef<TyCtxt<'tcx>>;
@@ -536,15 +535,6 @@ impl<'tcx> UpcastFrom<TyCtxt<'tcx>, ty::Binder<'tcx, TraitRef<'tcx>>> for Clause
536535
}
537536
}
538537

539-
impl<'tcx> UpcastFrom<TyCtxt<'tcx>, ty::Binder<'tcx, TraitRef<'tcx>>> for PolyTraitPredicate<'tcx> {
540-
fn upcast_from(from: ty::Binder<'tcx, TraitRef<'tcx>>, _tcx: TyCtxt<'tcx>) -> Self {
541-
from.map_bound(|trait_ref| TraitPredicate {
542-
trait_ref,
543-
polarity: PredicatePolarity::Positive,
544-
})
545-
}
546-
}
547-
548538
impl<'tcx> UpcastFrom<TyCtxt<'tcx>, TraitPredicate<'tcx>> for Predicate<'tcx> {
549539
fn upcast_from(from: TraitPredicate<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
550540
PredicateKind::Clause(ClauseKind::Trait(from)).upcast(tcx)

compiler/rustc_type_ir/src/const_kind.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
77
use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
88
use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
99

10-
use crate::{self as ty, DebruijnIndex, Interner};
10+
use crate::{
11+
self as ty, DebruijnIndex, FallibleTypeFolder, Interner, TypeFoldable, TypeFolder,
12+
TypeVisitable, TypeVisitor, VisitorResult,
13+
};
1114

1215
/// Represents a constant in Rust.
1316
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
@@ -120,3 +123,19 @@ impl<CTX> HashStable<CTX> for InferConst {
120123
}
121124
}
122125
}
126+
127+
impl<I: Interner> TypeFoldable<I> for InferConst {
128+
fn try_fold_with<F: FallibleTypeFolder<I>>(self, _folder: &mut F) -> Result<Self, F::Error> {
129+
Ok(self)
130+
}
131+
132+
fn fold_with<F: TypeFolder<I>>(self, _folder: &mut F) -> Self {
133+
self
134+
}
135+
}
136+
137+
impl<I: Interner> TypeVisitable<I> for InferConst {
138+
fn visit_with<V: TypeVisitor<I>>(&self, _visitor: &mut V) -> V::Result {
139+
V::Result::output()
140+
}
141+
}

compiler/rustc_type_ir/src/predicate.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ impl<I: Interner> UpcastFrom<I, TraitRef<I>> for TraitPredicate<I> {
184184
}
185185
}
186186

187+
impl<I: Interner> UpcastFrom<I, ty::Binder<I, TraitRef<I>>> for ty::Binder<I, TraitPredicate<I>> {
188+
fn upcast_from(from: ty::Binder<I, TraitRef<I>>, _tcx: I) -> Self {
189+
from.map_bound(|trait_ref| TraitPredicate {
190+
trait_ref,
191+
polarity: PredicatePolarity::Positive,
192+
})
193+
}
194+
}
195+
187196
impl<I: Interner> fmt::Debug for TraitPredicate<I> {
188197
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
189198
write!(f, "TraitPredicate({:?}, polarity:{:?})", self.trait_ref, self.polarity)

0 commit comments

Comments
 (0)