mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 05:13:35 +00:00
minor: New clippy lints
This commit is contained in:
parent
6725e046df
commit
4b6007115a
92 changed files with 180 additions and 201 deletions
|
|
@ -706,7 +706,7 @@ fn path_import_candidate(
|
|||
Some(match qualifier {
|
||||
Some(qualifier) => match sema.resolve_path(&qualifier) {
|
||||
Some(PathResolution::Def(ModuleDef::BuiltinType(_))) | None => {
|
||||
if qualifier.first_qualifier().map_or(true, |it| sema.resolve_path(&it).is_none()) {
|
||||
if qualifier.first_qualifier().is_none_or(|it| sema.resolve_path(&it).is_none()) {
|
||||
let qualifier = qualifier
|
||||
.segments()
|
||||
.map(|seg| seg.name_ref().map(|name| SmolStr::new(name.text())))
|
||||
|
|
|
|||
|
|
@ -72,9 +72,7 @@ impl ImportScope {
|
|||
fn from(syntax: SyntaxNode) -> Option<Self> {
|
||||
use syntax::match_ast;
|
||||
fn contains_cfg_attr(attrs: &dyn HasAttrs) -> bool {
|
||||
attrs
|
||||
.attrs()
|
||||
.any(|attr| attr.as_simple_call().map_or(false, |(ident, _)| ident == "cfg"))
|
||||
attrs.attrs().any(|attr| attr.as_simple_call().is_some_and(|(ident, _)| ident == "cfg"))
|
||||
}
|
||||
match_ast! {
|
||||
match syntax {
|
||||
|
|
@ -102,9 +100,7 @@ impl ImportScope {
|
|||
sema: &Semantics<'_, RootDatabase>,
|
||||
) -> Option<Self> {
|
||||
fn contains_cfg_attr(attrs: &dyn HasAttrs) -> bool {
|
||||
attrs
|
||||
.attrs()
|
||||
.any(|attr| attr.as_simple_call().map_or(false, |(ident, _)| ident == "cfg"))
|
||||
attrs.attrs().any(|attr| attr.as_simple_call().is_some_and(|(ident, _)| ident == "cfg"))
|
||||
}
|
||||
|
||||
// Walk up the ancestor tree searching for a suitable node to do insertions on
|
||||
|
|
@ -487,7 +483,7 @@ fn insert_use_(scope: &ImportScope, use_item: ast::Use, group_imports: bool) {
|
|||
.contains(&token.kind())
|
||||
}
|
||||
})
|
||||
.filter(|child| child.as_token().map_or(true, |t| t.kind() != SyntaxKind::WHITESPACE))
|
||||
.filter(|child| child.as_token().is_none_or(|t| t.kind() != SyntaxKind::WHITESPACE))
|
||||
.last()
|
||||
{
|
||||
cov_mark::hit!(insert_empty_inner_attr);
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ pub fn try_normalize_use_tree_mut(
|
|||
fn recursive_normalize(use_tree: &ast::UseTree, style: NormalizationStyle) -> Option<()> {
|
||||
let use_tree_list = use_tree.use_tree_list()?;
|
||||
let merge_subtree_into_parent_tree = |single_subtree: &ast::UseTree| {
|
||||
let subtree_is_only_self = single_subtree.path().as_ref().map_or(false, path_is_self);
|
||||
let subtree_is_only_self = single_subtree.path().as_ref().is_some_and(path_is_self);
|
||||
|
||||
let merged_path = match (use_tree.path(), single_subtree.path()) {
|
||||
// If the subtree is `{self}` then we cannot merge: `use
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue