Skip to content

Commit

Permalink
fixup! test: cross-edition metavar fragment specifiers
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo committed Sep 8, 2024
1 parent 81b3c9f commit e07b011
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
14 changes: 5 additions & 9 deletions tests/ui/macros/auxiliary/metavar_2021.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
//@ edition: 2021

#![feature(macro_metavar_expr)]

#[macro_export]
macro_rules! make_matcher {
($name:ident, $fragment_type:ident) => {
($name:ident, $fragment_type:ident, $d:tt) => {
#[macro_export]
macro_rules! $name {
($$_:$fragment_type) => { true };
($$($$_:tt)*) => { false };
($d _:$fragment_type) => { true };
(const { 0 }) => { false };
}
}
};
}

make_matcher!(is_expr_from_2021, expr);
make_matcher!(is_expr_from_2021, expr, $);
9 changes: 4 additions & 5 deletions tests/ui/macros/expr_2021_with_metavar_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//@ aux-build: metavar_2021.rs
//@ run-pass

// This test captures the behavior of macro-generating-macros with fragment specifiers across edition b
// This test captures the behavior of macro-generating-macros with fragment
// specifiers across edition boundaries.

#![feature(expr_fragment_specifier_2024)]
#![feature(macro_metavar_expr)]
Expand All @@ -12,7 +13,7 @@ extern crate metavar_2021;

use metavar_2021::{is_expr_from_2021, make_matcher};

make_matcher!(is_expr_from_2024, expr);
make_matcher!(is_expr_from_2024, expr, $);

fn main() {
let from_2021 = is_expr_from_2021!(const { 0 });
Expand All @@ -21,9 +22,7 @@ fn main() {
dbg!(from_2024);

// These capture the current, empirically determined behavior.
//
// It's not clear whether this is the desired behavior, but that's a
// question we can deal with when stabilizing macro_metavar_expr.
// It's not clear whether this is the desired behavior.
assert!(!from_2021);
assert!(!from_2024);
}

0 comments on commit e07b011

Please sign in to comment.