Skip to content

Commit 31135e0

Browse files
authoredOct 13, 2020
Rollup merge of #77884 - LingMan:ast_pretty_unwrap_or, r=varkor
Use Option::unwrap_or instead of open-coding it
2 parents c824787 + 61e722f commit 31135e0

File tree

1 file changed

+3
-6
lines changed
  • compiler/rustc_ast_pretty/src

1 file changed

+3
-6
lines changed
 

‎compiler/rustc_ast_pretty/src/pp.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -491,12 +491,9 @@ impl Printer {
491491
}
492492

493493
fn get_top(&mut self) -> PrintStackElem {
494-
match self.print_stack.last() {
495-
Some(el) => *el,
496-
None => {
497-
PrintStackElem { offset: 0, pbreak: PrintStackBreak::Broken(Breaks::Inconsistent) }
498-
}
499-
}
494+
*self.print_stack.last().unwrap_or({
495+
&PrintStackElem { offset: 0, pbreak: PrintStackBreak::Broken(Breaks::Inconsistent) }
496+
})
500497
}
501498

502499
fn print_begin(&mut self, b: BeginToken, l: isize) {

0 commit comments

Comments
 (0)
Please sign in to comment.