Skip to content

Commit 3d39e77

Browse files
committed
hir_def: various cleanups
1 parent 7ed42a3 commit 3d39e77

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

crates/hir_def/src/data.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,10 @@ impl TypeAliasData {
123123
let loc = typ.lookup(db);
124124
let item_tree = loc.id.item_tree(db);
125125
let typ = &item_tree[loc.id.value];
126-
let type_ref = typ.type_ref.clone();
127126

128127
Arc::new(TypeAliasData {
129128
name: typ.name.clone(),
130-
type_ref: type_ref,
129+
type_ref: typ.type_ref.clone(),
131130
visibility: item_tree[typ.visibility].clone(),
132131
is_extern: typ.is_extern,
133132
bounds: typ.bounds.to_vec(),
@@ -203,13 +202,12 @@ impl ImplData {
203202
let item_tree = impl_loc.id.item_tree(db);
204203
let impl_def = &item_tree[impl_loc.id.value];
205204
let target_trait = impl_def.target_trait.clone();
205+
let self_ty = impl_def.self_ty.clone();
206206
let is_negative = impl_def.is_negative;
207207
let module_id = impl_loc.container;
208208
let container = AssocContainerId::ImplId(id);
209-
let file_id = impl_loc.id.file_id();
210-
let self_ty = impl_def.self_ty.clone();
209+
let mut expander = Expander::new(db, impl_loc.id.file_id(), module_id);
211210

212-
let mut expander = Expander::new(db, file_id, module_id);
213211
let items = collect_items(
214212
db,
215213
module_id,

crates/hir_def/src/item_tree.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ impl ItemTree {
104104
// items and expanded during block DefMap computation
105105
return Default::default();
106106
},
107-
ast::Type(_ty) => {
108-
// FIXME: This occurs because macros in type position are treated as inner
109-
// items and expanded during block DefMap computation
110-
return Default::default();
107+
ast::Type(ty) => {
108+
// Types can contain inner items. We return an empty item tree in this case, but
109+
// still need to collect inner items.
110+
ctx.lower_inner_items(ty.syntax())
111111
},
112112
ast::Expr(e) => {
113113
// Macros can expand to expressions. We return an empty item tree in this case, but

crates/hir_def/src/type_ref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! HIR for references to types. Paths in these are not yet resolved. They can
22
//! be directly created from an ast::TypeRef, without further queries.
33
4-
use hir_expand::{ast_id_map::FileAstId, name::Name, ExpandResult, InFile};
4+
use hir_expand::{name::Name, AstId, ExpandResult, InFile};
55
use syntax::ast;
66

77
use crate::{
@@ -91,7 +91,7 @@ pub enum TypeRef {
9191
// For
9292
ImplTrait(Vec<TypeBound>),
9393
DynTrait(Vec<TypeBound>),
94-
Macro(InFile<FileAstId<ast::MacroCall>>),
94+
Macro(AstId<ast::MacroCall>),
9595
Error,
9696
}
9797

0 commit comments

Comments
 (0)