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

Lines changed: 13 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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): {

0 commit comments

Comments
 (0)