Skip to content

Commit 6f8ae03

Browse files
committed
make MIR less verbose
1 parent 290ce46 commit 6f8ae03

File tree

52 files changed

+99
-90
lines changed

Some content is hidden

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

52 files changed

+99
-90
lines changed

compiler/rustc_middle/src/mir/terminator.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ impl UnwindTerminateReason {
119119
}
120120
}
121121

122+
/// A short representation of this used for MIR printing.
123+
pub fn as_short_str(self) -> &'static str {
124+
match self {
125+
UnwindTerminateReason::Abi => "abi",
126+
UnwindTerminateReason::InCleanup => "cleanup",
127+
}
128+
}
129+
122130
pub fn lang_item(self) -> LangItem {
123131
match self {
124132
UnwindTerminateReason::Abi => LangItem::PanicCannotUnwind,
@@ -301,13 +309,14 @@ impl<'tcx> Debug for TerminatorKind<'tcx> {
301309
// `Cleanup` is already included in successors
302310
let show_unwind = !matches!(self.unwind(), None | Some(UnwindAction::Cleanup(_)));
303311
let fmt_unwind = |fmt: &mut Formatter<'_>| -> fmt::Result {
312+
write!(fmt, "unwind ")?;
304313
match self.unwind() {
305314
// Not needed or included in successors
306315
None | Some(UnwindAction::Cleanup(_)) => unreachable!(),
307-
Some(UnwindAction::Continue) => write!(fmt, "unwind continue"),
308-
Some(UnwindAction::Unreachable) => write!(fmt, "unwind unreachable"),
316+
Some(UnwindAction::Continue) => write!(fmt, "continue"),
317+
Some(UnwindAction::Unreachable) => write!(fmt, "unreachable"),
309318
Some(UnwindAction::Terminate(reason)) => {
310-
write!(fmt, "unwind terminate ({})", reason.as_str())
319+
write!(fmt, "terminate({})", reason.as_short_str())
311320
}
312321
}
313322
};
@@ -350,7 +359,7 @@ impl<'tcx> TerminatorKind<'tcx> {
350359
GeneratorDrop => write!(fmt, "generator_drop"),
351360
UnwindResume => write!(fmt, "resume"),
352361
UnwindTerminate(reason) => {
353-
write!(fmt, "abort(\"{}\")", reason.as_str())
362+
write!(fmt, "abort({})", reason.as_short_str())
354363
}
355364
Yield { value, resume_arg, .. } => write!(fmt, "{resume_arg:?} = yield({value:?})"),
356365
Unreachable => write!(fmt, "unreachable"),

tests/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn main() -> () {
99
bb0: {
1010
StorageLive(_1);
1111
_1 = const ();
12-
asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind terminate (panic in a function that cannot unwind)];
12+
asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind terminate(abi)];
1313
}
1414

1515
bb1: {

tests/mir-opt/basic_assignment.main.ElaborateDrops.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
bb2 (cleanup): {
4949
_5 = move _6;
50-
- drop(_6) -> [return: bb6, unwind terminate (panic in a destructor during cleanup)];
50+
- drop(_6) -> [return: bb6, unwind terminate(cleanup)];
5151
+ goto -> bb6;
5252
}
5353

@@ -71,12 +71,12 @@
7171
}
7272

7373
bb6 (cleanup): {
74-
- drop(_5) -> [return: bb7, unwind terminate (panic in a destructor during cleanup)];
74+
- drop(_5) -> [return: bb7, unwind terminate(cleanup)];
7575
+ goto -> bb7;
7676
}
7777

7878
bb7 (cleanup): {
79-
- drop(_4) -> [return: bb8, unwind terminate (panic in a destructor during cleanup)];
79+
- drop(_4) -> [return: bb8, unwind terminate(cleanup)];
8080
+ goto -> bb8;
8181
}
8282

tests/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn main() -> () {
5151

5252
bb2 (cleanup): {
5353
_5 = move _6;
54-
drop(_6) -> [return: bb6, unwind terminate (panic in a destructor during cleanup)];
54+
drop(_6) -> [return: bb6, unwind terminate(cleanup)];
5555
}
5656

5757
bb3: {
@@ -73,11 +73,11 @@ fn main() -> () {
7373
}
7474

7575
bb6 (cleanup): {
76-
drop(_5) -> [return: bb7, unwind terminate (panic in a destructor during cleanup)];
76+
drop(_5) -> [return: bb7, unwind terminate(cleanup)];
7777
}
7878

7979
bb7 (cleanup): {
80-
drop(_4) -> [return: bb8, unwind terminate (panic in a destructor during cleanup)];
80+
drop(_4) -> [return: bb8, unwind terminate(cleanup)];
8181
}
8282

8383
bb8 (cleanup): {

tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-abort.mir

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ fn main() -> () {
5454
}
5555

5656
bb6 (cleanup): {
57-
drop(_7) -> [return: bb7, unwind terminate (panic in a destructor during cleanup)];
57+
drop(_7) -> [return: bb7, unwind terminate(cleanup)];
5858
}
5959

6060
bb7 (cleanup): {
61-
drop(_1) -> [return: bb9, unwind terminate (panic in a destructor during cleanup)];
61+
drop(_1) -> [return: bb9, unwind terminate(cleanup)];
6262
}
6363

6464
bb8 (cleanup): {
65-
drop(_5) -> [return: bb9, unwind terminate (panic in a destructor during cleanup)];
65+
drop(_5) -> [return: bb9, unwind terminate(cleanup)];
6666
}
6767

6868
bb9 (cleanup): {

tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ fn main() -> () {
5454
}
5555

5656
bb6 (cleanup): {
57-
drop(_7) -> [return: bb7, unwind terminate (panic in a destructor during cleanup)];
57+
drop(_7) -> [return: bb7, unwind terminate(cleanup)];
5858
}
5959

6060
bb7 (cleanup): {
61-
drop(_1) -> [return: bb9, unwind terminate (panic in a destructor during cleanup)];
61+
drop(_1) -> [return: bb9, unwind terminate(cleanup)];
6262
}
6363

6464
bb8 (cleanup): {
65-
drop(_5) -> [return: bb9, unwind terminate (panic in a destructor during cleanup)];
65+
drop(_5) -> [return: bb9, unwind terminate(cleanup)];
6666
}
6767

6868
bb9 (cleanup): {

tests/mir-opt/building/enum_cast.droppy.built.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn droppy() -> () {
6262
}
6363

6464
bb4 (cleanup): {
65-
drop(_2) -> [return: bb5, unwind terminate (panic in a destructor during cleanup)];
65+
drop(_2) -> [return: bb5, unwind terminate(cleanup)];
6666
}
6767

6868
bb5 (cleanup): {

tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ fn move_out_by_subslice() -> () {
8989
}
9090

9191
bb9 (cleanup): {
92-
drop(_1) -> [return: bb12, unwind terminate (panic in a destructor during cleanup)];
92+
drop(_1) -> [return: bb12, unwind terminate(cleanup)];
9393
}
9494

9595
bb10 (cleanup): {
96-
drop(_7) -> [return: bb11, unwind terminate (panic in a destructor during cleanup)];
96+
drop(_7) -> [return: bb11, unwind terminate(cleanup)];
9797
}
9898

9999
bb11 (cleanup): {
100-
drop(_2) -> [return: bb12, unwind terminate (panic in a destructor during cleanup)];
100+
drop(_2) -> [return: bb12, unwind terminate(cleanup)];
101101
}
102102

103103
bb12 (cleanup): {

tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ fn move_out_from_end() -> () {
8989
}
9090

9191
bb9 (cleanup): {
92-
drop(_1) -> [return: bb12, unwind terminate (panic in a destructor during cleanup)];
92+
drop(_1) -> [return: bb12, unwind terminate(cleanup)];
9393
}
9494

9595
bb10 (cleanup): {
96-
drop(_7) -> [return: bb11, unwind terminate (panic in a destructor during cleanup)];
96+
drop(_7) -> [return: bb11, unwind terminate(cleanup)];
9797
}
9898

9999
bb11 (cleanup): {
100-
drop(_2) -> [return: bb12, unwind terminate (panic in a destructor during cleanup)];
100+
drop(_2) -> [return: bb12, unwind terminate(cleanup)];
101101
}
102102

103103
bb12 (cleanup): {

tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
}
6464

6565
bb4 (cleanup): {
66-
drop(_2) -> [return: bb5, unwind terminate (panic in a destructor during cleanup)];
66+
drop(_2) -> [return: bb5, unwind terminate(cleanup)];
6767
}
6868

6969
bb5 (cleanup): {

tests/mir-opt/derefer_inline_test.main.Derefer.panic-abort.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929

3030
bb4 (cleanup): {
31-
drop(_2) -> [return: bb5, unwind terminate (panic in a destructor during cleanup)];
31+
drop(_2) -> [return: bb5, unwind terminate(cleanup)];
3232
}
3333

3434
bb5 (cleanup): {

tests/mir-opt/derefer_inline_test.main.Derefer.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929

3030
bb4 (cleanup): {
31-
drop(_2) -> [return: bb5, unwind terminate (panic in a destructor during cleanup)];
31+
drop(_2) -> [return: bb5, unwind terminate(cleanup)];
3232
}
3333

3434
bb5 (cleanup): {

tests/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ yields ()
104104

105105
bb13 (cleanup): {
106106
StorageDead(_3);
107-
drop(_1) -> [return: bb14, unwind terminate (panic in a destructor during cleanup)];
107+
drop(_1) -> [return: bb14, unwind terminate(cleanup)];
108108
}
109109

110110
bb14 (cleanup): {
@@ -113,6 +113,6 @@ yields ()
113113

114114
bb15 (cleanup): {
115115
StorageDead(_3);
116-
drop(_1) -> [return: bb14, unwind terminate (panic in a destructor during cleanup)];
116+
drop(_1) -> [return: bb14, unwind terminate(cleanup)];
117117
}
118118
}

tests/mir-opt/inline/asm_unwind.main.Inline.panic-abort.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
StorageLive(_1);
1818
- _1 = foo() -> [return: bb1, unwind unreachable];
1919
+ StorageLive(_2);
20-
+ asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind terminate (panic in a function that cannot unwind)];
20+
+ asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind terminate(abi)];
2121
}
2222

2323
bb1: {

tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
+ }
3333
+
3434
+ bb3 (cleanup): {
35-
+ drop(_2) -> [return: bb4, unwind terminate (panic in a destructor during cleanup)];
35+
+ drop(_2) -> [return: bb4, unwind terminate(cleanup)];
3636
+ }
3737
+
3838
+ bb4 (cleanup): {

tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131

3232
bb3 (cleanup): {
33-
drop(_1) -> [return: bb4, unwind terminate (panic in a destructor during cleanup)];
33+
drop(_1) -> [return: bb4, unwind terminate(cleanup)];
3434
}
3535

3636
bb4 (cleanup): {

tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
+ }
3737
+
3838
+ bb3 (cleanup): {
39-
+ drop(_2) -> [return: bb4, unwind terminate (panic in a destructor during cleanup)];
39+
+ drop(_2) -> [return: bb4, unwind terminate(cleanup)];
4040
+ }
4141
+
4242
+ bb4 (cleanup): {

tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
+ }
3737
+
3838
+ bb3 (cleanup): {
39-
+ drop(_2) -> [return: bb4, unwind terminate (panic in a destructor during cleanup)];
39+
+ drop(_2) -> [return: bb4, unwind terminate(cleanup)];
4040
+ }
4141
+
4242
+ bb4 (cleanup): {

tests/mir-opt/inline/dont_ice_on_generic_rust_call.call.Inline.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828

2929
bb3 (cleanup): {
30-
drop(_1) -> [return: bb4, unwind terminate (panic in a destructor during cleanup)];
30+
drop(_1) -> [return: bb4, unwind terminate(cleanup)];
3131
}
3232

3333
bb4 (cleanup): {

tests/mir-opt/inline/inline_box_fn.call.Inline.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131

3232
bb3 (cleanup): {
33-
drop(_1) -> [return: bb4, unwind terminate (panic in a destructor during cleanup)];
33+
drop(_1) -> [return: bb4, unwind terminate(cleanup)];
3434
}
3535

3636
bb4 (cleanup): {

tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@
5454
+ }
5555
+
5656
+ bb4 (cleanup): {
57-
+ drop(_4) -> [return: bb5, unwind terminate (panic in a destructor during cleanup)];
57+
+ drop(_4) -> [return: bb5, unwind terminate(cleanup)];
5858
+ }
5959
+
6060
+ bb5 (cleanup): {
61-
+ drop(_2) -> [return: bb6, unwind terminate (panic in a destructor during cleanup)];
61+
+ drop(_2) -> [return: bb6, unwind terminate(cleanup)];
6262
+ }
6363
+
6464
+ bb6 (cleanup): {

tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
- StorageDead(_1);
156156
- return;
157157
+ bb3 (cleanup): {
158-
+ drop(_2) -> [return: bb2, unwind terminate (panic in a destructor during cleanup)];
158+
+ drop(_2) -> [return: bb2, unwind terminate(cleanup)];
159159
}
160160

161161
- bb4 (cleanup): {

tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838

3939
bb4 (cleanup): {
40-
drop(_1) -> [return: bb5, unwind terminate (panic in a destructor during cleanup)];
40+
drop(_1) -> [return: bb5, unwind terminate(cleanup)];
4141
}
4242

4343
bb5 (cleanup): {

tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
}
4141

4242
bb4 (cleanup): {
43-
drop(_1) -> [return: bb5, unwind terminate (panic in a destructor during cleanup)];
43+
drop(_1) -> [return: bb5, unwind terminate(cleanup)];
4444
}
4545

4646
bb5 (cleanup): {

tests/mir-opt/inline/unsized_argument.caller.Inline.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
bb4 (cleanup): {
4242
_8 = &mut _3;
43-
_9 = <Box<[i32]> as Drop>::drop(move _8) -> [return: bb1, unwind terminate (panic in a destructor during cleanup)];
43+
_9 = <Box<[i32]> as Drop>::drop(move _8) -> [return: bb1, unwind terminate(cleanup)];
4444
}
4545
}
4646

tests/mir-opt/issue_41110.main.ElaborateDrops.panic-abort.diff

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@
4040
}
4141

4242
bb3 (cleanup): {
43-
- drop(_3) -> [return: bb5, unwind terminate (panic in a destructor during cleanup)];
43+
- drop(_3) -> [return: bb5, unwind terminate(cleanup)];
4444
+ goto -> bb5;
4545
}
4646

4747
bb4 (cleanup): {
48-
- drop(_4) -> [return: bb5, unwind terminate (panic in a destructor during cleanup)];
48+
- drop(_4) -> [return: bb5, unwind terminate(cleanup)];
4949
+ goto -> bb5;
5050
}
5151

5252
bb5 (cleanup): {
53-
- drop(_2) -> [return: bb6, unwind terminate (panic in a destructor during cleanup)];
53+
- drop(_2) -> [return: bb6, unwind terminate(cleanup)];
5454
+ goto -> bb8;
5555
}
5656

@@ -59,7 +59,7 @@
5959
+ }
6060
+
6161
+ bb7 (cleanup): {
62-
+ drop(_2) -> [return: bb6, unwind terminate (panic in a destructor during cleanup)];
62+
+ drop(_2) -> [return: bb6, unwind terminate(cleanup)];
6363
+ }
6464
+
6565
+ bb8 (cleanup): {

tests/mir-opt/issue_41110.main.ElaborateDrops.panic-unwind.diff

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@
4040
}
4141

4242
bb3 (cleanup): {
43-
- drop(_3) -> [return: bb5, unwind terminate (panic in a destructor during cleanup)];
43+
- drop(_3) -> [return: bb5, unwind terminate(cleanup)];
4444
+ goto -> bb5;
4545
}
4646

4747
bb4 (cleanup): {
48-
- drop(_4) -> [return: bb5, unwind terminate (panic in a destructor during cleanup)];
48+
- drop(_4) -> [return: bb5, unwind terminate(cleanup)];
4949
+ goto -> bb5;
5050
}
5151

5252
bb5 (cleanup): {
53-
- drop(_2) -> [return: bb6, unwind terminate (panic in a destructor during cleanup)];
53+
- drop(_2) -> [return: bb6, unwind terminate(cleanup)];
5454
+ goto -> bb8;
5555
}
5656

@@ -59,7 +59,7 @@
5959
+ }
6060
+
6161
+ bb7 (cleanup): {
62-
+ drop(_2) -> [return: bb6, unwind terminate (panic in a destructor during cleanup)];
62+
+ drop(_2) -> [return: bb6, unwind terminate(cleanup)];
6363
+ }
6464
+
6565
+ bb8 (cleanup): {

0 commit comments

Comments
 (0)