mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 05:51:58 +00:00
Simplify a nested bool match
Logically this first eliminates the innermost match by merging the patterns. Then, in a second step, turns the newly innermost match into a `matches!` call.
This commit is contained in:
parent
4ba5068815
commit
fcec76bde4
@ -156,24 +156,13 @@ fn tt_prepend_space(tt: &TokenTree, prev: &TokenTree) -> bool {
|
||||
}
|
||||
}
|
||||
match tt {
|
||||
TokenTree::Token(token) => match token.kind {
|
||||
token::Comma => false,
|
||||
_ => true,
|
||||
},
|
||||
TokenTree::Delimited(_, DelimToken::Paren, _) => match prev {
|
||||
TokenTree::Token(token) => match token.kind {
|
||||
token::Ident(_, _) => false,
|
||||
_ => true,
|
||||
},
|
||||
_ => true,
|
||||
},
|
||||
TokenTree::Delimited(_, DelimToken::Bracket, _) => match prev {
|
||||
TokenTree::Token(token) => match token.kind {
|
||||
token::Pound => false,
|
||||
_ => true,
|
||||
},
|
||||
_ => true,
|
||||
},
|
||||
TokenTree::Token(token) => token.kind != token::Comma,
|
||||
TokenTree::Delimited(_, DelimToken::Paren, _) => {
|
||||
!matches!(prev, TokenTree::Token(Token { kind: token::Ident(..), .. }))
|
||||
}
|
||||
TokenTree::Delimited(_, DelimToken::Bracket, _) => {
|
||||
!matches!(prev, TokenTree::Token(Token { kind: token::Pound, .. }))
|
||||
}
|
||||
TokenTree::Delimited(..) => true,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user