mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Implement beginnings of generics
- add HIR for generic params - resolve generic params in type paths - add substitions for ADTs - insert type variables for substitutions
This commit is contained in:
parent
415cdc5210
commit
688a45e00b
13 changed files with 288 additions and 82 deletions
|
@ -12,6 +12,7 @@ use crate::{
|
|||
expr::BodySyntaxMapping,
|
||||
ty::InferenceResult,
|
||||
adt::VariantData,
|
||||
generics::Generics,
|
||||
code_model_impl::def_id_to_ast,
|
||||
};
|
||||
|
||||
|
@ -201,6 +202,10 @@ impl Struct {
|
|||
pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::StructDef>) {
|
||||
def_id_to_ast(db, self.def_id)
|
||||
}
|
||||
|
||||
pub fn generics(&self, db: &impl HirDatabase) -> Arc<Generics> {
|
||||
db.generics(self.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
@ -228,6 +233,10 @@ impl Enum {
|
|||
pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::EnumDef>) {
|
||||
def_id_to_ast(db, self.def_id)
|
||||
}
|
||||
|
||||
pub fn generics(&self, db: &impl HirDatabase) -> Arc<Generics> {
|
||||
db.generics(self.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
@ -339,6 +348,10 @@ impl Function {
|
|||
pub fn infer(&self, db: &impl HirDatabase) -> Arc<InferenceResult> {
|
||||
db.infer(self.def_id)
|
||||
}
|
||||
|
||||
pub fn generics(&self, db: &impl HirDatabase) -> Arc<Generics> {
|
||||
db.generics(self.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
@ -384,6 +397,10 @@ impl Trait {
|
|||
pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::TraitDef>) {
|
||||
def_id_to_ast(db, self.def_id)
|
||||
}
|
||||
|
||||
pub fn generics(&self, db: &impl HirDatabase) -> Arc<Generics> {
|
||||
db.generics(self.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
@ -399,4 +416,8 @@ impl Type {
|
|||
pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::TypeDef>) {
|
||||
def_id_to_ast(db, self.def_id)
|
||||
}
|
||||
|
||||
pub fn generics(&self, db: &impl HirDatabase) -> Arc<Generics> {
|
||||
db.generics(self.def_id)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue