mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +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,8 +525,10 @@ where
|
|||
fn collect(&mut self, items: &[raw::RawItem]) {
|
||||
// Prelude module is always considered to be `#[macro_use]`.
|
||||
if let Some(prelude_module) = self.def_collector.def_map.prelude {
|
||||
tested_by!(prelude_is_macro_use);
|
||||
self.def_collector.import_all_macros_exported(prelude_module);
|
||||
if prelude_module.krate != self.def_collector.def_map.krate {
|
||||
tested_by!(prelude_is_macro_use);
|
||||
self.def_collector.import_all_macros_exported(prelude_module);
|
||||
}
|
||||
}
|
||||
|
||||
// This should be processed eagerly instead of deferred to resolving.
|
||||
|
|
|
@ -248,3 +248,32 @@ fn prelude_is_macro_use() {
|
|||
⋮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