Skip to content

Commit c9c80d2

Browse files
committed
rustfmt tests/mir-opt.
The only non-obvious changes: - `building/storage_live_dead_in_statics.rs` has a `#[rustfmt::skip]` attribute to avoid reformating a table of data. - Two `.mir` files have slight changes involving line numbers. - In `unusual_item_types.rs` an `EMIT_MIR` annotation is moved to outside a function, which is the usual spot, because `tidy` complains if such a comment is indented. The commit also tweaks the comments in `rustfmt.toml`.
1 parent ac24299 commit c9c80d2

File tree

66 files changed

+251
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+251
-236
lines changed

rustfmt.toml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@ ignore = [
1010
"/build-*/",
1111
"/vendor/",
1212

13-
# Some tests are not formatted, for multiple reasons:
14-
# - some contain syntax errors that cause rustfmt to give an error
15-
# - some UI tests are broken by different formatting
16-
# - some require special comments in a particular position (e.g. `EMIT_MIR` comments)
13+
# Some tests are not formatted, for various reasons.
1714
"/tests/codegen/simd-intrinsic/", # Many types like `u8x64` are better hand-formatted.
18-
"/tests/crashes/", # Many tests contain syntax errors.
19-
"/tests/debuginfo/", # Tests are somewhat sensitive to source code layout.
20-
"/tests/incremental/", # Tests are somewhat sensitive to source code layout.
21-
"/tests/mir-opt/",
15+
"/tests/crashes/", # Many of these tests contain syntax errors.
16+
"/tests/debuginfo/", # These tests are somewhat sensitive to source code layout.
17+
"/tests/incremental/", # These tests are somewhat sensitive to source code layout.
2218
"/tests/pretty/",
23-
"/tests/run-make/translation/test.rs", # Contains syntax errors.
19+
"/tests/run-make/translation/test.rs", # This test contains syntax errors.
2420
"/tests/run-make-fulldeps/",
2521
"/tests/run-pass-valgrind/",
2622
"/tests/rustdoc/",

tests/mir-opt/address_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn address_of_reborrow() {
99
y as *const [i32; 10];
1010
y as *const dyn Send;
1111
y as *const [i32];
12-
y as *const i32; // This is a cast, not a coercion
12+
y as *const i32; // This is a cast, not a coercion
1313

1414
let p: *const _ = y;
1515
let p: *const [i32; 10] = y;

tests/mir-opt/array_index_is_temporary.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ unsafe fn foo(z: *mut usize) -> u32 {
99
99
1010
}
1111

12-
1312
// EMIT_MIR array_index_is_temporary.main.SimplifyCfg-pre-optimizations.after.mir
1413
fn main() {
1514
// CHECK-LABEL: fn main(

tests/mir-opt/building/custom/debuginfo.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ fn numbered(i: (u32, i32)) {
2727
}
2828
}
2929

30-
struct S { x: f32 }
30+
struct S {
31+
x: f32,
32+
}
3133

3234
// EMIT_MIR debuginfo.structured.built.after.mir
3335
#[custom_mir(dialect = "analysis", phase = "post-cleanup")]

tests/mir-opt/building/enum_cast.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@
55
// EMIT_MIR enum_cast.far.built.after.mir
66

77
enum Foo {
8-
A
8+
A,
99
}
1010

1111
enum Bar {
12-
A, B
12+
A,
13+
B,
1314
}
1415

1516
#[repr(u8)]
1617
enum Boo {
17-
A, B
18+
A,
19+
B,
1820
}
1921

2022
#[repr(i16)]
2123
enum Far {
22-
A, B
24+
A,
25+
B,
2326
}
2427

2528
fn foo(foo: Foo) -> usize {
@@ -40,7 +43,9 @@ fn far(far: Far) -> isize {
4043

4144
// EMIT_MIR enum_cast.droppy.built.after.mir
4245
enum Droppy {
43-
A, B, C
46+
A,
47+
B,
48+
C,
4449
}
4550

4651
impl Drop for Droppy {
@@ -82,12 +87,15 @@ fn unsigny(x: UnsignedAroundZero) -> u16 {
8287
x as u16
8388
}
8489

85-
enum NotStartingAtZero { A = 4, B = 6, C = 8 }
90+
enum NotStartingAtZero {
91+
A = 4,
92+
B = 6,
93+
C = 8,
94+
}
8695

8796
// EMIT_MIR enum_cast.offsetty.built.after.mir
8897
fn offsetty(x: NotStartingAtZero) -> u32 {
8998
x as u32
9099
}
91100

92-
fn main() {
93-
}
101+
fn main() {}

tests/mir-opt/building/logical_or_in_conditional.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ fn test_or() {
3030

3131
// EMIT_MIR logical_or_in_conditional.test_complex.built.after.mir
3232
fn test_complex() {
33-
if let E::A(_) = E::f() && ((always_true() && Droppy(0).0 > 0) || Droppy(1).0 > 1) {}
33+
if let E::A(_) = E::f()
34+
&& ((always_true() && Droppy(0).0 > 0) || Droppy(1).0 > 1)
35+
{}
3436

35-
if !always_true() && let E::B = E::f() {}
37+
if !always_true()
38+
&& let E::B = E::f()
39+
{}
3640
}
3741

3842
fn main() {

tests/mir-opt/building/match/simple_match.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// skip-filecheck
22
// Test that we don't generate unnecessarily large MIR for very simple matches
33

4-
54
// EMIT_MIR simple_match.match_bool.built.after.mir
65
fn match_bool(x: bool) -> usize {
76
match x {

tests/mir-opt/building/shifts.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,12 @@
33

44
// EMIT_MIR shifts.shift_signed.built.after.mir
55
fn shift_signed(small: i8, big: u128, a: i8, b: i32, c: i128) -> ([i8; 3], [u128; 3]) {
6-
(
7-
[small >> a, small >> b, small >> c],
8-
[big << a, big << b, big << c],
9-
)
6+
([small >> a, small >> b, small >> c], [big << a, big << b, big << c])
107
}
118

129
// EMIT_MIR shifts.shift_unsigned.built.after.mir
1310
fn shift_unsigned(small: u8, big: i128, a: u8, b: u32, c: u128) -> ([u8; 3], [i128; 3]) {
14-
(
15-
[small >> a, small >> b, small >> c],
16-
[big << a, big << b, big << c],
17-
)
11+
([small >> a, small >> b, small >> c], [big << a, big << b, big << c])
1812
}
1913

20-
fn main() {
21-
}
14+
fn main() {}

tests/mir-opt/building/storage_live_dead_in_statics.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// generate `StorageStart` or `StorageEnd` statements.
44

55
// EMIT_MIR storage_live_dead_in_statics.XXX.built.after.mir
6+
#[rustfmt::skip]
67
static XXX: &'static Foo = &Foo {
78
tup: "hi",
89
data: &[
@@ -20,13 +21,13 @@ static XXX: &'static Foo = &Foo {
2021
(0, 1), (0, 2), (0, 3),
2122
(0, 1), (0, 2), (0, 3),
2223
(0, 1), (0, 2), (0, 3),
23-
]
24+
],
2425
};
2526

2627
#[derive(Debug)]
2728
struct Foo {
2829
tup: &'static str,
29-
data: &'static [(u32, u32)]
30+
data: &'static [(u32, u32)],
3031
}
3132

3233
fn main() {

tests/mir-opt/const_prop/control_flow_simplification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl<This> NeedsDrop for This {}
1111

1212
// EMIT_MIR control_flow_simplification.hello.GVN.diff
1313
// EMIT_MIR control_flow_simplification.hello.PreCodegen.before.mir
14-
fn hello<T>(){
14+
fn hello<T>() {
1515
if <bool>::NEEDS {
1616
panic!()
1717
}

0 commit comments

Comments
 (0)