Some clippy fixes

This commit is contained in:
kjeremy 2019-10-30 13:36:37 -04:00
parent 5806195bc1
commit b441b4e8ef
17 changed files with 23 additions and 29 deletions

View file

@ -95,7 +95,7 @@ impl FnCallNode {
Some(FnCallNode::CallExpr(expr))
} else if let Some(expr) = ast::MethodCallExpr::cast(node.clone()) {
Some(FnCallNode::MethodCallExpr(expr))
} else if let Some(expr) = ast::MacroCall::cast(node.clone()) {
} else if let Some(expr) = ast::MacroCall::cast(node) {
Some(FnCallNode::MacroCallExpr(expr))
} else {
None

View file

@ -43,7 +43,7 @@ impl fmt::Debug for AnalysisChange {
if !self.libraries_added.is_empty() {
d.field("libraries_added", &self.libraries_added.len());
}
if !self.crate_graph.is_some() {
if !self.crate_graph.is_none() {
d.field("crate_graph", &self.crate_graph);
}
d.finish()

View file

@ -67,7 +67,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
});
}
}
_ => return,
_ => {}
};
}

View file

@ -136,7 +136,7 @@ impl Completions {
for (idx, s) in docs.match_indices(&macro_name) {
let (before, after) = (&docs[..idx], &docs[idx + s.len()..]);
// Ensure to match the full word
if after.starts_with("!")
if after.starts_with('!')
&& before
.chars()
.rev()
@ -225,7 +225,7 @@ impl Completions {
} else {
(format!("{}($0)", data.name()), format!("{}(…)", name))
};
builder = builder.lookup_by(name.clone()).label(label).insert_snippet(snippet);
builder = builder.lookup_by(name).label(label).insert_snippet(snippet);
}
self.add(builder)

View file

@ -111,8 +111,7 @@ impl NameDefinition {
if vis.as_str() != "" {
let source_root_id = db.file_source_root(file_id);
let source_root = db.source_root(source_root_id);
let mut res =
source_root.walk().map(|id| (id.into(), None)).collect::<FxHashMap<_, _>>();
let mut res = source_root.walk().map(|id| (id, None)).collect::<FxHashMap<_, _>>();
// FIXME: add "pub(in path)"
@ -128,7 +127,7 @@ impl NameDefinition {
let root_file = crate_graph.crate_root(crate_id);
let source_root_id = db.file_source_root(root_file);
let source_root = db.source_root(source_root_id);
res.extend(source_root.walk().map(|id| (id.into(), None)));
res.extend(source_root.walk().map(|id| (id, None)));
}
}
return SearchScope::new(res);

View file

@ -261,7 +261,7 @@ impl S {
fn type_char(char_typed: char, before: &str, after: &str) {
let (actual, file_change) = do_type_char(char_typed, before)
.expect(&format!("typing `{}` did nothing", char_typed));
.unwrap_or_else(|| panic!("typing `{}` did nothing", char_typed));
if after.contains("<|>") {
let (offset, after) = extract_offset(after);