forked from rust-lang/rustfmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlet_else_v2.rs
56 lines (45 loc) · 1.71 KB
/
let_else_v2.rs
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
// rustfmt-version: Two
// rustfmt-single_line_let_else_max_width: 100
fn issue5901() {
#[cfg(target_os = "linux")]
let Some(x) = foo else { todo!() };
#[cfg(target_os = "linux")]
// Some comments between attributes and let-else statement
let Some(x) = foo else { todo!() };
#[cfg(target_os = "linux")]
#[cfg(target_arch = "x86_64")]
let Some(x) = foo else { todo!() };
// The else block is multi-lined
#[cfg(target_os = "linux")]
let Some(x) = foo else { return; };
// The else block will be single-lined because attributes and comments before `let`
// are no longer included when calculating max width
#[cfg(target_os = "linux")]
#[cfg(target_arch = "x86_64")]
// Some comments between attributes and let-else statement
let Some(x) = foo else { todo!() };
// Some more test cases for v2 formatting with attributes
#[cfg(target_os = "linux")]
#[cfg(target_arch = "x86_64")]
let Some(x) = opt
// pre else keyword line-comment
else { return; };
#[cfg(target_os = "linux")]
#[cfg(target_arch = "x86_64")]
let Some(x) = opt else
// post else keyword line-comment
{ return; };
#[cfg(target_os = "linux")]
#[cfg(target_arch = "x86_64")]
let Foo {x: Bar(..), y: FooBar(..), z: Baz(..)} = opt else {
return;
};
#[cfg(target_os = "linux")]
#[cfg(target_arch = "x86_64")]
let Some(Ok((Message::ChangeColor(super::color::Color::Rgb(r, g, b)), Point { x, y, z }))) = opt else {
return;
};
#[cfg(target_os = "linux")]
#[cfg(target_arch = "x86_64")]
let Some(x) = very_very_very_very_very_very_very_very_very_very_very_very_long_expression_in_assign_rhs() else { return; };
}