mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-23 03:44:23 +00:00
a lot of clippy::style fixes
This commit is contained in:
parent
ae7e55c1dd
commit
202b51bc7b
19 changed files with 52 additions and 69 deletions
|
@ -595,7 +595,7 @@ impl IndentLevel {
|
|||
pub fn from_node(node: &SyntaxNode) -> IndentLevel {
|
||||
match node.first_token() {
|
||||
Some(it) => Self::from_token(&it),
|
||||
None => return IndentLevel(0),
|
||||
None => IndentLevel(0),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,16 +11,16 @@ impl ast::AttrsOwner for ast::Expr {}
|
|||
|
||||
impl ast::Expr {
|
||||
pub fn is_block_like(&self) -> bool {
|
||||
match self {
|
||||
matches!(
|
||||
self,
|
||||
ast::Expr::IfExpr(_)
|
||||
| ast::Expr::LoopExpr(_)
|
||||
| ast::Expr::ForExpr(_)
|
||||
| ast::Expr::WhileExpr(_)
|
||||
| ast::Expr::BlockExpr(_)
|
||||
| ast::Expr::MatchExpr(_)
|
||||
| ast::Expr::EffectExpr(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
| ast::Expr::LoopExpr(_)
|
||||
| ast::Expr::ForExpr(_)
|
||||
| ast::Expr::WhileExpr(_)
|
||||
| ast::Expr::BlockExpr(_)
|
||||
| ast::Expr::MatchExpr(_)
|
||||
| ast::Expr::EffectExpr(_)
|
||||
)
|
||||
}
|
||||
|
||||
pub fn name_ref(&self) -> Option<ast::NameRef> {
|
||||
|
@ -151,20 +151,20 @@ pub enum BinOp {
|
|||
|
||||
impl BinOp {
|
||||
pub fn is_assignment(self) -> bool {
|
||||
match self {
|
||||
matches!(
|
||||
self,
|
||||
BinOp::Assignment
|
||||
| BinOp::AddAssign
|
||||
| BinOp::DivAssign
|
||||
| BinOp::MulAssign
|
||||
| BinOp::RemAssign
|
||||
| BinOp::ShrAssign
|
||||
| BinOp::ShlAssign
|
||||
| BinOp::SubAssign
|
||||
| BinOp::BitOrAssign
|
||||
| BinOp::BitAndAssign
|
||||
| BinOp::BitXorAssign => true,
|
||||
_ => false,
|
||||
}
|
||||
| BinOp::AddAssign
|
||||
| BinOp::DivAssign
|
||||
| BinOp::MulAssign
|
||||
| BinOp::RemAssign
|
||||
| BinOp::ShrAssign
|
||||
| BinOp::ShlAssign
|
||||
| BinOp::SubAssign
|
||||
| BinOp::BitOrAssign
|
||||
| BinOp::BitAndAssign
|
||||
| BinOp::BitXorAssign
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,10 +58,7 @@ impl From<ast::MacroDef> for Macro {
|
|||
|
||||
impl AstNode for Macro {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
SyntaxKind::MACRO_RULES | SyntaxKind::MACRO_DEF => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(kind, SyntaxKind::MACRO_RULES | SyntaxKind::MACRO_DEF)
|
||||
}
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
let res = match syntax.kind() {
|
||||
|
@ -462,10 +459,8 @@ impl ast::FieldExpr {
|
|||
pub fn field_access(&self) -> Option<FieldKind> {
|
||||
if let Some(nr) = self.name_ref() {
|
||||
Some(FieldKind::Name(nr))
|
||||
} else if let Some(tok) = self.index_token() {
|
||||
Some(FieldKind::Index(tok))
|
||||
} else {
|
||||
None
|
||||
self.index_token().map(FieldKind::Index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -482,16 +477,10 @@ impl ast::SlicePat {
|
|||
let prefix = args
|
||||
.peeking_take_while(|p| match p {
|
||||
ast::Pat::RestPat(_) => false,
|
||||
ast::Pat::IdentPat(bp) => match bp.pat() {
|
||||
Some(ast::Pat::RestPat(_)) => false,
|
||||
_ => true,
|
||||
},
|
||||
ast::Pat::IdentPat(bp) => !matches!(bp.pat(), Some(ast::Pat::RestPat(_))),
|
||||
ast::Pat::RefPat(rp) => match rp.pat() {
|
||||
Some(ast::Pat::RestPat(_)) => false,
|
||||
Some(ast::Pat::IdentPat(bp)) => match bp.pat() {
|
||||
Some(ast::Pat::RestPat(_)) => false,
|
||||
_ => true,
|
||||
},
|
||||
Some(ast::Pat::IdentPat(bp)) => !matches!(bp.pat(), Some(ast::Pat::RestPat(_))),
|
||||
_ => true,
|
||||
},
|
||||
_ => true,
|
||||
|
|
|
@ -494,9 +494,8 @@ pub trait HasFormatSpecifier: AstToken {
|
|||
}
|
||||
_ => {
|
||||
while let Some((_, Ok(next_char))) = chars.peek() {
|
||||
match next_char {
|
||||
'{' => break,
|
||||
_ => {}
|
||||
if next_char == &'{' {
|
||||
break;
|
||||
}
|
||||
chars.next();
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ impl CheckReparse {
|
|||
TextRange::at(delete_start.try_into().unwrap(), delete_len.try_into().unwrap());
|
||||
let edited_text =
|
||||
format!("{}{}{}", &text[..delete_start], &insert, &text[delete_start + delete_len..]);
|
||||
let edit = Indel { delete, insert };
|
||||
let edit = Indel { insert, delete };
|
||||
Some(CheckReparse { text, edit, edited_text })
|
||||
}
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ fn validate_path_keywords(segment: ast::PathSegment, errors: &mut Vec<SyntaxErro
|
|||
}
|
||||
};
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
fn all_supers(path: &ast::Path) -> bool {
|
||||
|
@ -314,7 +314,7 @@ fn validate_path_keywords(segment: ast::PathSegment, errors: &mut Vec<SyntaxErro
|
|||
return all_supers(subpath);
|
||||
}
|
||||
|
||||
return true;
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue