Skip to content

Commit

Permalink
Rollup merge of rust-lang#77884 - LingMan:ast_pretty_unwrap_or, r=varkor
Browse files Browse the repository at this point in the history
Use Option::unwrap_or instead of open-coding it
  • Loading branch information
JohnTitor authored Oct 13, 2020
2 parents f7c9a7e + 61e722f commit c1e2619
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions compiler/rustc_ast_pretty/src/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,9 @@ impl Printer {
}

fn get_top(&mut self) -> PrintStackElem {
match self.print_stack.last() {
Some(el) => *el,
None => {
PrintStackElem { offset: 0, pbreak: PrintStackBreak::Broken(Breaks::Inconsistent) }
}
}
*self.print_stack.last().unwrap_or({
&PrintStackElem { offset: 0, pbreak: PrintStackBreak::Broken(Breaks::Inconsistent) }
})
}

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

0 comments on commit c1e2619

Please sign in to comment.