Skip to content

Commit 76546e8

Browse files
committed
implement InternedRegionKind for rust analyzer
1 parent 50d9003 commit 76546e8

7 files changed

Lines changed: 20 additions & 4 deletions

File tree

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ use std::ops::{ControlFlow, Deref};
33

44
use hir::intravisit::{self, Visitor};
55
use rustc_abi::{ExternAbi, ScalableElt};
6+
use rustc_ast as ast;
67
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
78
use rustc_errors::codes::*;
89
use rustc_errors::{Applicability, ErrorGuaranteed, msg, pluralize, struct_span_code_err};
10+
use rustc_hir as hir;
911
use rustc_hir::attrs::{EiiDecl, EiiImpl, EiiImplResolution};
1012
use rustc_hir::def::{DefKind, Res};
1113
use rustc_hir::def_id::{DefId, LocalDefId};
@@ -38,7 +40,6 @@ use rustc_trait_selection::traits::{
3840
WellFormedLoc,
3941
};
4042
use tracing::{debug, instrument};
41-
use {rustc_ast as ast, rustc_hir as hir};
4243

4344
use super::compare_eii::{compare_eii_function_types, compare_eii_statics};
4445
use crate::autoderef::Autoderef;

compiler/rustc_type_ir/src/predicate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ where
5252
feature = "nightly",
5353
derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
5454
)]
55-
pub struct RegionEqPredicate<I: Interner>(pub I::Region, pub I::Region);
55+
pub struct RegionEqPredicate<I: Interner>(pub Region<I>, pub Region<I>);
5656

5757
impl<I: Interner> RegionEqPredicate<I> {
5858
/// Decompose `'a == 'b` into `['a: 'b, 'b: 'a]`

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)