Skip to content

Commit 541dd2e

Browse files
committed
fix I::Interned<...> type error
1 parent c1ea62a commit 541dd2e

3 files changed

Lines changed: 27 additions & 17 deletions

File tree

compiler/rustc_middle/src/ty/context/impl_interner.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ use rustc_hir::def_id::{DefId, LocalDefId};
1212
use rustc_hir::lang_items::LangItem;
1313
use rustc_span::{DUMMY_SP, Span, Symbol};
1414
use rustc_type_ir::lang_items::{SolverAdtLangItem, SolverLangItem, SolverTraitLangItem};
15-
use rustc_type_ir::{CollectAndApply, Interner, TypeFoldable, elaborate, search_graph};
15+
use rustc_type_ir::{
16+
CollectAndApply, Interner, TypeFoldable, WithCachedTypeInfo, elaborate, search_graph,
17+
};
1618

1719
use crate::dep_graph::{DepKind, DepNodeIndex};
1820
use crate::infer::canonical::CanonicalVarKinds;
@@ -48,8 +50,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
4850
type ImplId = DefId;
4951
type UnevaluatedConstId = DefId;
5052
type Span = Span;
51-
type Interned<T: Copy + Clone + std::fmt::Debug + std::hash::Hash + Eq + PartialEq> =
52-
Interned<'tcx, T>;
53+
type InternedTyKindWithCachedInfo = Interned<'tcx, WithCachedTypeInfo<ty::TyKind<'tcx>>>;
5354
type VariantIdx = VariantIdx;
5455
type Discr = Discr<'tcx>;
5556
type ObligationCause = ObligationCause<'tcx>;

compiler/rustc_type_ir/src/interner.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use crate::lang_items::{SolverAdtLangItem, SolverLangItem, SolverTraitLangItem};
1414
use crate::relate::Relate;
1515
use crate::solve::{CanonicalInput, Certainty, ExternalConstraintsData, QueryResult, inspect};
1616
use crate::visit::{Flags, TypeVisitable};
17-
use crate::{self as ty, CanonicalParamEnvCacheEntry, Ty, search_graph};
17+
use crate::{
18+
self as ty, CanonicalParamEnvCacheEntry, Ty, TyKind, WithCachedTypeInfo, search_graph,
19+
};
1820

1921
#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "type_ir_interner")]
2022
pub trait Interner:
@@ -177,13 +179,20 @@ pub trait Interner:
177179
type Clause: Clause<Self>;
178180
type Clauses: Clauses<Self>;
179181

180-
type Interned<T: Copy + Clone + Debug + Hash + Eq + PartialEq>: Copy
182+
// type Interned<'a, T: Copy + Clone + Debug + Hash + Eq + PartialEq + 'a>: Copy
183+
// + Clone
184+
// + Debug
185+
// + Hash
186+
// + Eq
187+
// + PartialEq
188+
// + Deref<Target = T>;
189+
type InternedTyKindWithCachedInfo: Copy
181190
+ Clone
182191
+ Debug
183192
+ Hash
184193
+ Eq
185194
+ PartialEq
186-
+ Deref<Target = T>;
195+
+ Deref<Target = WithCachedTypeInfo<TyKind<Self>>>;
187196
type VariantIdx;
188197
type Discr: Debug + Copy + Clone;
189198
type ObligationCause: Debug + Clone;

compiler/rustc_type_ir/src/sty/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ use crate::{
2525
};
2626

2727
/// Use this rather than `TyKind`, whenever possible.
28-
#[derive_where(Copy; I: Interner, I::Interned<WithCachedTypeInfo<TyKind<I>>>: Copy)]
28+
#[derive_where(Copy; I: Interner, I::InternedTyKindWithCachedInfo: Copy)]
2929
#[derive_where(Clone, PartialEq, Eq, Hash; I: Interner)]
3030
#[rustc_diagnostic_item = "Ty"]
3131
#[rustc_pass_by_value]
32-
pub struct Ty<I: Interner>(pub I::Interned<WithCachedTypeInfo<TyKind<I>>>);
32+
pub struct Ty<I: Interner>(pub I::InternedTyKindWithCachedInfo);
3333

3434
impl<I: Interner> Ty<I> {
3535
#[inline]
36-
pub fn from_interned(interned: I::Interned<WithCachedTypeInfo<TyKind<I>>>) -> Self {
36+
pub fn from_interned(interned: I::InternedTyKindWithCachedInfo) -> Self {
3737
Ty(interned)
3838
}
3939

4040
#[inline]
41-
pub fn interned(self) -> I::Interned<WithCachedTypeInfo<TyKind<I>>> {
41+
pub fn interned(self) -> I::InternedTyKindWithCachedInfo {
4242
self.0
4343
}
4444
}
@@ -60,7 +60,7 @@ impl<CTX, I: Interner> HashStable<CTX> for Ty<I> {
6060

6161
impl<I: Interner> fmt::Debug for Ty<I>
6262
where
63-
I::Interned<WithCachedTypeInfo<TyKind<I>>>: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
63+
I::InternedTyKindWithCachedInfo: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
6464
{
6565
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6666
fmt::Debug::fmt(&(*self).kind(), f)
@@ -69,7 +69,7 @@ where
6969

7070
impl<I: Interner> IntoKind for Ty<I>
7171
where
72-
I::Interned<WithCachedTypeInfo<TyKind<I>>>: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
72+
I::InternedTyKindWithCachedInfo: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
7373
{
7474
type Kind = TyKind<I>;
7575

@@ -81,7 +81,7 @@ where
8181

8282
impl<I: Interner> Flags for Ty<I>
8383
where
84-
I::Interned<WithCachedTypeInfo<TyKind<I>>>: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
84+
I::InternedTyKindWithCachedInfo: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
8585
{
8686
#[inline]
8787
fn flags(&self) -> TypeFlags {
@@ -102,7 +102,7 @@ impl<I: Interner> TypeVisitable<I> for Ty<I> {
102102

103103
impl<I: Interner> TypeSuperVisitable<I> for Ty<I>
104104
where
105-
I::Interned<WithCachedTypeInfo<TyKind<I>>>: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
105+
I::InternedTyKindWithCachedInfo: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
106106
I::BoundExistentialPredicates: TypeVisitable<I>,
107107
I::Const: TypeVisitable<I>,
108108
I::ErrorGuaranteed: TypeVisitable<I>,
@@ -171,7 +171,7 @@ impl<I: Interner> TypeFoldable<I> for Ty<I> {
171171

172172
impl<I: Interner> TypeSuperFoldable<I> for Ty<I>
173173
where
174-
I::Interned<WithCachedTypeInfo<TyKind<I>>>: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
174+
I::InternedTyKindWithCachedInfo: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
175175
I::BoundExistentialPredicates: TypeFoldable<I>,
176176
I::Const: TypeFoldable<I>,
177177
I::GenericArgs: TypeFoldable<I>,
@@ -279,7 +279,7 @@ where
279279
I::Region: TypeFoldable<I> + TypeVisitable<I>,
280280
I::Term: From<Ty<I>>,
281281
I::Tys: TypeFoldable<I> + TypeVisitable<I>,
282-
I::Interned<WithCachedTypeInfo<TyKind<I>>>:
282+
I::InternedTyKindWithCachedInfo:
283283
Copy + Clone + Debug + Hash + Eq + Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
284284
{
285285
/// Avoid using this in favour of more specific `new_*` methods, where possible.
@@ -652,7 +652,7 @@ where
652652
// Methods to determine what flavour `Ty` is
653653
impl<I: Interner> Ty<I>
654654
where
655-
I::Interned<WithCachedTypeInfo<TyKind<I>>>: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
655+
I::InternedTyKindWithCachedInfo: Deref<Target = WithCachedTypeInfo<TyKind<I>>>,
656656
I::BoundExistentialPredicates: TypeVisitable<I>,
657657
I::Const: TypeVisitable<I>,
658658
I::ErrorGuaranteed: TypeVisitable<I>,

0 commit comments

Comments
 (0)