Merge #1787
1787: don't cycle when processing macros from prelude in prelude r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
787f1206a9
@ -525,8 +525,10 @@ impl<DB> ModCollector<'_, &'_ mut DefCollector<&'_ DB>>
|
||||
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 @@ macro_rules! structs_outside {
|
||||
⋮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 New Issue
Block a user