diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-10-14 06:02:35 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-14 06:02:35 +0900 |
| commit | 083638cfcf891911458efb4a9d50f66ca7bd1fc5 (patch) | |
| tree | 682416d63ba6c1085eb360d072bb2910aad7501a | |
| parent | 31135e02fac0c7bfbba05b26f6c6b8bda1fa49ad (diff) | |
| parent | 7a23a71e5138531f784ca4118e5136b6664bad55 (diff) | |
| download | rust-083638cfcf891911458efb4a9d50f66ca7bd1fc5.tar.gz rust-083638cfcf891911458efb4a9d50f66ca7bd1fc5.zip | |
Rollup merge of #77886 - LingMan:ast_pretty_bool_matches, r=petrochenkov
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.
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pp.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/compiler/rustc_ast_pretty/src/pp.rs b/compiler/rustc_ast_pretty/src/pp.rs index ba9081bb8a6..95f969d7691 100644 --- a/compiler/rustc_ast_pretty/src/pp.rs +++ b/compiler/rustc_ast_pretty/src/pp.rs @@ -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 })) } } |
