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:
bors[bot] 2019-09-07 18:52:45 +00:00 committed by GitHub
commit 787f1206a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 2 deletions

View File

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

View File

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