mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-16 07:03:57 +00:00
don't cycle when processing macros from prelude in prelude
This commit is contained in:
parent
4a89a7c902
commit
bcc9a28734
2 changed files with 33 additions and 2 deletions
|
@ -525,9 +525,11 @@ where
|
||||||
fn collect(&mut self, items: &[raw::RawItem]) {
|
fn collect(&mut self, items: &[raw::RawItem]) {
|
||||||
// Prelude module is always considered to be `#[macro_use]`.
|
// Prelude module is always considered to be `#[macro_use]`.
|
||||||
if let Some(prelude_module) = self.def_collector.def_map.prelude {
|
if let Some(prelude_module) = self.def_collector.def_map.prelude {
|
||||||
|
if prelude_module.krate != self.def_collector.def_map.krate {
|
||||||
tested_by!(prelude_is_macro_use);
|
tested_by!(prelude_is_macro_use);
|
||||||
self.def_collector.import_all_macros_exported(prelude_module);
|
self.def_collector.import_all_macros_exported(prelude_module);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This should be processed eagerly instead of deferred to resolving.
|
// This should be processed eagerly instead of deferred to resolving.
|
||||||
// `#[macro_use] extern crate` is hoisted to imports macros before collecting
|
// `#[macro_use] extern crate` is hoisted to imports macros before collecting
|
||||||
|
|
|
@ -248,3 +248,32 @@ fn prelude_is_macro_use() {
|
||||||
⋮Baz: t v
|
⋮Baz: t v
|
||||||
"###);
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn prelude_cycle() {
|
||||||
|
let map = def_map(
|
||||||
|
"
|
||||||
|
//- /lib.rs
|
||||||
|
#[prelude_import]
|
||||||
|
use self::prelude::*;
|
||||||
|
|
||||||
|
declare_mod!();
|
||||||
|
|
||||||
|
mod prelude {
|
||||||
|
macro_rules! declare_mod {
|
||||||
|
() => (mod foo {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
",
|
||||||
|
);
|
||||||
|
assert_snapshot!(map, @r###"
|
||||||
|
⋮crate
|
||||||
|
⋮foo: t
|
||||||
|
⋮prelude: t
|
||||||
|
⋮
|
||||||
|
⋮crate::prelude
|
||||||
|
⋮declare_mod: m
|
||||||
|
⋮
|
||||||
|
⋮crate::foo
|
||||||
|
"###);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue