File: metavar_cross_edition_recursive_macros.rs

package info (click to toggle)
rustc 1.88.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 934,128 kB
  • sloc: xml: 158,127; python: 36,062; javascript: 19,855; sh: 19,700; cpp: 18,947; ansic: 12,993; asm: 4,792; makefile: 690; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (37 lines) | stat: -rw-r--r-- 983 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//@ edition: 2024
//@ aux-build: metavar_2018.rs
//@ known-bug: #130484
//@ run-pass

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

#![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);

    assert!(!from_2018);
    assert!(!from_2024); // from_2024 will be true once #130484 is fixed

    // 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);

    assert!(!from_2018);
    assert!(!from_2024); // from_2024 will be true once #130484 is fixed
}