mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Merge #7080
7080: Implement ConstParams for HIR r=Veykril a=Veykril r? @flodiebold Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
0e5fe47153
28 changed files with 238 additions and 41 deletions
|
@ -6,8 +6,8 @@
|
|||
// FIXME: this badly needs rename/rewrite (matklad, 2020-02-06).
|
||||
|
||||
use hir::{
|
||||
db::HirDatabase, Crate, Field, HasVisibility, Impl, Label, LifetimeParam, Local, MacroDef,
|
||||
Module, ModuleDef, Name, PathResolution, Semantics, TypeParam, Visibility,
|
||||
db::HirDatabase, ConstParam, Crate, Field, HasVisibility, Impl, Label, LifetimeParam, Local,
|
||||
MacroDef, Module, ModuleDef, Name, PathResolution, Semantics, TypeParam, Visibility,
|
||||
};
|
||||
use syntax::{
|
||||
ast::{self, AstNode},
|
||||
|
@ -26,6 +26,7 @@ pub enum Definition {
|
|||
Local(Local),
|
||||
TypeParam(TypeParam),
|
||||
LifetimeParam(LifetimeParam),
|
||||
ConstParam(ConstParam),
|
||||
Label(Label),
|
||||
}
|
||||
|
||||
|
@ -39,6 +40,7 @@ impl Definition {
|
|||
Definition::Local(it) => Some(it.module(db)),
|
||||
Definition::TypeParam(it) => Some(it.module(db)),
|
||||
Definition::LifetimeParam(it) => Some(it.module(db)),
|
||||
Definition::ConstParam(it) => Some(it.module(db)),
|
||||
Definition::Label(it) => Some(it.module(db)),
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +54,7 @@ impl Definition {
|
|||
Definition::Local(_) => None,
|
||||
Definition::TypeParam(_) => None,
|
||||
Definition::LifetimeParam(_) => None,
|
||||
Definition::ConstParam(_) => None,
|
||||
Definition::Label(_) => None,
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +82,7 @@ impl Definition {
|
|||
Definition::Local(it) => it.name(db)?,
|
||||
Definition::TypeParam(it) => it.name(db),
|
||||
Definition::LifetimeParam(it) => it.name(db),
|
||||
Definition::ConstParam(it) => it.name(db),
|
||||
Definition::Label(it) => it.name(db),
|
||||
};
|
||||
Some(name)
|
||||
|
@ -233,6 +237,10 @@ impl NameClass {
|
|||
let def = sema.to_def(&it)?;
|
||||
Some(NameClass::Definition(Definition::TypeParam(def)))
|
||||
},
|
||||
ast::ConstParam(it) => {
|
||||
let def = sema.to_def(&it)?;
|
||||
Some(NameClass::Definition(Definition::ConstParam(def)))
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -417,6 +425,7 @@ impl From<PathResolution> for Definition {
|
|||
PathResolution::TypeParam(par) => Definition::TypeParam(par),
|
||||
PathResolution::Macro(def) => Definition::Macro(def),
|
||||
PathResolution::SelfType(impl_def) => Definition::SelfType(impl_def),
|
||||
PathResolution::ConstParam(par) => Definition::ConstParam(par),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue