Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/resolver.rs')
-rw-r--r--crates/hir-def/src/resolver.rs27
1 files changed, 19 insertions, 8 deletions
diff --git a/crates/hir-def/src/resolver.rs b/crates/hir-def/src/resolver.rs
index d491042eab..26655e40ca 100644
--- a/crates/hir-def/src/resolver.rs
+++ b/crates/hir-def/src/resolver.rs
@@ -3,7 +3,7 @@ use std::{fmt, iter, mem};
use base_db::CrateId;
use hir_expand::{name::Name, MacroDefId};
-use intern::{sym, Interned};
+use intern::sym;
use itertools::Itertools as _;
use rustc_hash::FxHashSet;
use smallvec::{smallvec, SmallVec};
@@ -24,7 +24,7 @@ use crate::{
nameres::{DefMap, MacroSubNs},
path::{ModPath, Path, PathKind},
per_ns::PerNs,
- type_ref::LifetimeRef,
+ type_ref::{LifetimeRef, TypesMap},
visibility::{RawVisibility, Visibility},
AdtId, ConstId, ConstParamId, CrateRootModuleId, DefWithBodyId, EnumId, EnumVariantId,
ExternBlockId, ExternCrateId, FunctionId, FxIndexMap, GenericDefId, GenericParamId, HasModule,
@@ -76,7 +76,7 @@ enum Scope {
/// All the items and imported names of a module
BlockScope(ModuleItemMap),
/// Brings the generic parameters of an item into scope
- GenericParams { def: GenericDefId, params: Interned<GenericParams> },
+ GenericParams { def: GenericDefId, params: Arc<GenericParams> },
/// Brings `Self` in `impl` block into scope
ImplDefScope(ImplId),
/// Brings `Self` in enum, struct and union definitions into scope
@@ -167,7 +167,8 @@ impl Resolver {
path: &Path,
) -> Option<(TypeNs, Option<usize>, Option<ImportOrExternCrate>)> {
let path = match path {
- Path::Normal { mod_path, .. } => mod_path,
+ Path::BarePath(mod_path) => mod_path,
+ Path::Normal(it) => it.mod_path(),
Path::LangItem(l, seg) => {
let type_ns = match *l {
LangItemTarget::Union(it) => TypeNs::AdtId(it.into()),
@@ -265,7 +266,8 @@ impl Resolver {
mut hygiene_id: HygieneId,
) -> Option<ResolveValueResult> {
let path = match path {
- Path::Normal { mod_path, .. } => mod_path,
+ Path::BarePath(mod_path) => mod_path,
+ Path::Normal(it) => it.mod_path(),
Path::LangItem(l, None) => {
return Some(ResolveValueResult::ValueNs(
match *l {
@@ -620,13 +622,15 @@ impl Resolver {
pub fn where_predicates_in_scope(
&self,
- ) -> impl Iterator<Item = (&crate::generics::WherePredicate, &GenericDefId)> {
+ ) -> impl Iterator<Item = (&crate::generics::WherePredicate, (&GenericDefId, &TypesMap))> {
self.scopes()
.filter_map(|scope| match scope {
Scope::GenericParams { params, def } => Some((params, def)),
_ => None,
})
- .flat_map(|(params, def)| params.where_predicates().zip(iter::repeat(def)))
+ .flat_map(|(params, def)| {
+ params.where_predicates().zip(iter::repeat((def, &params.types_map)))
+ })
}
pub fn generic_def(&self) -> Option<GenericDefId> {
@@ -636,13 +640,20 @@ impl Resolver {
})
}
- pub fn generic_params(&self) -> Option<&Interned<GenericParams>> {
+ pub fn generic_params(&self) -> Option<&Arc<GenericParams>> {
self.scopes().find_map(|scope| match scope {
Scope::GenericParams { params, .. } => Some(params),
_ => None,
})
}
+ pub fn all_generic_params(&self) -> impl Iterator<Item = (&GenericParams, &GenericDefId)> {
+ self.scopes().filter_map(|scope| match scope {
+ Scope::GenericParams { params, def } => Some((&**params, def)),
+ _ => None,
+ })
+ }
+
pub fn body_owner(&self) -> Option<DefWithBodyId> {
self.scopes().find_map(|scope| match scope {
Scope::ExprScope(it) => Some(it.owner),