Skip to content

Commit 9f5cca1

Browse files
committed
implement InternedRegionKind for rust analyzer
1 parent 50d9003 commit 9f5cca1

5 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/tools/rust-analyzer/Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,7 @@ version = "0.0.0"
12151215
dependencies = [
12161216
"dashmap",
12171217
"hashbrown 0.14.5",
1218+
"ra-ap-rustc_type_ir",
12181219
"rayon",
12191220
"rustc-hash 2.1.1",
12201221
"triomphe",

src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ use crate::{
5353
use super::{
5454
Binder, BoundExistentialPredicates, BoundTy, BoundTyKind, Clause, ClauseKind, Clauses, Const,
5555
ErrorGuaranteed, ExprConst, ExternalConstraints, GenericArg, GenericArgs, ParamConst, ParamEnv,
56-
ParamTy, PlaceholderConst, PlaceholderTy, PredefinedOpaques, Predicate, SolverDefId, Term, Ty,
57-
TyKind, Tys, Valtree, ValueConst,
56+
ParamTy, PlaceholderConst, PlaceholderTy, PredefinedOpaques, Predicate, RegionKind,
57+
SolverDefId, Term, Ty, TyKind, Tys, Valtree, ValueConst,
5858
abi::Safety,
5959
fold::{BoundVarReplacer, BoundVarReplacerDelegate, FnMutDelegate},
6060
generics::{Generics, generics},
@@ -1098,6 +1098,7 @@ impl<'db> Interner for DbInterner<'db> {
10981098
type LateParamRegion = LateParamRegion;
10991099
type BoundRegion = BoundRegion;
11001100
type PlaceholderRegion = PlaceholderRegion;
1101+
type InternedRegionKind = InternedRef<'db, RegionKind<'db>>;
11011102

11021103
type RegionAssumptions = RegionAssumptions<'db>;
11031104

src/tools/rust-analyzer/crates/intern/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ rustc-hash.workspace = true
2020
triomphe.workspace = true
2121
rayon.workspace = true
2222

23+
ra-ap-rustc_type_ir.workspace = true
24+
2325
[lints]
2426
workspace = true
2527

src/tools/rust-analyzer/crates/intern/src/intern.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use std::{
3434
use dashmap::{DashMap, SharedValue};
3535
use hashbrown::raw::RawTable;
3636
use rustc_hash::FxBuildHasher;
37+
use rustc_type_ir::inherent::IntoKind;
3738
use triomphe::{Arc, ArcBorrow};
3839

3940
type InternMap<T> = DashMap<Arc<T>, (), FxBuildHasher>;
@@ -318,6 +319,14 @@ impl<T: Display> Display for InternedRef<'_, T> {
318319
}
319320
}
320321

322+
impl<T: Clone> IntoKind for InternedRef<'_, T> {
323+
type Kind = T;
324+
325+
fn kind(self) -> Self::Kind {
326+
self.arc.get().clone()
327+
}
328+
}
329+
321330
pub struct InternStorage<T: ?Sized> {
322331
map: OnceLock<InternMap<T>>,
323332
}

src/tools/rust-analyzer/crates/intern/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ mod intern;
77
mod intern_slice;
88
mod symbol;
99

10+
extern crate ra_ap_rustc_type_ir as rustc_type_ir;
11+
1012
pub use self::gc::{GarbageCollector, GcInternedSliceVisit, GcInternedVisit};
1113
pub use self::intern::{InternStorage, Internable, Interned, InternedRef, impl_internable};
1214
pub use self::intern_slice::{

0 commit comments

Comments
 (0)