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 8d9acab

Browse files
committedMay 18, 2024
Add tests for -Zunpretty=expanded ported from stringify's tests
1 parent 8e78d16 commit 8d9acab

File tree

7 files changed

+1786
-26
lines changed

7 files changed

+1786
-26
lines changed
 

‎tests/ui/unpretty/auxiliary/data.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data for include_bytes in ../expanded-exhaustive.rs

‎tests/ui/unpretty/expanded-exhaustive.rs

Lines changed: 888 additions & 0 deletions
Large diffs are not rendered by default.

‎tests/ui/unpretty/expanded-exhaustive.stdout

Lines changed: 719 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
//@ compile-flags: -Zunpretty=expanded
2+
//@ check-pass
3+
4+
#![feature(let_chains)]
5+
#![feature(if_let_guard)]
6+
7+
macro_rules! expr {
8+
($expr:expr) => { $expr };
9+
}
10+
11+
macro_rules! stmt {
12+
($stmt:stmt) => { $stmt };
13+
}
14+
15+
fn if_let() {
16+
macro_rules! if_let {
17+
($pat:pat, $expr:expr) => {
18+
if let $pat = $expr {}
19+
};
20+
}
21+
22+
if let no_paren = true && false {}
23+
if_let!(paren_around_binary, true && false);
24+
if_let!(no_paren, true);
25+
26+
struct Struct {}
27+
match () {
28+
_ if let no_paren = Struct {} => {}
29+
}
30+
}
31+
32+
fn let_else() {
33+
let no_paren = expr!(1 + 1) else { return; };
34+
let paren_around_loop = expr!(loop {}) else { return; };
35+
}
36+
37+
fn local() {
38+
macro_rules! let_expr_minus_one {
39+
($pat:pat, $expr:expr) => {
40+
let $pat = $expr - 1;
41+
};
42+
}
43+
44+
let void;
45+
let_expr_minus_one!(no_paren, match void {});
46+
47+
macro_rules! let_expr_else_return {
48+
($pat:pat, $expr:expr) => {
49+
let $pat = $expr else { return; };
50+
};
51+
}
52+
53+
let_expr_else_return!(no_paren, void());
54+
}
55+
56+
fn match_arm() {
57+
macro_rules! match_arm {
58+
($pat:pat, $expr:expr) => {
59+
match () { $pat => $expr }
60+
};
61+
}
62+
63+
match_arm!(no_paren, 1 - 1);
64+
match_arm!(paren_around_brace, { 1 } - 1);
65+
}
66+
67+
fn stmt_semi() {
68+
macro_rules! expr_as_stmt {
69+
($expr:expr) => {
70+
stmt!($expr)
71+
};
72+
}
73+
74+
macro_rules! minus_one {
75+
($expr:expr) => {
76+
expr_as_stmt!($expr - 1)
77+
};
78+
}
79+
80+
let (no_paren, paren_around_match, paren_around_loop);
81+
minus_one!(no_paren);
82+
minus_one!(match paren_around_match {});
83+
minus_one!(match paren_around_match {}());
84+
minus_one!(match paren_around_match {}[0]);
85+
minus_one!(loop { break paren_around_loop; });
86+
}
87+
88+
fn vis_inherited() {
89+
macro_rules! vis_inherited {
90+
($vis:vis struct) => {
91+
$vis struct Struct;
92+
};
93+
}
94+
95+
vis_inherited!(struct);
96+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#![feature(prelude_import)]
2+
#![no_std]
3+
//@ compile-flags: -Zunpretty=expanded
4+
//@ check-pass
5+
6+
#![feature(let_chains)]
7+
#![feature(if_let_guard)]
8+
#[prelude_import]
9+
use ::std::prelude::rust_2015::*;
10+
#[macro_use]
11+
extern crate std;
12+
13+
macro_rules! expr { ($expr:expr) => { $expr }; }
14+
15+
macro_rules! stmt { ($stmt:stmt) => { $stmt }; }
16+
17+
fn if_let() {
18+
macro_rules! if_let {
19+
($pat:pat, $expr:expr) => { if let $pat = $expr {} };
20+
}
21+
22+
if let no_paren = true && false {}
23+
if let paren_around_binary = (true && false) {};
24+
if let no_paren = true {};
25+
26+
struct Struct {}
27+
match () { _ if let no_paren = Struct {} => {} }
28+
}
29+
30+
fn let_else() {
31+
let no_paren = 1 + 1 else { return; };
32+
let paren_around_loop = (loop {}) else { return; };
33+
}
34+
35+
fn local() {
36+
macro_rules! let_expr_minus_one {
37+
($pat:pat, $expr:expr) => { let $pat = $expr - 1; };
38+
}
39+
40+
let void;
41+
let no_paren = match void {} - 1;
42+
43+
macro_rules! let_expr_else_return {
44+
($pat:pat, $expr:expr) => { let $pat = $expr else { return; }; };
45+
}
46+
let
47+
48+
no_paren = void() else { return; };
49+
}
50+
51+
fn match_arm() {
52+
macro_rules! match_arm {
53+
($pat:pat, $expr:expr) => { match () { $pat => $expr } };
54+
}
55+
match () {
56+
57+
58+
no_paren => 1 - 1,
59+
};
60+
match () { paren_around_brace => ({ 1 }) - 1, };
61+
}
62+
63+
fn stmt_semi() {
64+
macro_rules! expr_as_stmt { ($expr:expr) => { stmt!($expr) }; }
65+
66+
macro_rules! minus_one { ($expr:expr) => { expr_as_stmt!($expr - 1) }; }
67+
68+
let (no_paren, paren_around_match, paren_around_loop);
69+
no_paren - 1;
70+
(match paren_around_match {}) - 1;
71+
(match paren_around_match {})() - 1;
72+
(match paren_around_match {})[0] - 1;
73+
(loop { break paren_around_loop; }) - 1;
74+
}
75+
76+
fn vis_inherited() {
77+
macro_rules! vis_inherited {
78+
($vis:vis struct) => { $vis struct Struct; };
79+
}
80+
struct Struct;
81+
82+
}

‎tests/ui/unpretty/let-else.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎tests/ui/unpretty/let-else.stdout

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.