Skip to content

Commit

Permalink
Rollup merge of #77886 - LingMan:ast_pretty_bool_matches, r=petrochenkov
Browse files Browse the repository at this point in the history
Replace trivial bool matches with the `matches!` macro

This derives `PartialEq` on one enum (and two structs it contains) to enable the `==` operator for it. If there's some downside to this, I could respin with the `matches!` macro instead.
  • Loading branch information
JohnTitor authored Oct 13, 2020
2 parents 31135e0 + 7a23a71 commit 083638c
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions compiler/rustc_ast_pretty/src/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,11 @@ pub enum Token {

impl Token {
crate fn is_eof(&self) -> bool {
match *self {
Token::Eof => true,
_ => false,
}
matches!(self, Token::Eof)
}

pub fn is_hardbreak_tok(&self) -> bool {
match *self {
Token::Break(BreakToken { offset: 0, blank_space: bs }) if bs == SIZE_INFINITY => true,
_ => false,
}
matches!(self, Token::Break(BreakToken { offset: 0, blank_space: SIZE_INFINITY }))
}
}

Expand Down

0 comments on commit 083638c

Please sign in to comment.