Test macros doing edition dependent parsing

This commit is contained in:
Lukas Wirth 2024-07-19 16:39:00 +02:00
parent 2c32ee7cfa
commit 546eb6b530
8 changed files with 92 additions and 62 deletions

View file

@ -1921,3 +1921,59 @@ fn f() {
"#]],
);
}
#[test]
fn test_edition_handling_out() {
check(
r#"
//- /main.rs crate:main deps:old edition:2021
macro_rules! r#try {
($it:expr) => {
$it?
};
}
fn f() {
old::invoke_bare_try!(0);
}
//- /old.rs crate:old edition:2015
#[macro_export]
macro_rules! invoke_bare_try {
($it:expr) => {
try!($it)
};
}
"#,
expect![[r#"
macro_rules! r#try {
($it:expr) => {
$it?
};
}
fn f() {
try!(0);
}
"#]],
);
}
#[test]
fn test_edition_handling_in() {
check(
r#"
//- /main.rs crate:main deps:old edition:2021
fn f() {
old::parse_try_old!(try!{});
}
//- /old.rs crate:old edition:2015
#[macro_export]
macro_rules! parse_try_old {
($it:expr) => {};
}
"#,
expect![[r#"
fn f() {
;
}
"#]],
);
}