Merge #4234
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:
@@ -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!(
|
||||
|
||||
Reference in New Issue
Block a user