From 8d96db3417fdabb1bad7a9919ea8ae1db25296f1 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 5 May 2020 00:17:22 +0800 Subject: Favor types for Record in name resolution --- crates/ra_hir_def/src/body/lower.rs | 15 +++++++++++---- crates/ra_hir_def/src/item_scope.rs | 11 +++++++++-- crates/ra_hir_def/src/nameres/collector.rs | 13 ++++++++++--- crates/ra_hir_def/src/nameres/raw.rs | 18 +++++++++++++++--- 4 files changed, 45 insertions(+), 12 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 687216dc3..49f5420d1 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -18,7 +18,7 @@ use ra_syntax::{ use test_utils::tested_by; use crate::{ - adt::StructKind, + adt::{self, StructKind}, body::{Body, BodySourceMap, Expander, PatPtr, SyntheticSyntax}, builtin_type::{BuiltinFloat, BuiltinInt}, db::DefDatabase, @@ -575,9 +575,16 @@ impl ExprCollector<'_> { self.body.item_scope.define_def(def); if let Some(name) = name { let vis = crate::visibility::Visibility::Public; // FIXME determine correctly - self.body - .item_scope - .push_res(name.as_name(), crate::per_ns::PerNs::from_def(def, vis)); + let favor_types = match def { + ModuleDefId::AdtId(AdtId::StructId(s)) => { + self.db.struct_data(s).variant_data.kind() == adt::StructKind::Record + } + _ => false, + }; + self.body.item_scope.push_res( + name.as_name(), + crate::per_ns::PerNs::from_def(def, vis, favor_types), + ); } } } diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index 259b9ff03..6d8d1f8a3 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs @@ -151,13 +151,20 @@ impl ItemScope { } impl PerNs { - pub(crate) fn from_def(def: ModuleDefId, v: Visibility) -> PerNs { + pub(crate) fn from_def(def: ModuleDefId, v: Visibility, favor_types: bool) -> PerNs { match def { ModuleDefId::ModuleId(_) => PerNs::types(def, v), ModuleDefId::FunctionId(_) => PerNs::values(def, v), ModuleDefId::AdtId(adt) => match adt { - AdtId::StructId(_) | AdtId::UnionId(_) => PerNs::both(def, def, v), + AdtId::UnionId(_) => PerNs::both(def, def, v), AdtId::EnumId(_) => PerNs::types(def, v), + AdtId::StructId(_) => { + if favor_types { + PerNs::types(def, v) + } else { + PerNs::both(def, def, v) + } + } }, ModuleDefId::EnumVariantId(_) => PerNs::both(def, def, v), ModuleDefId::ConstId(_) | ModuleDefId::StaticId(_) => PerNs::values(def, v), diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index bf3968bd6..49b33ca94 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -830,7 +830,7 @@ impl ModCollector<'_, '_> { let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: res }; let def: ModuleDefId = module.into(); self.def_collector.def_map.modules[self.module_id].scope.define_def(def); - self.def_collector.update(self.module_id, &[(name, PerNs::from_def(def, vis))], vis); + self.def_collector.update(self.module_id, &[(name, PerNs::from_def(def, vis, false))], vis); res } @@ -844,6 +844,8 @@ impl ModCollector<'_, '_> { let name = def.name.clone(); let container = ContainerId::ModuleId(module); let vis = &def.visibility; + let mut favor_types = false; + let def: ModuleDefId = match def.kind { raw::DefKind::Function(ast_id) => FunctionLoc { container: container.into(), @@ -851,7 +853,8 @@ impl ModCollector<'_, '_> { } .intern(self.def_collector.db) .into(), - raw::DefKind::Struct(ast_id) => { + raw::DefKind::Struct(ast_id, mode) => { + favor_types = mode == raw::StructDefKind::Record; StructLoc { container, ast_id: AstId::new(self.file_id, ast_id) } .intern(self.def_collector.db) .into() @@ -894,7 +897,11 @@ impl ModCollector<'_, '_> { .def_map .resolve_visibility(self.def_collector.db, self.module_id, vis) .unwrap_or(Visibility::Public); - self.def_collector.update(self.module_id, &[(name, PerNs::from_def(def, vis))], vis) + self.def_collector.update( + self.module_id, + &[(name, PerNs::from_def(def, vis, favor_types))], + vis, + ) } fn collect_derives(&mut self, attrs: &Attrs, def: &raw::DefData) { diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index a71503c76..f2716a295 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs @@ -155,10 +155,17 @@ pub(super) struct DefData { pub(super) visibility: RawVisibility, } +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub(super) enum StructDefKind { + Record, + Tuple, + Unit, +} + #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub(super) enum DefKind { Function(FileAstId), - Struct(FileAstId), + Struct(FileAstId, StructDefKind), Union(FileAstId), Enum(FileAstId), Const(FileAstId), @@ -171,7 +178,7 @@ impl DefKind { pub fn ast_id(&self) -> FileAstId { match self { DefKind::Function(it) => it.upcast(), - DefKind::Struct(it) => it.upcast(), + DefKind::Struct(it, _) => it.upcast(), DefKind::Union(it) => it.upcast(), DefKind::Enum(it) => it.upcast(), DefKind::Const(it) => it.upcast(), @@ -236,9 +243,14 @@ impl RawItemsCollector { return; } ast::ModuleItem::StructDef(it) => { + let kind = match it.kind() { + ast::StructKind::Record(_) => StructDefKind::Record, + ast::StructKind::Tuple(_) => StructDefKind::Tuple, + ast::StructKind::Unit => StructDefKind::Unit, + }; let id = self.source_ast_id_map.ast_id(&it); let name = it.name(); - (DefKind::Struct(id), name) + (DefKind::Struct(id, kind), name) } ast::ModuleItem::UnionDef(it) => { let id = self.source_ast_id_map.ast_id(&it); -- cgit v1.2.3 From af001677d103a3e0f5cf1bfde44982171faf34b9 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 5 May 2020 00:17:30 +0800 Subject: Fix test --- crates/ra_hir_def/src/nameres/tests/macros.rs | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/nameres/tests/macros.rs b/crates/ra_hir_def/src/nameres/tests/macros.rs index 9bc0e6287..40289e3ca 100644 --- a/crates/ra_hir_def/src/nameres/tests/macros.rs +++ b/crates/ra_hir_def/src/nameres/tests/macros.rs @@ -19,12 +19,12 @@ fn macro_rules_are_globally_visible() { ); assert_snapshot!(map, @r###" ⋮crate - ⋮Foo: t v + ⋮Foo: t ⋮nested: t ⋮ ⋮crate::nested - ⋮Bar: t v - ⋮Baz: t v + ⋮Bar: t + ⋮Baz: t "###); } @@ -91,13 +91,13 @@ fn macro_rules_from_other_crates_are_visible() { ); assert_snapshot!(map, @r###" ⋮crate - ⋮Bar: t v - ⋮Foo: t v + ⋮Bar: t + ⋮Foo: t ⋮bar: t ⋮ ⋮crate::bar - ⋮Bar: t v - ⋮Foo: t v + ⋮Bar: t + ⋮Foo: t ⋮bar: t "###); } @@ -124,13 +124,13 @@ fn macro_rules_export_with_local_inner_macros_are_visible() { ); assert_snapshot!(map, @r###" ⋮crate - ⋮Bar: t v - ⋮Foo: t v + ⋮Bar: t + ⋮Foo: t ⋮bar: t ⋮ ⋮crate::bar - ⋮Bar: t v - ⋮Foo: t v + ⋮Bar: t + ⋮Foo: t ⋮bar: t "###); } @@ -161,13 +161,13 @@ fn local_inner_macros_makes_local_macros_usable() { ); assert_snapshot!(map, @r###" ⋮crate - ⋮Bar: t v - ⋮Foo: t v + ⋮Bar: t + ⋮Foo: t ⋮bar: t ⋮ ⋮crate::bar - ⋮Bar: t v - ⋮Foo: t v + ⋮Bar: t + ⋮Foo: t ⋮bar: t "###); } @@ -204,7 +204,7 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() { ); assert_snapshot!(map, @r###" ⋮crate - ⋮Foo: t v + ⋮Foo: t ⋮bar: m ⋮foo: m "###); -- cgit v1.2.3 From 5ae18f4f814501ccd96a277c320e919159c91fac Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 5 May 2020 00:34:54 +0800 Subject: Remove unused import --- crates/ra_hir_def/src/body/lower.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 49f5420d1..ea0ddeebc 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -18,7 +18,7 @@ use ra_syntax::{ use test_utils::tested_by; use crate::{ - adt::{self, StructKind}, + adt::StructKind, body::{Body, BodySourceMap, Expander, PatPtr, SyntheticSyntax}, builtin_type::{BuiltinFloat, BuiltinInt}, db::DefDatabase, @@ -577,7 +577,7 @@ impl ExprCollector<'_> { let vis = crate::visibility::Visibility::Public; // FIXME determine correctly let favor_types = match def { ModuleDefId::AdtId(AdtId::StructId(s)) => { - self.db.struct_data(s).variant_data.kind() == adt::StructKind::Record + self.db.struct_data(s).variant_data.kind() == StructKind::Record } _ => false, }; -- cgit v1.2.3 From e921195d93c443b20a6fcb3cb1c5b8117fe2fa1b Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 5 May 2020 01:15:27 +0800 Subject: Change favor_types to has_constructor --- crates/ra_hir_def/src/body/lower.rs | 8 ++++---- crates/ra_hir_def/src/item_scope.rs | 4 ++-- crates/ra_hir_def/src/nameres/collector.rs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index ea0ddeebc..4671b72e9 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -575,15 +575,15 @@ impl ExprCollector<'_> { self.body.item_scope.define_def(def); if let Some(name) = name { let vis = crate::visibility::Visibility::Public; // FIXME determine correctly - let favor_types = match def { + let has_constructor = match def { ModuleDefId::AdtId(AdtId::StructId(s)) => { - self.db.struct_data(s).variant_data.kind() == StructKind::Record + self.db.struct_data(s).variant_data.kind() != StructKind::Record } - _ => false, + _ => true, }; self.body.item_scope.push_res( name.as_name(), - crate::per_ns::PerNs::from_def(def, vis, favor_types), + crate::per_ns::PerNs::from_def(def, vis, has_constructor), ); } } diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index 6d8d1f8a3..954f2542a 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs @@ -151,7 +151,7 @@ impl ItemScope { } impl PerNs { - pub(crate) fn from_def(def: ModuleDefId, v: Visibility, favor_types: bool) -> PerNs { + pub(crate) fn from_def(def: ModuleDefId, v: Visibility, has_constructor: bool) -> PerNs { match def { ModuleDefId::ModuleId(_) => PerNs::types(def, v), ModuleDefId::FunctionId(_) => PerNs::values(def, v), @@ -159,7 +159,7 @@ impl PerNs { AdtId::UnionId(_) => PerNs::both(def, def, v), AdtId::EnumId(_) => PerNs::types(def, v), AdtId::StructId(_) => { - if favor_types { + if !has_constructor { PerNs::types(def, v) } else { PerNs::both(def, def, v) diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 49b33ca94..db994122a 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -844,7 +844,7 @@ impl ModCollector<'_, '_> { let name = def.name.clone(); let container = ContainerId::ModuleId(module); let vis = &def.visibility; - let mut favor_types = false; + let mut has_constructor = false; let def: ModuleDefId = match def.kind { raw::DefKind::Function(ast_id) => FunctionLoc { @@ -854,7 +854,7 @@ impl ModCollector<'_, '_> { .intern(self.def_collector.db) .into(), raw::DefKind::Struct(ast_id, mode) => { - favor_types = mode == raw::StructDefKind::Record; + has_constructor = mode != raw::StructDefKind::Record; StructLoc { container, ast_id: AstId::new(self.file_id, ast_id) } .intern(self.def_collector.db) .into() @@ -899,7 +899,7 @@ impl ModCollector<'_, '_> { .unwrap_or(Visibility::Public); self.def_collector.update( self.module_id, - &[(name, PerNs::from_def(def, vis, favor_types))], + &[(name, PerNs::from_def(def, vis, has_constructor))], vis, ) } -- cgit v1.2.3 From cf821cc33271b3a133ea3b3775f86573aa2514cb Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 5 May 2020 01:19:54 +0800 Subject: Change union resolve types only --- crates/ra_hir_def/src/item_scope.rs | 2 +- crates/ra_hir_def/src/nameres/tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index 954f2542a..7792ed709 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs @@ -156,7 +156,7 @@ impl PerNs { ModuleDefId::ModuleId(_) => PerNs::types(def, v), ModuleDefId::FunctionId(_) => PerNs::values(def, v), ModuleDefId::AdtId(adt) => match adt { - AdtId::UnionId(_) => PerNs::both(def, def, v), + AdtId::UnionId(_) => PerNs::types(def, v), AdtId::EnumId(_) => PerNs::types(def, v), AdtId::StructId(_) => { if !has_constructor { diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index 83120fa36..1b66c1aac 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs @@ -67,7 +67,7 @@ fn crate_def_map_smoke_test() { ⋮Baz: t v ⋮E: t ⋮EXT: v - ⋮U: t v + ⋮U: t ⋮ext: v "###) } -- cgit v1.2.3 From 831bb1cf91d69e7e325ecbdab11e6fc80bcae4a4 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Tue, 5 May 2020 09:34:07 +0200 Subject: refactor: use attrsOwner directly in is_cfg_enabled Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_hir_def/src/adt.rs | 17 ++++++++--------- crates/ra_hir_def/src/body.rs | 11 ++++------- crates/ra_hir_def/src/body/lower.rs | 6 ++---- crates/ra_hir_def/src/data.rs | 3 +-- 4 files changed, 15 insertions(+), 22 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index d0912ddaa..2bc34d449 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -118,11 +118,12 @@ fn lower_enum( module_id: ModuleId, ) { let expander = CfgExpander::new(db, ast.file_id, module_id.krate); - let variants = - ast.value.variant_list().into_iter().flat_map(|it| it.variants()).filter(|var| { - let attrs = expander.parse_attrs(var); - expander.is_cfg_enabled(&attrs) - }); + let variants = ast + .value + .variant_list() + .into_iter() + .flat_map(|it| it.variants()) + .filter(|var| expander.is_cfg_enabled(var)); for var in variants { trace.alloc( || var.clone(), @@ -215,8 +216,7 @@ fn lower_struct( match &ast.value { ast::StructKind::Tuple(fl) => { for (i, fd) in fl.fields().enumerate() { - let attrs = expander.parse_attrs(&fd); - if !expander.is_cfg_enabled(&attrs) { + if !expander.is_cfg_enabled(&fd) { continue; } @@ -233,8 +233,7 @@ fn lower_struct( } ast::StructKind::Record(fl) => { for fd in fl.fields() { - let attrs = expander.parse_attrs(&fd); - if !expander.is_cfg_enabled(&attrs) { + if !expander.is_cfg_enabled(&fd) { continue; } diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 4edaad960..f5a7305dc 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -60,7 +60,8 @@ impl CfgExpander { Attrs::new(owner, &self.hygiene) } - pub(crate) fn is_cfg_enabled(&self, attrs: &Attrs) -> bool { + pub(crate) fn is_cfg_enabled(&self, owner: &dyn ast::AttrsOwner) -> bool { + let attrs = self.parse_attrs(owner); attrs.is_cfg_enabled(&self.cfg_options) } } @@ -141,12 +142,8 @@ impl Expander { InFile { file_id: self.current_file_id, value } } - pub(crate) fn parse_attrs(&self, owner: &dyn ast::AttrsOwner) -> Attrs { - self.cfg_expander.parse_attrs(owner) - } - - pub(crate) fn is_cfg_enabled(&self, attrs: &Attrs) -> bool { - self.cfg_expander.is_cfg_enabled(attrs) + pub(crate) fn is_cfg_enabled(&self, owner: &dyn ast::AttrsOwner) -> bool { + self.cfg_expander.is_cfg_enabled(owner) } fn parse_path(&mut self, path: ast::Path) -> Option { diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 687216dc3..8f5fa1b55 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -162,8 +162,7 @@ impl ExprCollector<'_> { fn collect_expr(&mut self, expr: ast::Expr) -> ExprId { let syntax_ptr = AstPtr::new(&expr); - let attrs = self.expander.parse_attrs(&expr); - if !self.expander.is_cfg_enabled(&attrs) { + if !self.expander.is_cfg_enabled(&expr) { return self.missing_expr(); } match expr { @@ -329,8 +328,7 @@ impl ExprCollector<'_> { .fields() .inspect(|field| field_ptrs.push(AstPtr::new(field))) .filter_map(|field| { - let attrs = self.expander.parse_attrs(&field); - if !self.expander.is_cfg_enabled(&attrs) { + if !self.expander.is_cfg_enabled(&field) { return None; } let name = field.field_name()?.as_name(); diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index d4cba4d05..2dbae04d3 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs @@ -335,8 +335,7 @@ fn collect_items( .filter_map(|item_node| match item_node { ast::ImplItem::FnDef(it) => { let name = it.name().map_or_else(Name::missing, |it| it.as_name()); - let attrs = expander.parse_attrs(&it); - if !expander.is_cfg_enabled(&attrs) { + if !expander.is_cfg_enabled(&it) { return None; } let def = FunctionLoc { container, ast_id: AstId::new(file_id, items.ast_id(&it)) } -- cgit v1.2.3 From 07de8ea165deb37ca9c42e66d2d3ecac57756ec6 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 5 May 2020 23:01:07 +0800 Subject: invert if --- crates/ra_hir_def/src/item_scope.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index 7792ed709..fc15948ad 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs @@ -159,10 +159,10 @@ impl PerNs { AdtId::UnionId(_) => PerNs::types(def, v), AdtId::EnumId(_) => PerNs::types(def, v), AdtId::StructId(_) => { - if !has_constructor { - PerNs::types(def, v) - } else { + if has_constructor { PerNs::both(def, def, v) + } else { + PerNs::types(def, v) } } }, -- cgit v1.2.3 From 92665358cd98913e3fef8294e1889cc0bb919e3f Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 5 May 2020 23:56:10 +0800 Subject: Rename ImplItem to AssocItem --- crates/ra_hir_def/src/data.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index 2dbae04d3..e7eb2bb11 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs @@ -9,7 +9,7 @@ use hir_expand::{ }; use ra_prof::profile; use ra_syntax::ast::{ - self, AstNode, ImplItem, ModuleItemOwner, NameOwner, TypeAscriptionOwner, TypeBoundsOwner, + self, AssocItem, AstNode, ModuleItemOwner, NameOwner, TypeAscriptionOwner, TypeBoundsOwner, VisibilityOwner, }; @@ -164,7 +164,7 @@ impl TraitData { items.extend(collect_items( db, &mut expander, - item_list.impl_items(), + item_list.assoc_items(), src.file_id, container, )); @@ -219,7 +219,7 @@ impl ImplData { if let Some(item_list) = src.value.item_list() { let mut expander = Expander::new(db, impl_loc.ast_id.file_id, module_id); items.extend( - collect_items(db, &mut expander, item_list.impl_items(), src.file_id, container) + collect_items(db, &mut expander, item_list.assoc_items(), src.file_id, container) .into_iter() .map(|(_, item)| item), ); @@ -304,7 +304,7 @@ fn collect_items_in_macro( let mut res = collect_items( db, expander, - items.value.items().filter_map(|it| ImplItem::cast(it.syntax().clone())), + items.value.items().filter_map(|it| AssocItem::cast(it.syntax().clone())), items.file_id, container, ); @@ -325,15 +325,15 @@ fn collect_items_in_macro( fn collect_items( db: &dyn DefDatabase, expander: &mut Expander, - impl_items: impl Iterator, + assoc_items: impl Iterator, file_id: crate::HirFileId, container: AssocContainerId, ) -> Vec<(Name, AssocItemId)> { let items = db.ast_id_map(file_id); - impl_items + assoc_items .filter_map(|item_node| match item_node { - ast::ImplItem::FnDef(it) => { + ast::AssocItem::FnDef(it) => { let name = it.name().map_or_else(Name::missing, |it| it.as_name()); if !expander.is_cfg_enabled(&it) { return None; @@ -342,13 +342,13 @@ fn collect_items( .intern(db); Some((name, def.into())) } - ast::ImplItem::ConstDef(it) => { + ast::AssocItem::ConstDef(it) => { let name = it.name().map_or_else(Name::missing, |it| it.as_name()); let def = ConstLoc { container, ast_id: AstId::new(file_id, items.ast_id(&it)) } .intern(db); Some((name, def.into())) } - ast::ImplItem::TypeAliasDef(it) => { + ast::AssocItem::TypeAliasDef(it) => { let name = it.name().map_or_else(Name::missing, |it| it.as_name()); let def = TypeAliasLoc { container, ast_id: AstId::new(file_id, items.ast_id(&it)) } -- cgit v1.2.3