Add coverage for pat too
In 2021 pat was changed to recognize `|` at the top level, with pat_param added to retain the old behavior. This means pat is subject to the same cross-edition behavior as expr will be in 2024. Co-authored-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
parent
255586d659
commit
7653811ac5
@ -1,4 +1,4 @@
|
||||
//@ edition: 2021
|
||||
//@ edition: 2018
|
||||
#[macro_export]
|
||||
macro_rules! make_matcher {
|
||||
($name:ident, $fragment_type:ident, $d:tt) => {
|
||||
@ -6,7 +6,9 @@ macro_rules! make_matcher {
|
||||
macro_rules! $name {
|
||||
($d _:$fragment_type) => { true };
|
||||
(const { 0 }) => { false };
|
||||
(A | B) => { false };
|
||||
}
|
||||
};
|
||||
}
|
||||
make_matcher!(is_expr_from_2021, expr, $);
|
||||
make_matcher!(is_expr_from_2018, expr, $);
|
||||
make_matcher!(is_pat_from_2018, pat, $);
|
@ -1,28 +0,0 @@
|
||||
//@ compile-flags: --edition=2024 -Z unstable-options
|
||||
//@ aux-build: metavar_2021.rs
|
||||
//@ run-pass
|
||||
|
||||
// This test captures the behavior of macro-generating-macros with fragment
|
||||
// specifiers across edition boundaries.
|
||||
|
||||
#![feature(expr_fragment_specifier_2024)]
|
||||
#![feature(macro_metavar_expr)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
extern crate metavar_2021;
|
||||
|
||||
use metavar_2021::{is_expr_from_2021, make_matcher};
|
||||
|
||||
make_matcher!(is_expr_from_2024, expr, $);
|
||||
|
||||
fn main() {
|
||||
let from_2021 = is_expr_from_2021!(const { 0 });
|
||||
dbg!(from_2021);
|
||||
let from_2024 = is_expr_from_2024!(const { 0 });
|
||||
dbg!(from_2024);
|
||||
|
||||
// These capture the current, empirically determined behavior.
|
||||
// It's not clear whether this is the desired behavior.
|
||||
assert!(!from_2021);
|
||||
assert!(!from_2024);
|
||||
}
|
41
tests/ui/macros/metavar_cross_edition_recursive_macros.rs
Normal file
41
tests/ui/macros/metavar_cross_edition_recursive_macros.rs
Normal file
@ -0,0 +1,41 @@
|
||||
//@ compile-flags: --edition=2024 -Z unstable-options
|
||||
//@ aux-build: metavar_2018.rs
|
||||
//@ run-pass
|
||||
|
||||
// This test captures the behavior of macro-generating-macros with fragment
|
||||
// specifiers across edition boundaries.
|
||||
|
||||
#![feature(expr_fragment_specifier_2024)]
|
||||
#![feature(macro_metavar_expr)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
extern crate metavar_2018;
|
||||
|
||||
use metavar_2018::{is_expr_from_2018, is_pat_from_2018, make_matcher};
|
||||
|
||||
make_matcher!(is_expr_from_2024, expr, $);
|
||||
make_matcher!(is_pat_from_2024, pat, $);
|
||||
|
||||
fn main() {
|
||||
// Check expr
|
||||
let from_2018 = is_expr_from_2018!(const { 0 });
|
||||
dbg!(from_2018);
|
||||
let from_2024 = is_expr_from_2024!(const { 0 });
|
||||
dbg!(from_2024);
|
||||
|
||||
// These capture the current, empirically determined behavior.
|
||||
// It's not clear whether this is the desired behavior.
|
||||
assert!(!from_2018);
|
||||
assert!(!from_2024);
|
||||
|
||||
// Check pat
|
||||
let from_2018 = is_pat_from_2018!(A | B);
|
||||
dbg!(from_2018);
|
||||
let from_2024 = is_pat_from_2024!(A | B);
|
||||
dbg!(from_2024);
|
||||
|
||||
// These capture the current, empirically determined behavior.
|
||||
// It's not clear whether this is the desired behavior.
|
||||
assert!(!from_2018);
|
||||
assert!(!from_2024);
|
||||
}
|
Loading…
Reference in New Issue
Block a user