don't cycle when processing macros from prelude in prelude

This commit is contained in:
Aleksey Kladov 2019-09-07 21:43:41 +03:00
parent 4a89a7c902
commit bcc9a28734
2 changed files with 33 additions and 2 deletions

View file

@ -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.

View file

@ -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
"###);
}