aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-17 11:16:05 +0100
committerGitHub <[email protected]>2021-05-17 11:16:05 +0100
commit6aac6bcc74d02614fd4827f922b4846a10d56f59 (patch)
tree3816136d3f8a190b9fc488c88758403a5a26c5f0 /crates
parent67c157b7dd4d52db0462da0b8734590ec8c7ee45 (diff)
parent999217374f7be95eddee8c109790c6cfa0ce67e5 (diff)
Merge #8858
8858: Ignore macro import from `extern crate self` r=jonas-schievink a=ivan770 Closes #8834 Co-authored-by: ivan770 <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_def/src/nameres/collector.rs5
-rw-r--r--crates/hir_def/src/nameres/tests.rs16
2 files changed, 21 insertions, 0 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index adfb78c94..19db6cc59 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -481,6 +481,11 @@ impl DefCollector<'_> {
481 let res = self.def_map.resolve_name_in_extern_prelude(self.db, &extern_crate.name); 481 let res = self.def_map.resolve_name_in_extern_prelude(self.db, &extern_crate.name);
482 482
483 if let Some(ModuleDefId::ModuleId(m)) = res.take_types() { 483 if let Some(ModuleDefId::ModuleId(m)) = res.take_types() {
484 if m == self.def_map.module_id(current_module_id) {
485 cov_mark::hit!(ignore_macro_use_extern_crate_self);
486 return;
487 }
488
484 cov_mark::hit!(macro_rules_from_other_crates_are_visible_with_macro_use); 489 cov_mark::hit!(macro_rules_from_other_crates_are_visible_with_macro_use);
485 self.import_all_macros_exported(current_module_id, m.krate); 490 self.import_all_macros_exported(current_module_id, m.krate);
486 } 491 }
diff --git a/crates/hir_def/src/nameres/tests.rs b/crates/hir_def/src/nameres/tests.rs
index 4f2e7a2f9..9f652731d 100644
--- a/crates/hir_def/src/nameres/tests.rs
+++ b/crates/hir_def/src/nameres/tests.rs
@@ -411,6 +411,22 @@ struct Arc;
411} 411}
412 412
413#[test] 413#[test]
414fn macro_use_extern_crate_self() {
415 cov_mark::check!(ignore_macro_use_extern_crate_self);
416 check(
417 r#"
418//- /main.rs crate:main
419#[macro_use]
420extern crate self as bla;
421"#,
422 expect![[r#"
423 crate
424 bla: t
425 "#]],
426 );
427}
428
429#[test]
414fn reexport_across_crates() { 430fn reexport_across_crates() {
415 check( 431 check(
416 r#" 432 r#"