4234: Support local_inner_macros r=jonas-schievink a=edwin0cheng

This PR implements `#[macro_export(local_inner_macros)]` support. 

Note that the rustc implementation is quite [hacky][1] too. :)

[1]: 614f273e93/src/librustc_resolve/macros.rs (L456)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
bors[bot]
2020-05-02 10:30:49 +00:00
committed by GitHub
13 changed files with 139 additions and 17 deletions

View File

@@ -427,6 +427,32 @@ fn main() {
);
}
#[test]
fn infer_local_inner_macros() {
let (db, pos) = TestDB::with_position(
r#"
//- /main.rs crate:main deps:foo
fn test() {
let x = foo::foo!(1);
x<|>;
}
//- /lib.rs crate:foo
#[macro_export(local_inner_macros)]
macro_rules! foo {
(1) => { bar!() };
}
#[macro_export]
macro_rules! bar {
() => { 42 }
}
"#,
);
assert_eq!("i32", type_at_pos(&db, pos));
}
#[test]
fn infer_builtin_macros_line() {
assert_snapshot!(