diff options
| author | Ralf Jung <post@ralfj.de> | 2023-08-24 14:26:26 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-08-24 14:26:26 +0200 |
| commit | 6f8ae03f9b485c41a3c4fbc1f0d854b30b6e283a (patch) | |
| tree | 82124074f663a3cbce8f7661ed4f0e63d3291444 /compiler/rustc_middle/src | |
| parent | 290ce462526872f4fee675a23011f6fa27960ff0 (diff) | |
make MIR less verbose
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/mir/terminator.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index c4d7f122ea9..7eddf13b3fb 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -119,6 +119,14 @@ impl UnwindTerminateReason { } } + /// A short representation of this used for MIR printing. + pub fn as_short_str(self) -> &'static str { + match self { + UnwindTerminateReason::Abi => "abi", + UnwindTerminateReason::InCleanup => "cleanup", + } + } + pub fn lang_item(self) -> LangItem { match self { UnwindTerminateReason::Abi => LangItem::PanicCannotUnwind, @@ -301,13 +309,14 @@ impl<'tcx> Debug for TerminatorKind<'tcx> { // `Cleanup` is already included in successors let show_unwind = !matches!(self.unwind(), None | Some(UnwindAction::Cleanup(_))); let fmt_unwind = |fmt: &mut Formatter<'_>| -> fmt::Result { + write!(fmt, "unwind ")?; match self.unwind() { // Not needed or included in successors None | Some(UnwindAction::Cleanup(_)) => unreachable!(), - Some(UnwindAction::Continue) => write!(fmt, "unwind continue"), - Some(UnwindAction::Unreachable) => write!(fmt, "unwind unreachable"), + Some(UnwindAction::Continue) => write!(fmt, "continue"), + Some(UnwindAction::Unreachable) => write!(fmt, "unreachable"), Some(UnwindAction::Terminate(reason)) => { - write!(fmt, "unwind terminate ({})", reason.as_str()) + write!(fmt, "terminate({})", reason.as_short_str()) } } }; @@ -350,7 +359,7 @@ impl<'tcx> TerminatorKind<'tcx> { GeneratorDrop => write!(fmt, "generator_drop"), UnwindResume => write!(fmt, "resume"), UnwindTerminate(reason) => { - write!(fmt, "abort(\"{}\")", reason.as_str()) + write!(fmt, "abort({})", reason.as_short_str()) } Yield { value, resume_arg, .. } => write!(fmt, "{resume_arg:?} = yield({value:?})"), Unreachable => write!(fmt, "unreachable"), |
