mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Add AST pretty-printer tests for let-else
This commit is contained in:
parent
852a78ea8d
commit
68854b798e
@ -675,6 +675,11 @@ fn test_stmt() {
|
||||
"let (a, b): (u32, u32) = (1, 2);",
|
||||
"let (a, b): (u32, u32) = (1, 2)"
|
||||
);
|
||||
c2!(stmt,
|
||||
[ let _ = f() else { return; } ],
|
||||
"let _ = f() else { return; };",
|
||||
"let _ = f() else { return; }",
|
||||
);
|
||||
macro_rules! c2_let_expr_minus_one {
|
||||
([ $expr:expr ], $stmt_expected:expr, $tokens_expected:expr $(,)?) => {
|
||||
c2!(stmt, [ let _ = $expr - 1 ], $stmt_expected, $tokens_expected);
|
||||
@ -685,6 +690,16 @@ fn test_stmt() {
|
||||
"let _ = match void {} - 1;",
|
||||
"let _ = match void {} - 1",
|
||||
);
|
||||
macro_rules! c2_let_expr_else_return {
|
||||
([ $expr:expr ], $stmt_expected:expr, $tokens_expected:expr $(,)?) => {
|
||||
c2!(stmt, [ let _ = $expr else { return; } ], $stmt_expected, $tokens_expected);
|
||||
};
|
||||
}
|
||||
c2_let_expr_else_return!(
|
||||
[ f() ],
|
||||
"let _ = f() else { return; };",
|
||||
"let _ = f() else { return; }",
|
||||
);
|
||||
|
||||
// StmtKind::Item
|
||||
c1!(stmt, [ struct S; ], "struct S;");
|
||||
|
11
tests/ui/unpretty/let-else.rs
Normal file
11
tests/ui/unpretty/let-else.rs
Normal file
@ -0,0 +1,11 @@
|
||||
//@ compile-flags: -Zunpretty=expanded
|
||||
//@ check-pass
|
||||
|
||||
macro_rules! expr {
|
||||
($e:expr) => { $e };
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = expr!(1 + 1) else { return; };
|
||||
let _ = expr!(loop {}) else { return; };
|
||||
}
|
15
tests/ui/unpretty/let-else.stdout
Normal file
15
tests/ui/unpretty/let-else.stdout
Normal file
@ -0,0 +1,15 @@
|
||||
#![feature(prelude_import)]
|
||||
#![no_std]
|
||||
#[prelude_import]
|
||||
use ::std::prelude::rust_2015::*;
|
||||
#[macro_use]
|
||||
extern crate std;
|
||||
//@ compile-flags: -Zunpretty=expanded
|
||||
//@ check-pass
|
||||
|
||||
macro_rules! expr { ($e:expr) => { $e }; }
|
||||
|
||||
fn main() {
|
||||
let _ = 1 + 1 else { return; };
|
||||
let _ = loop {} else { return; };
|
||||
}
|
Loading…
Reference in New Issue
Block a user