9668: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-07-21 18:52:49 +00:00 committed by GitHub
commit b7e80d14f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 22 additions and 29 deletions

View file

@ -52,12 +52,12 @@ impl AssistKind {
match self {
AssistKind::None | AssistKind::Generate => true,
AssistKind::Refactor => match other {
AssistKind::Refactor => matches!(
other,
AssistKind::RefactorExtract
| AssistKind::RefactorInline
| AssistKind::RefactorRewrite => true,
_ => false,
},
| AssistKind::RefactorInline
| AssistKind::RefactorRewrite
),
_ => false,
}
}

View file

@ -166,7 +166,7 @@ impl ActiveParameter {
let idx = active_parameter?;
let mut params = signature.params(sema.db);
if !(idx < params.len()) {
if params.len() <= idx {
cov_mark::hit!(too_many_arguments);
return None;
}

View file

@ -153,7 +153,7 @@ impl NameClass {
path_segment.name_ref()
},
PathSegmentKind::Name(name_ref) => Some(name_ref),
_ => return None,
_ => None,
}
})
.and_then(|name_ref| NameRefClass::classify(sema, &name_ref))?;
@ -341,7 +341,7 @@ impl NameRefClass {
hir::AssocItem::TypeAlias(it) => Some(*it),
_ => None,
})
.find(|alias| &alias.name(sema.db).to_string() == &name_ref.text())
.find(|alias| alias.name(sema.db).to_string() == name_ref.text())
{
return Some(NameRefClass::Definition(Definition::ModuleDef(
ModuleDef::TypeAlias(ty),

View file

@ -181,7 +181,7 @@ enum ImportGranularityGuess {
}
/// Insert an import path into the given file/node. A `merge` value of none indicates that no import merging is allowed to occur.
pub fn insert_use<'a>(scope: &ImportScope, path: ast::Path, cfg: &InsertUseConfig) {
pub fn insert_use(scope: &ImportScope, path: ast::Path, cfg: &InsertUseConfig) {
let _p = profile::span("insert_use");
let mut mb = match cfg.granularity {
ImportGranularity::Crate => Some(MergeBehavior::Crate),

View file

@ -162,7 +162,7 @@ fn recursive_merge(
}
Err(_)
if merge == MergeBehavior::Module
&& use_trees.len() > 0
&& !use_trees.is_empty()
&& rhs_t.use_tree_list().is_some() =>
{
return None

View file

@ -3,10 +3,7 @@
//!
//! It can be viewed as a dual for `Change`.
use std::{
collections::hash_map::Entry,
iter::{self, FromIterator},
};
use std::{collections::hash_map::Entry, iter};
use base_db::{AnchoredPathBuf, FileId};
use rustc_hash::FxHashMap;
@ -32,7 +29,7 @@ impl SourceChange {
pub fn from_text_edit(file_id: FileId, edit: TextEdit) -> Self {
SourceChange {
source_file_edits: FxHashMap::from_iter(iter::once((file_id, edit))),
source_file_edits: iter::once((file_id, edit)).collect(),
..Default::default()
}
}

View file

@ -26,7 +26,7 @@ impl TryEnum {
_ => return None,
};
TryEnum::ALL.iter().find_map(|&var| {
if &enum_.name(sema.db).to_string() == var.type_name() {
if enum_.name(sema.db).to_string() == var.type_name() {
return Some(var);
}
None

View file

@ -105,14 +105,12 @@ fn param(p: &mut Parser, m: Marker, flavor: Flavor) -> Variadic {
patterns::pattern(p);
if variadic_param(p) {
res = Variadic(true)
} else if p.at(T![:]) {
types::ascription(p)
} else {
if p.at(T![:]) {
types::ascription(p)
} else {
// test_err missing_fn_param_type
// fn f(x y: i32, z, t: i32) {}
p.error("missing type for function parameter")
}
// test_err missing_fn_param_type
// fn f(x y: i32, z, t: i32) {}
p.error("missing type for function parameter")
}
}
// test value_parameters_no_patterns
@ -131,12 +129,10 @@ fn param(p: &mut Parser, m: Marker, flavor: Flavor) -> Variadic {
patterns::pattern_single(p);
if variadic_param(p) {
res = Variadic(true)
} else if p.at(T![:]) {
types::ascription(p)
} else {
if p.at(T![:]) {
types::ascription(p)
} else {
p.error("missing type for function parameter")
}
p.error("missing type for function parameter")
}
} else {
types::type_(p);

View file

@ -91,7 +91,7 @@ impl ast::Expr {
| ast::Effect::Const(_)
)
}
ast::Expr::ClosureExpr(__) => true,
ast::Expr::ClosureExpr(_) => true,
_ => false,
};
cb(expr);