mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
extract_assist
is aware of the expression owner
This commit is contained in:
parent
9edaf0cad8
commit
29c4ae6f9a
2 changed files with 114 additions and 99 deletions
|
@ -1391,8 +1391,13 @@ impl Const {
|
|||
db.const_data(self.id).name.clone()
|
||||
}
|
||||
|
||||
pub fn type_ref(self, db: &dyn HirDatabase) -> TypeRef {
|
||||
db.const_data(self.id).type_ref.as_ref().clone()
|
||||
pub fn ty(self, db: &dyn HirDatabase) -> Type {
|
||||
let data = db.const_data(self.id);
|
||||
let resolver = self.id.resolver(db.upcast());
|
||||
let krate = self.id.lookup(db.upcast()).container.krate(db);
|
||||
let ctx = hir_ty::TyLoweringContext::new(db, &resolver);
|
||||
let ty = ctx.lower_ty(&data.type_ref);
|
||||
Type::new_with_resolver_inner(db, krate.id, &resolver, ty)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1421,6 +1426,15 @@ impl Static {
|
|||
pub fn is_mut(self, db: &dyn HirDatabase) -> bool {
|
||||
db.static_data(self.id).mutable
|
||||
}
|
||||
|
||||
pub fn ty(self, db: &dyn HirDatabase) -> Type {
|
||||
let data = db.static_data(self.id);
|
||||
let resolver = self.id.resolver(db.upcast());
|
||||
let krate = self.id.lookup(db.upcast()).container.krate();
|
||||
let ctx = hir_ty::TyLoweringContext::new(db, &resolver);
|
||||
let ty = ctx.lower_ty(&data.type_ref);
|
||||
Type::new_with_resolver_inner(db, krate, &resolver, ty)
|
||||
}
|
||||
}
|
||||
|
||||
impl HasVisibility for Static {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue