7482: block_def_map: add a few macro tests r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
bors[bot] 2021-01-28 17:55:54 +00:00 committed by GitHub
commit fa1b500d2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -121,3 +121,66 @@ struct Struct {}
"#]],
);
}
#[test]
fn legacy_macro_items() {
// Checks that legacy-scoped `macro_rules!` from parent namespaces are resolved and expanded
// correctly.
check_at(
r#"
macro_rules! hit {
() => {
struct Hit {}
}
}
fn f() {
hit!();
$0
}
"#,
expect![[r#"
block scope
Hit: t
crate
f: v
"#]],
);
}
#[test]
fn macro_resolve() {
check_at(
r#"
//- /lib.rs crate:lib deps:core
use core::mark;
fn f() {
fn nested() {
mark::hit!(Hit);
$0
}
}
//- /core.rs crate:core
pub mod mark {
#[macro_export]
macro_rules! _hit {
($name:ident) => {
struct $name {}
}
}
pub use crate::_hit as hit;
}
"#,
expect![[r#"
block scope
Hit: t
block scope
nested: v
crate
f: v
mark: t
"#]],
);
}