Skip to content

Commit 6b4ec73

Browse files
committed
Clippy changes
1 parent 21f70a7 commit 6b4ec73

File tree

6 files changed

+22
-27
lines changed

6 files changed

+22
-27
lines changed

crates/ra_assists/src/fill_match_arms.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,24 @@ pub(crate) fn fill_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<As
2323
// We already have some match arms, so we don't provide any assists.
2424
// Unless if there is only one trivial match arm possibly created
2525
// by match postfix complete. Trivial match arm is the catch all arm.
26-
match match_expr.match_arm_list() {
27-
Some(arm_list) => {
28-
let mut arm_iter = arm_list.arms();
29-
let first = arm_iter.next();
30-
31-
match first {
32-
// If there arm list is empty or there is only one trivial arm, then proceed.
33-
Some(arm) if is_trivial_arm(arm) => {
34-
if arm_iter.next() != None {
35-
return None;
36-
}
37-
}
38-
None => {}
39-
40-
_ => {
26+
if let Some(arm_list) = match_expr.match_arm_list() {
27+
let mut arm_iter = arm_list.arms();
28+
let first = arm_iter.next();
29+
30+
match first {
31+
// If there arm list is empty or there is only one trivial arm, then proceed.
32+
Some(arm) if is_trivial_arm(arm) => {
33+
if arm_iter.next() != None {
4134
return None;
4235
}
4336
}
37+
None => {}
38+
39+
_ => {
40+
return None;
41+
}
4442
}
45-
_ => {}
46-
}
43+
};
4744

4845
let expr = match_expr.expr()?;
4946
let analyzer = hir::SourceAnalyzer::new(ctx.db, ctx.frange.file_id, expr.syntax(), None);

crates/ra_assists/src/split_import.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assis
1010
let path = ast::Path::cast(colon_colon.parent())?;
1111
let top_path = successors(Some(path), |it| it.parent_path()).last()?;
1212

13-
let use_tree = top_path.syntax().ancestors().find_map(ast::UseTree::cast);
14-
if use_tree.is_none() {
15-
return None;
16-
}
13+
let _use_tree = top_path.syntax().ancestors().find_map(ast::UseTree::cast)?;
1714

1815
let l_curly = colon_colon.range().end();
1916
let r_curly = match top_path.syntax().parent().and_then(ast::UseTree::cast) {

crates/ra_db/src/input.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ impl CrateGraph {
131131
if self.dfs_find(from, to, &mut FxHashSet::default()) {
132132
return Err(CyclicDependencies);
133133
}
134-
Ok(self.arena.get_mut(&from).unwrap().add_dep(name, to))
134+
self.arena.get_mut(&from).unwrap().add_dep(name, to);
135+
Ok(())
135136
}
136137

137138
pub fn is_empty(&self) -> bool {

crates/ra_hir/src/code_model.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,10 @@ impl Module {
240240
}
241241

242242
pub fn path_to_root(self, db: &impl HirDatabase) -> Vec<Module> {
243-
let mut res = vec![self.clone()];
244-
let mut curr = self.clone();
243+
let mut res = vec![self];
244+
let mut curr = self;
245245
while let Some(next) = curr.parent(db) {
246-
res.push(next.clone());
246+
res.push(next);
247247
curr = next
248248
}
249249
res

crates/ra_hir/src/ty/infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
529529
match matching_def {
530530
Some(_) => {
531531
self.write_assoc_resolution(id, item);
532-
return matching_def;
532+
matching_def
533533
}
534534
None => None,
535535
}

crates/ra_syntax/src/validation/unescape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ where
262262

263263
fn byte_from_char(c: char) -> u8 {
264264
let res = c as u32;
265-
assert!(res <= u8::max_value() as u32, "guaranteed because of Mode::Byte");
265+
assert!(res <= u32::from(u8::max_value()), "guaranteed because of Mode::Byte");
266266
res as u8
267267
}
268268

0 commit comments

Comments
 (0)