Skip to content

Commit

Permalink
Fix printing of Yield terminator
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Feb 15, 2020
1 parent 61d9231 commit 759526e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1468,21 +1468,23 @@ impl<'tcx> TerminatorKind<'tcx> {
/// successors, which may be rendered differently between the text and the graphviz format.
pub fn fmt_head<W: Write>(&self, fmt: &mut W) -> fmt::Result {
use self::TerminatorKind::*;
match *self {
match self {
Goto { .. } => write!(fmt, "goto"),
SwitchInt { discr: ref place, .. } => write!(fmt, "switchInt({:?})", place),
SwitchInt { discr, .. } => write!(fmt, "switchInt({:?})", discr),
Return => write!(fmt, "return"),
GeneratorDrop => write!(fmt, "generator_drop"),
Resume => write!(fmt, "resume"),
Abort => write!(fmt, "abort"),
Yield { ref value, .. } => write!(fmt, "_1 = suspend({:?})", value),
Yield { value, resume_arg, .. } => {
write!(fmt, "{:?} = suspend({:?})", resume_arg, value)
}
Unreachable => write!(fmt, "unreachable"),
Drop { ref location, .. } => write!(fmt, "drop({:?})", location),
DropAndReplace { ref location, ref value, .. } => {
Drop { location, .. } => write!(fmt, "drop({:?})", location),
DropAndReplace { location, value, .. } => {
write!(fmt, "replace({:?} <- {:?})", location, value)
}
Call { ref func, ref args, ref destination, .. } => {
if let Some((ref destination, _)) = *destination {
Call { func, args, destination, .. } => {
if let Some((destination, _)) = destination {
write!(fmt, "{:?} = ", destination)?;
}
write!(fmt, "{:?}(", func)?;
Expand All @@ -1494,7 +1496,7 @@ impl<'tcx> TerminatorKind<'tcx> {
}
write!(fmt, ")")
}
Assert { ref cond, expected, ref msg, .. } => {
Assert { cond, expected, msg, .. } => {
write!(fmt, "assert(")?;
if !expected {
write!(fmt, "!")?;
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/generator-storage-dead-unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn main() {
// StorageLive(_4);
// _4 = Bar(const 6i32,);
// ...
// _1 = suspend(move _6) -> [resume: bb2, drop: bb4];
// _5 = suspend(move _6) -> [resume: bb2, drop: bb4];
// }
// bb1 (cleanup): {
// resume;
Expand Down

0 comments on commit 759526e

Please sign in to comment.