mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-30 11:37:31 +00:00
minor: New clippy lints
This commit is contained in:
parent
6725e046df
commit
4b6007115a
92 changed files with 180 additions and 201 deletions
|
|
@ -751,7 +751,7 @@ impl ast::MatchArmList {
|
|||
ted::insert_all(position, elements);
|
||||
|
||||
fn needs_comma(arm: &ast::MatchArm) -> bool {
|
||||
arm.expr().map_or(false, |e| !e.is_block_like()) && arm.comma_token().is_none()
|
||||
arm.expr().is_some_and(|e| !e.is_block_like()) && arm.comma_token().is_none()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ impl ast::BlockExpr {
|
|||
FOR_EXPR | IF_EXPR => parent
|
||||
.children()
|
||||
.find(|it| ast::Expr::can_cast(it.kind()))
|
||||
.map_or(true, |it| it == *self.syntax()),
|
||||
.is_none_or(|it| it == *self.syntax()),
|
||||
LET_ELSE | FN | WHILE_EXPR | LOOP_EXPR | CONST_BLOCK_PAT => false,
|
||||
_ => true,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -819,7 +819,7 @@ pub fn match_arm_with_guard(
|
|||
|
||||
pub fn match_arm_list(arms: impl IntoIterator<Item = ast::MatchArm>) -> ast::MatchArmList {
|
||||
let arms_str = arms.into_iter().fold(String::new(), |mut acc, arm| {
|
||||
let needs_comma = arm.expr().map_or(true, |it| !it.is_block_like());
|
||||
let needs_comma = arm.expr().is_none_or(|it| !it.is_block_like());
|
||||
let comma = if needs_comma { "," } else { "" };
|
||||
let arm = arm.syntax();
|
||||
format_to_acc!(acc, " {arm}{comma}\n")
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ impl ast::Path {
|
|||
|
||||
impl ast::Use {
|
||||
pub fn is_simple_glob(&self) -> bool {
|
||||
self.use_tree().map_or(false, |use_tree| {
|
||||
self.use_tree().is_some_and(|use_tree| {
|
||||
use_tree.use_tree_list().is_none() && use_tree.star_token().is_some()
|
||||
})
|
||||
}
|
||||
|
|
@ -387,7 +387,7 @@ impl ast::UseTreeList {
|
|||
if let Some((single_subtree,)) = u.use_trees().collect_tuple() {
|
||||
// We have a single subtree, check whether it is self.
|
||||
|
||||
let is_self = single_subtree.path().as_ref().map_or(false, |path| {
|
||||
let is_self = single_subtree.path().as_ref().is_some_and(|path| {
|
||||
path.segment().and_then(|seg| seg.self_token()).is_some()
|
||||
&& path.qualifier().is_none()
|
||||
});
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ impl CommentKind {
|
|||
impl ast::Whitespace {
|
||||
pub fn spans_multiple_lines(&self) -> bool {
|
||||
let text = self.text();
|
||||
text.find('\n').map_or(false, |idx| text[idx + 1..].contains('\n'))
|
||||
text.find('\n').is_some_and(|idx| text[idx + 1..].contains('\n'))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue