Skip to content

Commit 6ef46b3

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 494f05c + ae5598a commit 6ef46b3

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

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))?

0 commit comments

Comments
 (0)