Skip to content

Commit 8768db9

Browse files
committed
Auto merge of rust-lang#125912 - nnethercote:rustfmt-tests-mir-opt, r=oli-obk
rustfmt `tests/mir-opt` Continuing the work started in rust-lang#125759. Details in individual commit log messages. r? `@oli-obk`
2 parents 1d52972 + c9c80d2 commit 8768db9

File tree

112 files changed

+630
-563
lines changed

Some content is hidden

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

112 files changed

+630
-563
lines changed

compiler/rustc_mir_transform/src/elaborate_drops.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ use std::fmt;
3434
///
3535
/// ```text
3636
// fn drop_term<T>(t: &mut T) {
37-
// mir!(
37+
// mir! {
3838
// {
3939
// Drop(*t, exit)
4040
// }
4141
// exit = {
4242
// Return()
4343
// }
44-
// )
44+
// }
4545
// }
4646
/// ```
4747
pub struct ElaborateDrops;

library/core/src/intrinsics/mir.rs

+32-26
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//!
2121
//! #[custom_mir(dialect = "built")]
2222
//! pub fn simple(x: i32) -> i32 {
23-
//! mir!(
23+
//! mir! {
2424
//! let temp2: i32;
2525
//!
2626
//! {
@@ -33,7 +33,7 @@
3333
//! RET = temp2;
3434
//! Return()
3535
//! }
36-
//! )
36+
//! }
3737
//! }
3838
//! ```
3939
//!
@@ -71,7 +71,7 @@
7171
//!
7272
//! #[custom_mir(dialect = "built")]
7373
//! pub fn choose_load(a: &i32, b: &i32, c: bool) -> i32 {
74-
//! mir!(
74+
//! mir! {
7575
//! {
7676
//! match c {
7777
//! true => t,
@@ -93,20 +93,22 @@
9393
//! RET = *temp;
9494
//! Return()
9595
//! }
96-
//! )
96+
//! }
9797
//! }
9898
//!
9999
//! #[custom_mir(dialect = "built")]
100100
//! fn unwrap_unchecked<T>(opt: Option<T>) -> T {
101-
//! mir!({
102-
//! RET = Move(Field(Variant(opt, 1), 0));
103-
//! Return()
104-
//! })
101+
//! mir! {
102+
//! {
103+
//! RET = Move(Field(Variant(opt, 1), 0));
104+
//! Return()
105+
//! }
106+
//! }
105107
//! }
106108
//!
107109
//! #[custom_mir(dialect = "runtime", phase = "optimized")]
108110
//! fn push_and_pop<T>(v: &mut Vec<T>, value: T) {
109-
//! mir!(
111+
//! mir! {
110112
//! let _unused;
111113
//! let popped;
112114
//!
@@ -125,19 +127,19 @@
125127
//! ret = {
126128
//! Return()
127129
//! }
128-
//! )
130+
//! }
129131
//! }
130132
//!
131133
//! #[custom_mir(dialect = "runtime", phase = "optimized")]
132134
//! fn annotated_return_type() -> (i32, bool) {
133-
//! mir!(
135+
//! mir! {
134136
//! type RET = (i32, bool);
135137
//! {
136138
//! RET.0 = 1;
137139
//! RET.1 = true;
138140
//! Return()
139141
//! }
140-
//! )
142+
//! }
141143
//! }
142144
//! ```
143145
//!
@@ -152,7 +154,7 @@
152154
//!
153155
//! #[custom_mir(dialect = "built")]
154156
//! fn borrow_error(should_init: bool) -> i32 {
155-
//! mir!(
157+
//! mir! {
156158
//! let temp: i32;
157159
//!
158160
//! {
@@ -171,15 +173,15 @@
171173
//! RET = temp;
172174
//! Return()
173175
//! }
174-
//! )
176+
//! }
175177
//! }
176178
//! ```
177179
//!
178180
//! ```text
179181
//! error[E0381]: used binding is possibly-uninitialized
180182
//! --> test.rs:24:13
181183
//! |
182-
//! 8 | / mir!(
184+
//! 8 | / mir! {
183185
//! 9 | | let temp: i32;
184186
//! 10 | |
185187
//! 11 | | {
@@ -191,7 +193,7 @@
191193
//! | | ^^^^^^^^^^ value used here but it is possibly-uninitialized
192194
//! 25 | | Return()
193195
//! 26 | | }
194-
//! 27 | | )
196+
//! 27 | | }
195197
//! | |_____- binding declared here but left uninitialized
196198
//!
197199
//! error: aborting due to 1 previous error
@@ -407,18 +409,22 @@ define!(
407409
///
408410
/// #[custom_mir(dialect = "built")]
409411
/// fn unwrap_deref(opt: Option<&i32>) -> i32 {
410-
/// mir!({
411-
/// RET = *Field::<&i32>(Variant(opt, 1), 0);
412-
/// Return()
413-
/// })
412+
/// mir! {
413+
/// {
414+
/// RET = *Field::<&i32>(Variant(opt, 1), 0);
415+
/// Return()
416+
/// }
417+
/// }
414418
/// }
415419
///
416420
/// #[custom_mir(dialect = "built")]
417421
/// fn set(opt: &mut Option<i32>) {
418-
/// mir!({
419-
/// place!(Field(Variant(*opt, 1), 0)) = 5;
420-
/// Return()
421-
/// })
422+
/// mir! {
423+
/// {
424+
/// place!(Field(Variant(*opt, 1), 0)) = 5;
425+
/// Return()
426+
/// }
427+
/// }
422428
/// }
423429
/// ```
424430
fn Field<F>(place: (), field: u32) -> F
@@ -455,7 +461,7 @@ define!(
455461
/// your MIR into something that is easier to parse in the compiler.
456462
#[rustc_macro_transparency = "transparent"]
457463
pub macro mir {
458-
(
464+
{
459465
$(type RET = $ret_ty:ty ;)?
460466
$(let $local_decl:ident $(: $local_decl_ty:ty)? ;)*
461467
$(debug $dbg_name:ident => $dbg_data:expr ;)*
@@ -469,7 +475,7 @@ pub macro mir {
469475
$($block:tt)*
470476
}
471477
)*
472-
) => {{
478+
} => {{
473479
// First, we declare all basic blocks.
474480
__internal_declare_basic_blocks!($(
475481
$block_name $(($block_cleanup))?

rustfmt.toml

+5-9
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/",

src/tools/miri/tests/fail/intrinsics/ptr_metadata_uninit_slice_data.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ use std::intrinsics::mir::*;
77

88
#[custom_mir(dialect = "runtime")]
99
pub unsafe fn deref_meta(p: *const *const [i32]) -> usize {
10-
mir!({
11-
RET = PtrMetadata(*p); //~ ERROR: Undefined Behavior: using uninitialized data
12-
Return()
13-
})
10+
mir! {
11+
{
12+
RET = PtrMetadata(*p); //~ ERROR: Undefined Behavior: using uninitialized data
13+
Return()
14+
}
15+
}
1416
}
1517

1618
fn main() {

src/tools/miri/tests/fail/intrinsics/ptr_metadata_uninit_slice_data.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
22
--> $DIR/ptr_metadata_uninit_slice_data.rs:LL:CC
33
|
4-
LL | RET = PtrMetadata(*p);
5-
| ^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
4+
LL | RET = PtrMetadata(*p);
5+
| ^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

src/tools/miri/tests/fail/intrinsics/ptr_metadata_uninit_slice_len.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ use std::intrinsics::mir::*;
77

88
#[custom_mir(dialect = "runtime")]
99
pub unsafe fn deref_meta(p: *const *const [i32]) -> usize {
10-
mir!({
11-
RET = PtrMetadata(*p); //~ ERROR: Undefined Behavior: using uninitialized data
12-
Return()
13-
})
10+
mir! {
11+
{
12+
RET = PtrMetadata(*p); //~ ERROR: Undefined Behavior: using uninitialized data
13+
Return()
14+
}
15+
}
1416
}
1517

1618
fn main() {

src/tools/miri/tests/fail/intrinsics/ptr_metadata_uninit_slice_len.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ LL | (*p.as_mut_ptr().cast::<[*const i32; 2]>())[0] = 4 as *const i32;
1616
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1717
--> $DIR/ptr_metadata_uninit_slice_len.rs:LL:CC
1818
|
19-
LL | RET = PtrMetadata(*p);
20-
| ^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
19+
LL | RET = PtrMetadata(*p);
20+
| ^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
2121
|
2222
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
2323
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

src/tools/miri/tests/fail/intrinsics/ptr_metadata_uninit_thin.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ use std::intrinsics::mir::*;
77

88
#[custom_mir(dialect = "runtime")]
99
pub unsafe fn deref_meta(p: *const *const i32) -> () {
10-
mir!({
11-
RET = PtrMetadata(*p); //~ ERROR: Undefined Behavior: using uninitialized data
12-
Return()
13-
})
10+
mir! {
11+
{
12+
RET = PtrMetadata(*p); //~ ERROR: Undefined Behavior: using uninitialized data
13+
Return()
14+
}
15+
}
1416
}
1517

1618
fn main() {

src/tools/miri/tests/fail/intrinsics/ptr_metadata_uninit_thin.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
22
--> $DIR/ptr_metadata_uninit_thin.rs:LL:CC
33
|
4-
LL | RET = PtrMetadata(*p);
5-
| ^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
4+
LL | RET = PtrMetadata(*p);
5+
| ^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/mir-opt/address_of.rs

+1-1
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

-1
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/aggregate_exprs.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ use core::intrinsics::mir::*;
77
// EMIT_MIR aggregate_exprs.tuple.built.after.mir
88
#[custom_mir(dialect = "built")]
99
fn tuple() -> (i32, bool) {
10-
mir!(
10+
mir! {
1111
{
1212
RET = (1, true);
1313
Return()
1414
}
15-
)
15+
}
1616
}
1717

1818
// EMIT_MIR aggregate_exprs.array.built.after.mir
1919
#[custom_mir(dialect = "built")]
2020
fn array() -> [i32; 2] {
21-
mir!(
21+
mir! {
2222
let x: [i32; 2];
2323
let one: i32;
2424
{
@@ -28,7 +28,7 @@ fn array() -> [i32; 2] {
2828
RET = Move(x);
2929
Return()
3030
}
31-
)
31+
}
3232
}
3333

3434
struct Foo {
@@ -48,7 +48,7 @@ union Onion {
4848
// EMIT_MIR aggregate_exprs.adt.built.after.mir
4949
#[custom_mir(dialect = "built")]
5050
fn adt() -> Onion {
51-
mir!(
51+
mir! {
5252
let one: i32;
5353
let x: Foo;
5454
let y: Bar;
@@ -62,7 +62,7 @@ fn adt() -> Onion {
6262
RET = Onion { neon: Field(Variant(y, 0), 1) };
6363
Return()
6464
}
65-
)
65+
}
6666
}
6767

6868
fn main() {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use core::ptr::{addr_of, addr_of_mut};
88
// EMIT_MIR arbitrary_let.arbitrary_let.built.after.mir
99
#[custom_mir(dialect = "built")]
1010
fn arbitrary_let(x: i32) -> i32 {
11-
mir!(
11+
mir! {
1212
{
1313
let y = x;
1414
Goto(second)
@@ -21,7 +21,7 @@ fn arbitrary_let(x: i32) -> i32 {
2121
let z = y;
2222
Goto(third)
2323
}
24-
)
24+
}
2525
}
2626

2727
fn main() {

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

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ use core::intrinsics::mir::*;
77
// EMIT_MIR arrays.arrays.built.after.mir
88
#[custom_mir(dialect = "built")]
99
fn arrays<const C: usize>() -> usize {
10-
mir!({
11-
let x = [5_i32; C];
12-
let c = Len(x);
13-
RET = c;
14-
Return()
15-
})
10+
mir! {
11+
{
12+
let x = [5_i32; C];
13+
let c = Len(x);
14+
RET = c;
15+
Return()
16+
}
17+
}
1618
}
1719

1820
fn main() {

0 commit comments

Comments
 (0)