mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Introduce hir::GenericParam
Unlike existing hir::GenericParams, this is a global ID.
This commit is contained in:
parent
ff609cc497
commit
c5a18c44e5
@ -23,7 +23,7 @@ use crate::{
|
||||
adt::VariantDef,
|
||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||
expr::{validation::ExprValidator, BindingAnnotation, Body, BodySourceMap, Pat, PatId},
|
||||
generics::HasGenericParams,
|
||||
generics::{GenericDef, HasGenericParams},
|
||||
ids::{
|
||||
AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId,
|
||||
TypeAliasId,
|
||||
@ -1121,3 +1121,9 @@ impl Local {
|
||||
src.map(|ast| ast.map(|it| it.cast().unwrap().to_node(&root), |it| it.to_node(&root)))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct GenericParam {
|
||||
pub(crate) parent: GenericDef,
|
||||
pub(crate) idx: u32,
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ pub use crate::{
|
||||
docs::{DocDef, Docs, Documentation},
|
||||
src::{HasBodySource, HasSource},
|
||||
Adt, AssocItem, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum,
|
||||
EnumVariant, FieldSource, FnData, Function, HasBody, Local, MacroDef, Module, ModuleDef,
|
||||
ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||
EnumVariant, FieldSource, FnData, Function, GenericParam, HasBody, Local, MacroDef, Module,
|
||||
ModuleDef, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||
},
|
||||
expr::ExprScopes,
|
||||
from_source::FromSource,
|
||||
|
@ -28,8 +28,8 @@ use crate::{
|
||||
ids::LocationCtx,
|
||||
resolve::{ScopeDef, TypeNs, ValueNs},
|
||||
ty::method_resolution::{self, implements_trait},
|
||||
AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, HasBody, HirFileId, Local,
|
||||
MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty,
|
||||
AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, GenericParam, HasBody,
|
||||
HirFileId, Local, MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty,
|
||||
};
|
||||
|
||||
fn try_get_resolver_for_node(
|
||||
@ -107,7 +107,7 @@ pub enum PathResolution {
|
||||
/// A local binding (only value namespace)
|
||||
Local(Local),
|
||||
/// A generic parameter
|
||||
GenericParam(u32),
|
||||
GenericParam(GenericParam),
|
||||
SelfType(crate::ImplBlock),
|
||||
Macro(MacroDef),
|
||||
AssocItem(crate::AssocItem),
|
||||
@ -227,7 +227,10 @@ impl SourceAnalyzer {
|
||||
) -> Option<PathResolution> {
|
||||
let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty {
|
||||
TypeNs::SelfType(it) => PathResolution::SelfType(it),
|
||||
TypeNs::GenericParam(it) => PathResolution::GenericParam(it),
|
||||
TypeNs::GenericParam(idx) => PathResolution::GenericParam(GenericParam {
|
||||
parent: self.resolver.generic_def().unwrap(),
|
||||
idx,
|
||||
}),
|
||||
TypeNs::AdtSelfType(it) | TypeNs::Adt(it) => PathResolution::Def(it.into()),
|
||||
TypeNs::EnumVariant(it) => PathResolution::Def(it.into()),
|
||||
TypeNs::TypeAlias(it) => PathResolution::Def(it.into()),
|
||||
|
@ -4,7 +4,8 @@
|
||||
//! Note that the reference search is possible for not all of the classified items.
|
||||
|
||||
use hir::{
|
||||
Adt, AssocItem, HasSource, Local, MacroDef, Module, ModuleDef, StructField, Ty, VariantDef,
|
||||
Adt, AssocItem, GenericParam, HasSource, Local, MacroDef, Module, ModuleDef, StructField, Ty,
|
||||
VariantDef,
|
||||
};
|
||||
use ra_syntax::{ast, ast::VisibilityOwner};
|
||||
|
||||
@ -18,7 +19,7 @@ pub enum NameKind {
|
||||
Def(ModuleDef),
|
||||
SelfType(Ty),
|
||||
Local(Local),
|
||||
GenericParam(u32),
|
||||
GenericParam(GenericParam),
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
|
Loading…
Reference in New Issue
Block a user