mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Simlify with matches!()
This commit is contained in:
parent
513924a7e0
commit
e75e2ae5b6
20 changed files with 32 additions and 98 deletions
|
@ -73,10 +73,7 @@ pub(crate) mod fragments {
|
|||
// Parse a meta item , which excluded [], e.g : #[ MetaItem ]
|
||||
pub(crate) fn meta_item(p: &mut Parser) {
|
||||
fn is_delimiter(p: &mut Parser) -> bool {
|
||||
match p.current() {
|
||||
T!['{'] | T!['('] | T!['['] => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(p.current(), T!['{'] | T!['('] | T!['['])
|
||||
}
|
||||
|
||||
if is_delimiter(p) {
|
||||
|
|
|
@ -41,10 +41,7 @@ fn path(p: &mut Parser, mode: Mode) {
|
|||
path_segment(p, mode, true);
|
||||
let mut qual = path.complete(p, PATH);
|
||||
loop {
|
||||
let use_tree = match p.nth(2) {
|
||||
T![*] | T!['{'] => true,
|
||||
_ => false,
|
||||
};
|
||||
let use_tree = matches!(p.nth(2), T![*] | T!['{']);
|
||||
if p.at(T![::]) && !use_tree {
|
||||
let path = qual.precede(p);
|
||||
p.bump(T![::]);
|
||||
|
|
|
@ -169,10 +169,7 @@ fn is_where_predicate(p: &mut Parser) -> bool {
|
|||
}
|
||||
|
||||
fn is_where_clause_end(p: &mut Parser) -> bool {
|
||||
match p.current() {
|
||||
T!['{'] | T![;] | T![=] => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(p.current(), T!['{'] | T![;] | T![=])
|
||||
}
|
||||
|
||||
fn where_predicate(p: &mut Parser) {
|
||||
|
|
|
@ -20,9 +20,6 @@ impl From<SyntaxKind> for u16 {
|
|||
|
||||
impl SyntaxKind {
|
||||
pub fn is_trivia(self) -> bool {
|
||||
match self {
|
||||
SyntaxKind::WHITESPACE | SyntaxKind::COMMENT => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, SyntaxKind::WHITESPACE | SyntaxKind::COMMENT)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue