File: expanded-interpolation.stdout

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (105 lines) | stat: -rw-r--r-- 2,775 bytes parent folder | download | duplicates (3)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#![feature(prelude_import)]
#![no_std]
//@ compile-flags: -Zunpretty=expanded
//@ check-pass

// This test covers the AST pretty-printer's insertion of parentheses in some
// macro metavariable edge cases. Synthetic parentheses (i.e. not appearing in
// the syntax tree) need to be printed in order for the printed code to be valid
// Rust syntax. We also test negative cases: the pretty-printer should not be
// synthesizing parentheses indiscriminately; only where necessary.

#![feature(let_chains)]
#![feature(if_let_guard)]
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;

macro_rules! expr { ($expr:expr) => { $expr }; }

macro_rules! stmt { ($stmt:stmt) => { $stmt }; }

fn break_labeled_loop() {
    let no_paren =
        'outer: loop { break 'outer 'inner: loop { break 'inner 1; } + 1; };

    let paren_around_break_value =
        'outer: loop { break ('inner: loop { break 'inner 1; } + 1); };

    macro_rules! breaking { ($value:expr) => { break $value }; }

    let paren_around_break_value =
        loop { break ('inner: loop { break 'inner 1; } + 1); };
}

fn if_let() {
    macro_rules! if_let {
        ($pat:pat, $expr:expr) => { if let $pat = $expr {} };
    }

    if let no_paren = true && false {}
    if let paren_around_binary = (true && false) {};
    if let no_paren = true {};

    struct Struct {}
    match () { _ if let no_paren = Struct {} => {} }
}

fn let_else() {
    let no_paren = 1 + 1 else { return; };
    let paren_around_loop = (loop {}) else { return; };
}

fn local() {
    macro_rules! let_expr_minus_one {
        ($pat:pat, $expr:expr) => { let $pat = $expr - 1; };
    }

    let void;
    let no_paren = match void {} - 1;

    macro_rules! let_expr_else_return {
        ($pat:pat, $expr:expr) => { let $pat = $expr else { return; }; };
    }
    let 

            no_paren = void() else { return; };
}

fn match_arm() {
    macro_rules! match_arm {
        ($pat:pat, $expr:expr) => { match () { $pat => $expr } };
    }
    match () {


            no_paren => 1 - 1,
    };
    match () { paren_around_brace => ({ 1 }) - 1, };
}

/// https://github.com/rust-lang/rust/issues/98790
fn stmt_boundary() {
    macro_rules! expr_as_stmt { ($expr:expr) => { stmt!($expr) }; }

    let paren_around_match;
    (match paren_around_match {}) | true;

    macro_rules! minus_one { ($expr:expr) => { expr_as_stmt!($expr - 1) }; }

    let (no_paren, paren_around_loop);
    no_paren - 1;
    (match paren_around_match {}) - 1;
    (match paren_around_match {})() - 1;
    (match paren_around_match {})[0] - 1;
    (loop { break paren_around_loop; }) - 1;
}

fn vis_inherited() {
    macro_rules! vis_inherited {
        ($vis:vis struct) => { $vis struct Struct; };
    }
    struct Struct;

}