diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 29 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/path_resolution.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/raw.rs | 51 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/globs.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/macros.rs | 70 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/mod_resolution.rs | 2 |
7 files changed, 126 insertions, 51 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 98c74fe25..353a31ad4 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -14,7 +14,7 @@ use ra_cfg::CfgOptions; | |||
14 | use ra_db::{CrateId, FileId, ProcMacroId}; | 14 | use ra_db::{CrateId, FileId, ProcMacroId}; |
15 | use ra_syntax::ast; | 15 | use ra_syntax::ast; |
16 | use rustc_hash::FxHashMap; | 16 | use rustc_hash::FxHashMap; |
17 | use test_utils::tested_by; | 17 | use test_utils::mark; |
18 | 18 | ||
19 | use crate::{ | 19 | use crate::{ |
20 | attr::Attrs, | 20 | attr::Attrs, |
@@ -204,6 +204,7 @@ impl DefCollector<'_> { | |||
204 | ast_id: None, | 204 | ast_id: None, |
205 | krate: Some(krate), | 205 | krate: Some(krate), |
206 | kind: MacroDefKind::CustomDerive(expander), | 206 | kind: MacroDefKind::CustomDerive(expander), |
207 | local_inner: false, | ||
207 | }; | 208 | }; |
208 | 209 | ||
209 | self.define_proc_macro(name.clone(), macro_id); | 210 | self.define_proc_macro(name.clone(), macro_id); |
@@ -301,7 +302,7 @@ impl DefCollector<'_> { | |||
301 | ); | 302 | ); |
302 | 303 | ||
303 | if let Some(ModuleDefId::ModuleId(m)) = res.take_types() { | 304 | if let Some(ModuleDefId::ModuleId(m)) = res.take_types() { |
304 | tested_by!(macro_rules_from_other_crates_are_visible_with_macro_use); | 305 | mark::hit!(macro_rules_from_other_crates_are_visible_with_macro_use); |
305 | self.import_all_macros_exported(current_module_id, m.krate); | 306 | self.import_all_macros_exported(current_module_id, m.krate); |
306 | } | 307 | } |
307 | } | 308 | } |
@@ -411,10 +412,10 @@ impl DefCollector<'_> { | |||
411 | match def.take_types() { | 412 | match def.take_types() { |
412 | Some(ModuleDefId::ModuleId(m)) => { | 413 | Some(ModuleDefId::ModuleId(m)) => { |
413 | if import.is_prelude { | 414 | if import.is_prelude { |
414 | tested_by!(std_prelude); | 415 | mark::hit!(std_prelude); |
415 | self.def_map.prelude = Some(m); | 416 | self.def_map.prelude = Some(m); |
416 | } else if m.krate != self.def_map.krate { | 417 | } else if m.krate != self.def_map.krate { |
417 | tested_by!(glob_across_crates); | 418 | mark::hit!(glob_across_crates); |
418 | // glob import from other crate => we can just import everything once | 419 | // glob import from other crate => we can just import everything once |
419 | let item_map = self.db.crate_def_map(m.krate); | 420 | let item_map = self.db.crate_def_map(m.krate); |
420 | let scope = &item_map[m.local_id].scope; | 421 | let scope = &item_map[m.local_id].scope; |
@@ -460,7 +461,7 @@ impl DefCollector<'_> { | |||
460 | } | 461 | } |
461 | } | 462 | } |
462 | Some(ModuleDefId::AdtId(AdtId::EnumId(e))) => { | 463 | Some(ModuleDefId::AdtId(AdtId::EnumId(e))) => { |
463 | tested_by!(glob_enum); | 464 | mark::hit!(glob_enum); |
464 | // glob import from enum => just import all the variants | 465 | // glob import from enum => just import all the variants |
465 | 466 | ||
466 | // XXX: urgh, so this works by accident! Here, we look at | 467 | // XXX: urgh, so this works by accident! Here, we look at |
@@ -509,7 +510,7 @@ impl DefCollector<'_> { | |||
509 | 510 | ||
510 | self.update(module_id, &[(name, def)], vis); | 511 | self.update(module_id, &[(name, def)], vis); |
511 | } | 512 | } |
512 | None => tested_by!(bogus_paths), | 513 | None => mark::hit!(bogus_paths), |
513 | } | 514 | } |
514 | } | 515 | } |
515 | } | 516 | } |
@@ -682,7 +683,7 @@ impl ModCollector<'_, '_> { | |||
682 | // Prelude module is always considered to be `#[macro_use]`. | 683 | // Prelude module is always considered to be `#[macro_use]`. |
683 | if let Some(prelude_module) = self.def_collector.def_map.prelude { | 684 | if let Some(prelude_module) = self.def_collector.def_map.prelude { |
684 | if prelude_module.krate != self.def_collector.def_map.krate { | 685 | if prelude_module.krate != self.def_collector.def_map.krate { |
685 | tested_by!(prelude_is_macro_use); | 686 | mark::hit!(prelude_is_macro_use); |
686 | self.def_collector.import_all_macros_exported(self.module_id, prelude_module.krate); | 687 | self.def_collector.import_all_macros_exported(self.module_id, prelude_module.krate); |
687 | } | 688 | } |
688 | } | 689 | } |
@@ -829,7 +830,7 @@ impl ModCollector<'_, '_> { | |||
829 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: res }; | 830 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: res }; |
830 | let def: ModuleDefId = module.into(); | 831 | let def: ModuleDefId = module.into(); |
831 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); | 832 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); |
832 | self.def_collector.update(self.module_id, &[(name, PerNs::from_def(def, vis))], vis); | 833 | self.def_collector.update(self.module_id, &[(name, PerNs::from_def(def, vis, false))], vis); |
833 | res | 834 | res |
834 | } | 835 | } |
835 | 836 | ||
@@ -843,6 +844,8 @@ impl ModCollector<'_, '_> { | |||
843 | let name = def.name.clone(); | 844 | let name = def.name.clone(); |
844 | let container = ContainerId::ModuleId(module); | 845 | let container = ContainerId::ModuleId(module); |
845 | let vis = &def.visibility; | 846 | let vis = &def.visibility; |
847 | let mut has_constructor = false; | ||
848 | |||
846 | let def: ModuleDefId = match def.kind { | 849 | let def: ModuleDefId = match def.kind { |
847 | raw::DefKind::Function(ast_id) => FunctionLoc { | 850 | raw::DefKind::Function(ast_id) => FunctionLoc { |
848 | container: container.into(), | 851 | container: container.into(), |
@@ -850,7 +853,8 @@ impl ModCollector<'_, '_> { | |||
850 | } | 853 | } |
851 | .intern(self.def_collector.db) | 854 | .intern(self.def_collector.db) |
852 | .into(), | 855 | .into(), |
853 | raw::DefKind::Struct(ast_id) => { | 856 | raw::DefKind::Struct(ast_id, mode) => { |
857 | has_constructor = mode != raw::StructDefKind::Record; | ||
854 | StructLoc { container, ast_id: AstId::new(self.file_id, ast_id) } | 858 | StructLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
855 | .intern(self.def_collector.db) | 859 | .intern(self.def_collector.db) |
856 | .into() | 860 | .into() |
@@ -893,7 +897,11 @@ impl ModCollector<'_, '_> { | |||
893 | .def_map | 897 | .def_map |
894 | .resolve_visibility(self.def_collector.db, self.module_id, vis) | 898 | .resolve_visibility(self.def_collector.db, self.module_id, vis) |
895 | .unwrap_or(Visibility::Public); | 899 | .unwrap_or(Visibility::Public); |
896 | self.def_collector.update(self.module_id, &[(name, PerNs::from_def(def, vis))], vis) | 900 | self.def_collector.update( |
901 | self.module_id, | ||
902 | &[(name, PerNs::from_def(def, vis, has_constructor))], | ||
903 | vis, | ||
904 | ) | ||
897 | } | 905 | } |
898 | 906 | ||
899 | fn collect_derives(&mut self, attrs: &Attrs, def: &raw::DefData) { | 907 | fn collect_derives(&mut self, attrs: &Attrs, def: &raw::DefData) { |
@@ -941,6 +949,7 @@ impl ModCollector<'_, '_> { | |||
941 | ast_id: Some(ast_id.ast_id), | 949 | ast_id: Some(ast_id.ast_id), |
942 | krate: Some(self.def_collector.def_map.krate), | 950 | krate: Some(self.def_collector.def_map.krate), |
943 | kind: MacroDefKind::Declarative, | 951 | kind: MacroDefKind::Declarative, |
952 | local_inner: mac.local_inner, | ||
944 | }; | 953 | }; |
945 | self.def_collector.define_macro(self.module_id, name.clone(), macro_id, mac.export); | 954 | self.def_collector.define_macro(self.module_id, name.clone(), macro_id, mac.export); |
946 | } | 955 | } |
diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs index 35a0a0c98..19692e70c 100644 --- a/crates/ra_hir_def/src/nameres/path_resolution.rs +++ b/crates/ra_hir_def/src/nameres/path_resolution.rs | |||
@@ -14,7 +14,7 @@ use std::iter::successors; | |||
14 | 14 | ||
15 | use hir_expand::name::Name; | 15 | use hir_expand::name::Name; |
16 | use ra_db::Edition; | 16 | use ra_db::Edition; |
17 | use test_utils::tested_by; | 17 | use test_utils::mark; |
18 | 18 | ||
19 | use crate::{ | 19 | use crate::{ |
20 | db::DefDatabase, | 20 | db::DefDatabase, |
@@ -108,7 +108,7 @@ impl CrateDefMap { | |||
108 | let mut curr_per_ns: PerNs = match path.kind { | 108 | let mut curr_per_ns: PerNs = match path.kind { |
109 | PathKind::DollarCrate(krate) => { | 109 | PathKind::DollarCrate(krate) => { |
110 | if krate == self.krate { | 110 | if krate == self.krate { |
111 | tested_by!(macro_dollar_crate_self); | 111 | mark::hit!(macro_dollar_crate_self); |
112 | PerNs::types( | 112 | PerNs::types( |
113 | ModuleId { krate: self.krate, local_id: self.root }.into(), | 113 | ModuleId { krate: self.krate, local_id: self.root }.into(), |
114 | Visibility::Public, | 114 | Visibility::Public, |
@@ -116,7 +116,7 @@ impl CrateDefMap { | |||
116 | } else { | 116 | } else { |
117 | let def_map = db.crate_def_map(krate); | 117 | let def_map = db.crate_def_map(krate); |
118 | let module = ModuleId { krate, local_id: def_map.root }; | 118 | let module = ModuleId { krate, local_id: def_map.root }; |
119 | tested_by!(macro_dollar_crate_other); | 119 | mark::hit!(macro_dollar_crate_other); |
120 | PerNs::types(module.into(), Visibility::Public) | 120 | PerNs::types(module.into(), Visibility::Public) |
121 | } | 121 | } |
122 | } | 122 | } |
@@ -221,7 +221,7 @@ impl CrateDefMap { | |||
221 | } | 221 | } |
222 | ModuleDefId::AdtId(AdtId::EnumId(e)) => { | 222 | ModuleDefId::AdtId(AdtId::EnumId(e)) => { |
223 | // enum variant | 223 | // enum variant |
224 | tested_by!(can_import_enum_variant); | 224 | mark::hit!(can_import_enum_variant); |
225 | let enum_data = db.enum_data(e); | 225 | let enum_data = db.enum_data(e); |
226 | match enum_data.variant(&segment) { | 226 | match enum_data.variant(&segment) { |
227 | Some(local_id) => { | 227 | Some(local_id) => { |
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 39b011ad7..4e628b14d 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs | |||
@@ -18,7 +18,7 @@ use ra_syntax::{ | |||
18 | ast::{self, AttrsOwner, NameOwner, VisibilityOwner}, | 18 | ast::{self, AttrsOwner, NameOwner, VisibilityOwner}, |
19 | AstNode, | 19 | AstNode, |
20 | }; | 20 | }; |
21 | use test_utils::tested_by; | 21 | use test_utils::mark; |
22 | 22 | ||
23 | use crate::{ | 23 | use crate::{ |
24 | attr::Attrs, | 24 | attr::Attrs, |
@@ -156,9 +156,16 @@ pub(super) struct DefData { | |||
156 | } | 156 | } |
157 | 157 | ||
158 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 158 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
159 | pub(super) enum StructDefKind { | ||
160 | Record, | ||
161 | Tuple, | ||
162 | Unit, | ||
163 | } | ||
164 | |||
165 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | ||
159 | pub(super) enum DefKind { | 166 | pub(super) enum DefKind { |
160 | Function(FileAstId<ast::FnDef>), | 167 | Function(FileAstId<ast::FnDef>), |
161 | Struct(FileAstId<ast::StructDef>), | 168 | Struct(FileAstId<ast::StructDef>, StructDefKind), |
162 | Union(FileAstId<ast::UnionDef>), | 169 | Union(FileAstId<ast::UnionDef>), |
163 | Enum(FileAstId<ast::EnumDef>), | 170 | Enum(FileAstId<ast::EnumDef>), |
164 | Const(FileAstId<ast::ConstDef>), | 171 | Const(FileAstId<ast::ConstDef>), |
@@ -171,7 +178,7 @@ impl DefKind { | |||
171 | pub fn ast_id(&self) -> FileAstId<ast::ModuleItem> { | 178 | pub fn ast_id(&self) -> FileAstId<ast::ModuleItem> { |
172 | match self { | 179 | match self { |
173 | DefKind::Function(it) => it.upcast(), | 180 | DefKind::Function(it) => it.upcast(), |
174 | DefKind::Struct(it) => it.upcast(), | 181 | DefKind::Struct(it, _) => it.upcast(), |
175 | DefKind::Union(it) => it.upcast(), | 182 | DefKind::Union(it) => it.upcast(), |
176 | DefKind::Enum(it) => it.upcast(), | 183 | DefKind::Enum(it) => it.upcast(), |
177 | DefKind::Const(it) => it.upcast(), | 184 | DefKind::Const(it) => it.upcast(), |
@@ -188,6 +195,7 @@ pub(super) struct MacroData { | |||
188 | pub(super) path: ModPath, | 195 | pub(super) path: ModPath, |
189 | pub(super) name: Option<Name>, | 196 | pub(super) name: Option<Name>, |
190 | pub(super) export: bool, | 197 | pub(super) export: bool, |
198 | pub(super) local_inner: bool, | ||
191 | pub(super) builtin: bool, | 199 | pub(super) builtin: bool, |
192 | } | 200 | } |
193 | 201 | ||
@@ -235,9 +243,14 @@ impl RawItemsCollector { | |||
235 | return; | 243 | return; |
236 | } | 244 | } |
237 | ast::ModuleItem::StructDef(it) => { | 245 | ast::ModuleItem::StructDef(it) => { |
246 | let kind = match it.kind() { | ||
247 | ast::StructKind::Record(_) => StructDefKind::Record, | ||
248 | ast::StructKind::Tuple(_) => StructDefKind::Tuple, | ||
249 | ast::StructKind::Unit => StructDefKind::Unit, | ||
250 | }; | ||
238 | let id = self.source_ast_id_map.ast_id(&it); | 251 | let id = self.source_ast_id_map.ast_id(&it); |
239 | let name = it.name(); | 252 | let name = it.name(); |
240 | (DefKind::Struct(id), name) | 253 | (DefKind::Struct(id, kind), name) |
241 | } | 254 | } |
242 | ast::ModuleItem::UnionDef(it) => { | 255 | ast::ModuleItem::UnionDef(it) => { |
243 | let id = self.source_ast_id_map.ast_id(&it); | 256 | let id = self.source_ast_id_map.ast_id(&it); |
@@ -333,7 +346,7 @@ impl RawItemsCollector { | |||
333 | self.push_item(current_module, attrs, RawItemKind::Module(item)); | 346 | self.push_item(current_module, attrs, RawItemKind::Module(item)); |
334 | return; | 347 | return; |
335 | } | 348 | } |
336 | tested_by!(name_res_works_for_broken_modules); | 349 | mark::hit!(name_res_works_for_broken_modules); |
337 | } | 350 | } |
338 | 351 | ||
339 | fn add_use_item(&mut self, current_module: Option<Idx<ModuleData>>, use_item: ast::UseItem) { | 352 | fn add_use_item(&mut self, current_module: Option<Idx<ModuleData>>, use_item: ast::UseItem) { |
@@ -401,14 +414,32 @@ impl RawItemsCollector { | |||
401 | 414 | ||
402 | let name = m.name().map(|it| it.as_name()); | 415 | let name = m.name().map(|it| it.as_name()); |
403 | let ast_id = self.source_ast_id_map.ast_id(&m); | 416 | let ast_id = self.source_ast_id_map.ast_id(&m); |
404 | // FIXME: cfg_attr | ||
405 | let export = m.attrs().filter_map(|x| x.simple_name()).any(|name| name == "macro_export"); | ||
406 | 417 | ||
407 | // FIXME: cfg_attr | 418 | // FIXME: cfg_attr |
408 | let builtin = | 419 | let export_attr = attrs.by_key("macro_export"); |
409 | m.attrs().filter_map(|x| x.simple_name()).any(|name| name == "rustc_builtin_macro"); | 420 | |
421 | let export = export_attr.exists(); | ||
422 | let local_inner = if export { | ||
423 | export_attr.tt_values().map(|it| &it.token_trees).flatten().any(|it| match it { | ||
424 | tt::TokenTree::Leaf(tt::Leaf::Ident(ident)) => { | ||
425 | ident.text.contains("local_inner_macros") | ||
426 | } | ||
427 | _ => false, | ||
428 | }) | ||
429 | } else { | ||
430 | false | ||
431 | }; | ||
432 | |||
433 | let builtin = attrs.by_key("rustc_builtin_macro").exists(); | ||
410 | 434 | ||
411 | let m = self.raw_items.macros.alloc(MacroData { ast_id, path, name, export, builtin }); | 435 | let m = self.raw_items.macros.alloc(MacroData { |
436 | ast_id, | ||
437 | path, | ||
438 | name, | ||
439 | export, | ||
440 | local_inner, | ||
441 | builtin, | ||
442 | }); | ||
412 | self.push_item(current_module, attrs, RawItemKind::Macro(m)); | 443 | self.push_item(current_module, attrs, RawItemKind::Macro(m)); |
413 | } | 444 | } |
414 | 445 | ||
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index 83120fa36..05cd0297d 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs | |||
@@ -8,7 +8,7 @@ use std::sync::Arc; | |||
8 | 8 | ||
9 | use insta::assert_snapshot; | 9 | use insta::assert_snapshot; |
10 | use ra_db::{fixture::WithFixture, SourceDatabase}; | 10 | use ra_db::{fixture::WithFixture, SourceDatabase}; |
11 | use test_utils::covers; | 11 | use test_utils::mark; |
12 | 12 | ||
13 | use crate::{db::DefDatabase, nameres::*, test_db::TestDB}; | 13 | use crate::{db::DefDatabase, nameres::*, test_db::TestDB}; |
14 | 14 | ||
@@ -67,7 +67,7 @@ fn crate_def_map_smoke_test() { | |||
67 | ⋮Baz: t v | 67 | ⋮Baz: t v |
68 | ⋮E: t | 68 | ⋮E: t |
69 | ⋮EXT: v | 69 | ⋮EXT: v |
70 | ⋮U: t v | 70 | ⋮U: t |
71 | ⋮ext: v | 71 | ⋮ext: v |
72 | "###) | 72 | "###) |
73 | } | 73 | } |
@@ -132,7 +132,7 @@ fn crate_def_map_fn_mod_same_name() { | |||
132 | 132 | ||
133 | #[test] | 133 | #[test] |
134 | fn bogus_paths() { | 134 | fn bogus_paths() { |
135 | covers!(bogus_paths); | 135 | mark::check!(bogus_paths); |
136 | let map = def_map( | 136 | let map = def_map( |
137 | " | 137 | " |
138 | //- /lib.rs | 138 | //- /lib.rs |
@@ -247,7 +247,7 @@ fn re_exports() { | |||
247 | 247 | ||
248 | #[test] | 248 | #[test] |
249 | fn std_prelude() { | 249 | fn std_prelude() { |
250 | covers!(std_prelude); | 250 | mark::check!(std_prelude); |
251 | let map = def_map( | 251 | let map = def_map( |
252 | " | 252 | " |
253 | //- /main.rs crate:main deps:test_crate | 253 | //- /main.rs crate:main deps:test_crate |
@@ -271,7 +271,7 @@ fn std_prelude() { | |||
271 | 271 | ||
272 | #[test] | 272 | #[test] |
273 | fn can_import_enum_variant() { | 273 | fn can_import_enum_variant() { |
274 | covers!(can_import_enum_variant); | 274 | mark::check!(can_import_enum_variant); |
275 | let map = def_map( | 275 | let map = def_map( |
276 | " | 276 | " |
277 | //- /lib.rs | 277 | //- /lib.rs |
diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/ra_hir_def/src/nameres/tests/globs.rs index ee8df3a26..2b12c0daa 100644 --- a/crates/ra_hir_def/src/nameres/tests/globs.rs +++ b/crates/ra_hir_def/src/nameres/tests/globs.rs | |||
@@ -152,7 +152,7 @@ fn glob_privacy_2() { | |||
152 | 152 | ||
153 | #[test] | 153 | #[test] |
154 | fn glob_across_crates() { | 154 | fn glob_across_crates() { |
155 | covers!(glob_across_crates); | 155 | mark::check!(glob_across_crates); |
156 | let map = def_map( | 156 | let map = def_map( |
157 | r" | 157 | r" |
158 | //- /main.rs crate:main deps:test_crate | 158 | //- /main.rs crate:main deps:test_crate |
@@ -171,7 +171,6 @@ fn glob_across_crates() { | |||
171 | 171 | ||
172 | #[test] | 172 | #[test] |
173 | fn glob_privacy_across_crates() { | 173 | fn glob_privacy_across_crates() { |
174 | covers!(glob_across_crates); | ||
175 | let map = def_map( | 174 | let map = def_map( |
176 | r" | 175 | r" |
177 | //- /main.rs crate:main deps:test_crate | 176 | //- /main.rs crate:main deps:test_crate |
@@ -191,7 +190,7 @@ fn glob_privacy_across_crates() { | |||
191 | 190 | ||
192 | #[test] | 191 | #[test] |
193 | fn glob_enum() { | 192 | fn glob_enum() { |
194 | covers!(glob_enum); | 193 | mark::check!(glob_enum); |
195 | let map = def_map( | 194 | let map = def_map( |
196 | " | 195 | " |
197 | //- /lib.rs | 196 | //- /lib.rs |
@@ -212,7 +211,7 @@ fn glob_enum() { | |||
212 | 211 | ||
213 | #[test] | 212 | #[test] |
214 | fn glob_enum_group() { | 213 | fn glob_enum_group() { |
215 | covers!(glob_enum_group); | 214 | mark::check!(glob_enum_group); |
216 | let map = def_map( | 215 | let map = def_map( |
217 | r" | 216 | r" |
218 | //- /lib.rs | 217 | //- /lib.rs |
diff --git a/crates/ra_hir_def/src/nameres/tests/macros.rs b/crates/ra_hir_def/src/nameres/tests/macros.rs index b0befdfbd..84480d9f6 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() { | |||
19 | ); | 19 | ); |
20 | assert_snapshot!(map, @r###" | 20 | assert_snapshot!(map, @r###" |
21 | ⋮crate | 21 | ⋮crate |
22 | ⋮Foo: t v | 22 | ⋮Foo: t |
23 | ⋮nested: t | 23 | ⋮nested: t |
24 | ⋮ | 24 | ⋮ |
25 | ⋮crate::nested | 25 | ⋮crate::nested |
26 | ⋮Bar: t v | 26 | ⋮Bar: t |
27 | ⋮Baz: t v | 27 | ⋮Baz: t |
28 | "###); | 28 | "###); |
29 | } | 29 | } |
30 | 30 | ||
@@ -91,13 +91,13 @@ fn macro_rules_from_other_crates_are_visible() { | |||
91 | ); | 91 | ); |
92 | assert_snapshot!(map, @r###" | 92 | assert_snapshot!(map, @r###" |
93 | ⋮crate | 93 | ⋮crate |
94 | ⋮Bar: t v | 94 | ⋮Bar: t |
95 | ⋮Foo: t v | 95 | ⋮Foo: t |
96 | ⋮bar: t | 96 | ⋮bar: t |
97 | ⋮ | 97 | ⋮ |
98 | ⋮crate::bar | 98 | ⋮crate::bar |
99 | ⋮Bar: t v | 99 | ⋮Bar: t |
100 | ⋮Foo: t v | 100 | ⋮Foo: t |
101 | ⋮bar: t | 101 | ⋮bar: t |
102 | "###); | 102 | "###); |
103 | } | 103 | } |
@@ -124,13 +124,50 @@ fn macro_rules_export_with_local_inner_macros_are_visible() { | |||
124 | ); | 124 | ); |
125 | assert_snapshot!(map, @r###" | 125 | assert_snapshot!(map, @r###" |
126 | ⋮crate | 126 | ⋮crate |
127 | ⋮Bar: t v | 127 | ⋮Bar: t |
128 | ⋮Foo: t v | 128 | ⋮Foo: t |
129 | ⋮bar: t | 129 | ⋮bar: t |
130 | ⋮ | 130 | ⋮ |
131 | ⋮crate::bar | 131 | ⋮crate::bar |
132 | ⋮Bar: t v | 132 | ⋮Bar: t |
133 | ⋮Foo: t v | 133 | ⋮Foo: t |
134 | ⋮bar: t | ||
135 | "###); | ||
136 | } | ||
137 | |||
138 | #[test] | ||
139 | fn local_inner_macros_makes_local_macros_usable() { | ||
140 | let map = def_map( | ||
141 | " | ||
142 | //- /main.rs crate:main deps:foo | ||
143 | foo::structs!(Foo, Bar); | ||
144 | mod bar; | ||
145 | //- /bar.rs | ||
146 | use crate::*; | ||
147 | //- /lib.rs crate:foo | ||
148 | #[macro_export(local_inner_macros)] | ||
149 | macro_rules! structs { | ||
150 | ($($i:ident),*) => { | ||
151 | inner!($($i),*); | ||
152 | } | ||
153 | } | ||
154 | #[macro_export] | ||
155 | macro_rules! inner { | ||
156 | ($($i:ident),*) => { | ||
157 | $(struct $i { field: u32 } )* | ||
158 | } | ||
159 | } | ||
160 | ", | ||
161 | ); | ||
162 | assert_snapshot!(map, @r###" | ||
163 | ⋮crate | ||
164 | ⋮Bar: t | ||
165 | ⋮Foo: t | ||
166 | ⋮bar: t | ||
167 | ⋮ | ||
168 | ⋮crate::bar | ||
169 | ⋮Bar: t | ||
170 | ⋮Foo: t | ||
134 | ⋮bar: t | 171 | ⋮bar: t |
135 | "###); | 172 | "###); |
136 | } | 173 | } |
@@ -167,7 +204,7 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() { | |||
167 | ); | 204 | ); |
168 | assert_snapshot!(map, @r###" | 205 | assert_snapshot!(map, @r###" |
169 | ⋮crate | 206 | ⋮crate |
170 | ⋮Foo: t v | 207 | ⋮Foo: t |
171 | ⋮bar: m | 208 | ⋮bar: m |
172 | ⋮foo: m | 209 | ⋮foo: m |
173 | "###); | 210 | "###); |
@@ -175,7 +212,7 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() { | |||
175 | 212 | ||
176 | #[test] | 213 | #[test] |
177 | fn macro_rules_from_other_crates_are_visible_with_macro_use() { | 214 | fn macro_rules_from_other_crates_are_visible_with_macro_use() { |
178 | covers!(macro_rules_from_other_crates_are_visible_with_macro_use); | 215 | mark::check!(macro_rules_from_other_crates_are_visible_with_macro_use); |
179 | let map = def_map( | 216 | let map = def_map( |
180 | " | 217 | " |
181 | //- /main.rs crate:main deps:foo | 218 | //- /main.rs crate:main deps:foo |
@@ -225,7 +262,7 @@ fn macro_rules_from_other_crates_are_visible_with_macro_use() { | |||
225 | 262 | ||
226 | #[test] | 263 | #[test] |
227 | fn prelude_is_macro_use() { | 264 | fn prelude_is_macro_use() { |
228 | covers!(prelude_is_macro_use); | 265 | mark::check!(prelude_is_macro_use); |
229 | let map = def_map( | 266 | let map = def_map( |
230 | " | 267 | " |
231 | //- /main.rs crate:main deps:foo | 268 | //- /main.rs crate:main deps:foo |
@@ -507,8 +544,7 @@ fn path_qualified_macros() { | |||
507 | 544 | ||
508 | #[test] | 545 | #[test] |
509 | fn macro_dollar_crate_is_correct_in_item() { | 546 | fn macro_dollar_crate_is_correct_in_item() { |
510 | covers!(macro_dollar_crate_self); | 547 | mark::check!(macro_dollar_crate_self); |
511 | covers!(macro_dollar_crate_other); | ||
512 | let map = def_map( | 548 | let map = def_map( |
513 | " | 549 | " |
514 | //- /main.rs crate:main deps:foo | 550 | //- /main.rs crate:main deps:foo |
@@ -566,7 +602,7 @@ fn macro_dollar_crate_is_correct_in_item() { | |||
566 | 602 | ||
567 | #[test] | 603 | #[test] |
568 | fn macro_dollar_crate_is_correct_in_indirect_deps() { | 604 | fn macro_dollar_crate_is_correct_in_indirect_deps() { |
569 | covers!(macro_dollar_crate_other); | 605 | mark::check!(macro_dollar_crate_other); |
570 | // From std | 606 | // From std |
571 | let map = def_map( | 607 | let map = def_map( |
572 | r#" | 608 | r#" |
diff --git a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs index 37fcdfb8c..b43b294ca 100644 --- a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs | |||
@@ -2,7 +2,7 @@ use super::*; | |||
2 | 2 | ||
3 | #[test] | 3 | #[test] |
4 | fn name_res_works_for_broken_modules() { | 4 | fn name_res_works_for_broken_modules() { |
5 | covers!(name_res_works_for_broken_modules); | 5 | mark::check!(name_res_works_for_broken_modules); |
6 | let map = def_map( | 6 | let map = def_map( |
7 | r" | 7 | r" |
8 | //- /lib.rs | 8 | //- /lib.rs |