Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1e3d482

Browse files
eholkvincenzopalazzo
andcommittedSep 17, 2024··
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 <[email protected]>
1 parent e07b011 commit 1e3d482

File tree

3 files changed

+45
-30
lines changed

3 files changed

+45
-30
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
//@ edition: 2021
1+
//@ edition: 2018
22
#[macro_export]
33
macro_rules! make_matcher {
44
($name:ident, $fragment_type:ident, $d:tt) => {
55
#[macro_export]
66
macro_rules! $name {
77
($d _:$fragment_type) => { true };
88
(const { 0 }) => { false };
9+
(A | B) => { false };
910
}
1011
};
1112
}
12-
make_matcher!(is_expr_from_2021, expr, $);
13+
make_matcher!(is_expr_from_2018, expr, $);
14+
make_matcher!(is_pat_from_2018, pat, $);

‎tests/ui/macros/expr_2021_with_metavar_expr.rs

-28
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//@ compile-flags: --edition=2024 -Z unstable-options
2+
//@ aux-build: metavar_2018.rs
3+
//@ run-pass
4+
5+
// This test captures the behavior of macro-generating-macros with fragment
6+
// specifiers across edition boundaries.
7+
8+
#![feature(expr_fragment_specifier_2024)]
9+
#![feature(macro_metavar_expr)]
10+
#![allow(incomplete_features)]
11+
12+
extern crate metavar_2018;
13+
14+
use metavar_2018::{is_expr_from_2018, is_pat_from_2018, make_matcher};
15+
16+
make_matcher!(is_expr_from_2024, expr, $);
17+
make_matcher!(is_pat_from_2024, pat, $);
18+
19+
fn main() {
20+
// Check expr
21+
let from_2018 = is_expr_from_2018!(const { 0 });
22+
dbg!(from_2018);
23+
let from_2024 = is_expr_from_2024!(const { 0 });
24+
dbg!(from_2024);
25+
26+
// These capture the current, empirically determined behavior.
27+
// It's not clear whether this is the desired behavior.
28+
assert!(!from_2018);
29+
assert!(!from_2024);
30+
31+
// Check pat
32+
let from_2018 = is_pat_from_2018!(A | B);
33+
dbg!(from_2018);
34+
let from_2024 = is_pat_from_2024!(A | B);
35+
dbg!(from_2024);
36+
37+
// These capture the current, empirically determined behavior.
38+
// It's not clear whether this is the desired behavior.
39+
assert!(!from_2018);
40+
assert!(!from_2024);
41+
}

0 commit comments

Comments
 (0)
Please sign in to comment.