Skip to content

Commit b7e80d1

Browse files
bors[bot]Veykril
andauthored
Merge #9668
9668: minor: Simplify r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents 695f315 + dfdf6fd commit b7e80d1

File tree

9 files changed

+22
-29
lines changed

9 files changed

+22
-29
lines changed

crates/ide_db/src/assists.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ impl AssistKind {
5252

5353
match self {
5454
AssistKind::None | AssistKind::Generate => true,
55-
AssistKind::Refactor => match other {
55+
AssistKind::Refactor => matches!(
56+
other,
5657
AssistKind::RefactorExtract
57-
| AssistKind::RefactorInline
58-
| AssistKind::RefactorRewrite => true,
59-
_ => false,
60-
},
58+
| AssistKind::RefactorInline
59+
| AssistKind::RefactorRewrite
60+
),
6161
_ => false,
6262
}
6363
}

crates/ide_db/src/call_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl ActiveParameter {
166166

167167
let idx = active_parameter?;
168168
let mut params = signature.params(sema.db);
169-
if !(idx < params.len()) {
169+
if params.len() <= idx {
170170
cov_mark::hit!(too_many_arguments);
171171
return None;
172172
}

crates/ide_db/src/defs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl NameClass {
153153
path_segment.name_ref()
154154
},
155155
PathSegmentKind::Name(name_ref) => Some(name_ref),
156-
_ => return None,
156+
_ => None,
157157
}
158158
})
159159
.and_then(|name_ref| NameRefClass::classify(sema, &name_ref))?;
@@ -341,7 +341,7 @@ impl NameRefClass {
341341
hir::AssocItem::TypeAlias(it) => Some(*it),
342342
_ => None,
343343
})
344-
.find(|alias| &alias.name(sema.db).to_string() == &name_ref.text())
344+
.find(|alias| alias.name(sema.db).to_string() == name_ref.text())
345345
{
346346
return Some(NameRefClass::Definition(Definition::ModuleDef(
347347
ModuleDef::TypeAlias(ty),

crates/ide_db/src/helpers/insert_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ enum ImportGranularityGuess {
181181
}
182182

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

crates/ide_db/src/helpers/merge_imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn recursive_merge(
162162
}
163163
Err(_)
164164
if merge == MergeBehavior::Module
165-
&& use_trees.len() > 0
165+
&& !use_trees.is_empty()
166166
&& rhs_t.use_tree_list().is_some() =>
167167
{
168168
return None

crates/ide_db/src/source_change.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
//!
44
//! It can be viewed as a dual for `Change`.
55
6-
use std::{
7-
collections::hash_map::Entry,
8-
iter::{self, FromIterator},
9-
};
6+
use std::{collections::hash_map::Entry, iter};
107

118
use base_db::{AnchoredPathBuf, FileId};
129
use rustc_hash::FxHashMap;
@@ -32,7 +29,7 @@ impl SourceChange {
3229

3330
pub fn from_text_edit(file_id: FileId, edit: TextEdit) -> Self {
3431
SourceChange {
35-
source_file_edits: FxHashMap::from_iter(iter::once((file_id, edit))),
32+
source_file_edits: iter::once((file_id, edit)).collect(),
3633
..Default::default()
3734
}
3835
}

crates/ide_db/src/ty_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl TryEnum {
2626
_ => return None,
2727
};
2828
TryEnum::ALL.iter().find_map(|&var| {
29-
if &enum_.name(sema.db).to_string() == var.type_name() {
29+
if enum_.name(sema.db).to_string() == var.type_name() {
3030
return Some(var);
3131
}
3232
None

crates/parser/src/grammar/params.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,12 @@ fn param(p: &mut Parser, m: Marker, flavor: Flavor) -> Variadic {
105105
patterns::pattern(p);
106106
if variadic_param(p) {
107107
res = Variadic(true)
108+
} else if p.at(T![:]) {
109+
types::ascription(p)
108110
} else {
109-
if p.at(T![:]) {
110-
types::ascription(p)
111-
} else {
112-
// test_err missing_fn_param_type
113-
// fn f(x y: i32, z, t: i32) {}
114-
p.error("missing type for function parameter")
115-
}
111+
// test_err missing_fn_param_type
112+
// fn f(x y: i32, z, t: i32) {}
113+
p.error("missing type for function parameter")
116114
}
117115
}
118116
// test value_parameters_no_patterns
@@ -131,12 +129,10 @@ fn param(p: &mut Parser, m: Marker, flavor: Flavor) -> Variadic {
131129
patterns::pattern_single(p);
132130
if variadic_param(p) {
133131
res = Variadic(true)
132+
} else if p.at(T![:]) {
133+
types::ascription(p)
134134
} else {
135-
if p.at(T![:]) {
136-
types::ascription(p)
137-
} else {
138-
p.error("missing type for function parameter")
139-
}
135+
p.error("missing type for function parameter")
140136
}
141137
} else {
142138
types::type_(p);

crates/syntax/src/ast/node_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl ast::Expr {
9191
| ast::Effect::Const(_)
9292
)
9393
}
94-
ast::Expr::ClosureExpr(__) => true,
94+
ast::Expr::ClosureExpr(_) => true,
9595
_ => false,
9696
};
9797
cb(expr);

0 commit comments

Comments
 (0)