Skip to content

Commit 7ea7de3

Browse files
bors[bot]kjeremy
andauthored
Merge #2825
2825: Some clippy lints r=matklad a=kjeremy Co-authored-by: kjeremy <[email protected]>
2 parents 27abd4a + c5c5f42 commit 7ea7de3

File tree

9 files changed

+44
-45
lines changed

9 files changed

+44
-45
lines changed

crates/ra_assists/src/assists/add_custom_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use ra_syntax::{
1010
TextRange, TextUnit,
1111
};
1212

13-
const DERIVE_TRAIT: &'static str = "derive";
13+
const DERIVE_TRAIT: &str = "derive";
1414

1515
// Assist: add_custom_impl
1616
//

crates/ra_cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub enum Verbosity {
2222
}
2323

2424
impl Verbosity {
25-
fn is_verbose(&self) -> bool {
25+
fn is_verbose(self) -> bool {
2626
match self {
2727
Verbosity::Verbose => true,
2828
_ => false,

crates/ra_ide/src/call_hierarchy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub(crate) fn outgoing_calls(db: &RootDatabase, position: FilePosition) -> Optio
121121
Some(macro_def.to_nav(db))
122122
}
123123
} {
124-
Some((func_target.clone(), name_ref.value.text_range()))
124+
Some((func_target, name_ref.value.text_range()))
125125
} else {
126126
None
127127
}

crates/ra_ide/src/call_info.rs

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! FIXME: write short doc here
2-
32
use hir::db::AstDatabase;
43
use ra_syntax::{
54
ast::{self, ArgListOwner},
65
match_ast, AstNode, SyntaxNode,
76
};
7+
88
use test_utils::tested_by;
99

1010
use crate::{
@@ -51,36 +51,39 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
5151
// If we have a calling expression let's find which argument we are on
5252
let num_params = call_info.parameters().len();
5353

54-
if num_params == 1 {
55-
if !has_self {
56-
call_info.active_parameter = Some(0);
57-
}
58-
} else if num_params > 1 {
59-
// Count how many parameters into the call we are.
60-
if let Some(arg_list) = calling_node.arg_list() {
61-
// Number of arguments specified at the call site
62-
let num_args_at_callsite = arg_list.args().count();
63-
64-
let arg_list_range = arg_list.syntax().text_range();
65-
if !arg_list_range.contains_inclusive(position.offset) {
66-
tested_by!(call_info_bad_offset);
67-
return None;
54+
match num_params {
55+
0 => (),
56+
1 => {
57+
if !has_self {
58+
call_info.active_parameter = Some(0);
6859
}
60+
}
61+
_ => {
62+
if let Some(arg_list) = calling_node.arg_list() {
63+
// Number of arguments specified at the call site
64+
let num_args_at_callsite = arg_list.args().count();
65+
66+
let arg_list_range = arg_list.syntax().text_range();
67+
if !arg_list_range.contains_inclusive(position.offset) {
68+
tested_by!(call_info_bad_offset);
69+
return None;
70+
}
6971

70-
let mut param = std::cmp::min(
71-
num_args_at_callsite,
72-
arg_list
73-
.args()
74-
.take_while(|arg| arg.syntax().text_range().end() < position.offset)
75-
.count(),
76-
);
77-
78-
// If we are in a method account for `self`
79-
if has_self {
80-
param += 1;
81-
}
72+
let mut param = std::cmp::min(
73+
num_args_at_callsite,
74+
arg_list
75+
.args()
76+
.take_while(|arg| arg.syntax().text_range().end() < position.offset)
77+
.count(),
78+
);
79+
80+
// If we are in a method account for `self`
81+
if has_self {
82+
param += 1;
83+
}
8284

83-
call_info.active_parameter = Some(param);
85+
call_info.active_parameter = Some(param);
86+
}
8487
}
8588
}
8689

crates/ra_ide/src/completion/complete_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
2626
}
2727
if let ScopeDef::Unknown = def {
2828
if let Some(name_ref) = ctx.name_ref_syntax.as_ref() {
29-
if &name_ref.syntax().text() == name.to_string().as_str() {
29+
if name_ref.syntax().text() == name.to_string().as_str() {
3030
// for `use self::foo<|>`, don't suggest `foo` as a completion
3131
tested_by!(dont_complete_current_use);
3232
continue;

crates/ra_ide/src/extend_selection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ mod tests {
339339
let (cursor, before) = extract_offset(before);
340340
let (analysis, file_id) = single_file(&before);
341341
let range = TextRange::offset_len(cursor, 0.into());
342-
let mut frange = FileRange { file_id: file_id, range };
342+
let mut frange = FileRange { file_id, range };
343343

344344
for &after in afters {
345345
frange.range = analysis.extend_selection(frange).unwrap();

crates/ra_ide/src/references.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub(crate) fn find_all_refs(
166166
Some(RangeInfo::new(range, ReferenceSearchResult { declaration, references }))
167167
}
168168

169-
fn find_name<'a>(
169+
fn find_name(
170170
db: &RootDatabase,
171171
syntax: &SyntaxNode,
172172
position: FilePosition,
@@ -253,13 +253,10 @@ fn decl_access(
253253
let stmt = find_node_at_offset::<ast::LetStmt>(syntax, range.start())?;
254254
if let Some(_) = stmt.initializer() {
255255
let pat = stmt.pat()?;
256-
match pat {
257-
ast::Pat::BindPat(it) => {
258-
if it.name()?.text().as_str() == name {
259-
return Some(ReferenceAccess::Write);
260-
}
256+
if let ast::Pat::BindPat(it) = pat {
257+
if it.name()?.text().as_str() == name {
258+
return Some(ReferenceAccess::Write);
261259
}
262-
_ => {}
263260
}
264261
}
265262

@@ -286,7 +283,7 @@ fn reference_access(kind: &NameKind, name_ref: &ast::NameRef) -> Option<Referenc
286283
}
287284
}
288285
}
289-
return Some(ReferenceAccess::Read);
286+
Some(ReferenceAccess::Read)
290287
},
291288
_ => {None}
292289
}

crates/ra_ide/src/references/search_scope.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ impl NameDefinition {
8282
return SearchScope::new(res);
8383
}
8484

85-
let vis =
86-
self.visibility.as_ref().map(|v| v.syntax().to_string()).unwrap_or("".to_string());
85+
let vis = self.visibility.as_ref().map(|v| v.syntax().to_string()).unwrap_or_default();
8786

8887
if vis.as_str() == "pub(super)" {
8988
if let Some(parent_module) = self.container.parent(db) {

crates/ra_syntax/src/ast/expr_extensions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ pub enum BinOp {
127127
}
128128

129129
impl BinOp {
130-
pub fn is_assignment(&self) -> bool {
131-
match *self {
130+
pub fn is_assignment(self) -> bool {
131+
match self {
132132
BinOp::Assignment
133133
| BinOp::AddAssign
134134
| BinOp::DivAssign

0 commit comments

Comments
 (0)