mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
more clippy fixes:
clippy::match_like_matches_macro clippy::to_string_in_format_args clippy::single_char_add_str clippy::filter_map_identity clippy::clone_on_copy clippy::useless_format clippy::unused_unit
This commit is contained in:
parent
77790f2b8e
commit
56e4ea59d9
12 changed files with 18 additions and 25 deletions
|
@ -1812,14 +1812,12 @@ impl Macro {
|
|||
|
||||
pub fn is_builtin_derive(&self, db: &dyn HirDatabase) -> bool {
|
||||
match self.id {
|
||||
MacroId::Macro2Id(it) => match it.lookup(db.upcast()).expander {
|
||||
MacroExpander::BuiltInDerive(_) => true,
|
||||
_ => false,
|
||||
},
|
||||
MacroId::MacroRulesId(it) => match it.lookup(db.upcast()).expander {
|
||||
MacroExpander::BuiltInDerive(_) => true,
|
||||
_ => false,
|
||||
},
|
||||
MacroId::Macro2Id(it) => {
|
||||
matches!(it.lookup(db.upcast()).expander, MacroExpander::BuiltInDerive(_))
|
||||
}
|
||||
MacroId::MacroRulesId(it) => {
|
||||
matches!(it.lookup(db.upcast()).expander, MacroExpander::BuiltInDerive(_))
|
||||
}
|
||||
MacroId::ProcMacroId(_) => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -504,10 +504,8 @@ impl DefCollector<'_> {
|
|||
} else {
|
||||
PathKind::Abs
|
||||
};
|
||||
let path = ModPath::from_segments(
|
||||
path_kind.clone(),
|
||||
[krate.clone(), name![prelude], edition].into_iter(),
|
||||
);
|
||||
let path =
|
||||
ModPath::from_segments(path_kind, [krate.clone(), name![prelude], edition].into_iter());
|
||||
// Fall back to the older `std::prelude::v1` for compatibility with Rust <1.52.0
|
||||
// FIXME remove this fallback
|
||||
let fallback_path =
|
||||
|
|
|
@ -120,7 +120,7 @@ impl Path {
|
|||
let res = Path {
|
||||
type_anchor: self.type_anchor.clone(),
|
||||
mod_path: Interned::new(ModPath::from_segments(
|
||||
self.mod_path.kind.clone(),
|
||||
self.mod_path.kind,
|
||||
self.mod_path.segments()[..self.mod_path.segments().len() - 1].iter().cloned(),
|
||||
)),
|
||||
generic_args: self.generic_args[..self.generic_args.len() - 1].to_vec().into(),
|
||||
|
|
|
@ -176,7 +176,7 @@ mod tests {
|
|||
);
|
||||
|
||||
let mut actual = tt.to_string();
|
||||
actual.push_str("\n");
|
||||
actual.push('\n');
|
||||
|
||||
expect.indent(false);
|
||||
expect.assert_eq(&actual);
|
||||
|
|
|
@ -79,7 +79,7 @@ pub(crate) fn annotations(
|
|||
.map(|variant| {
|
||||
variant.source(db).and_then(|node| name_range(db, node, file_id))
|
||||
})
|
||||
.filter_map(std::convert::identity)
|
||||
.flatten()
|
||||
.for_each(|range| {
|
||||
annotations.push(Annotation {
|
||||
range,
|
||||
|
|
|
@ -138,7 +138,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
|
|||
collapse_ws(param_list.syntax(), &mut detail);
|
||||
}
|
||||
if let Some(ret_type) = it.ret_type() {
|
||||
detail.push_str(" ");
|
||||
detail.push(' ');
|
||||
collapse_ws(ret_type.syntax(), &mut detail);
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext)
|
|||
}
|
||||
None => {
|
||||
let offset = strukt.syntax().text_range().end();
|
||||
let snippet = format!("\n\n{}", impl_def.syntax().to_string());
|
||||
let snippet = format!("\n\n{}", impl_def.syntax());
|
||||
builder.insert(offset, snippet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,10 +103,7 @@ fn are_same_types(
|
|||
for (other_arm_type_name, other_arm_type) in arm_types {
|
||||
match (current_arm_types.get(&other_arm_type_name), other_arm_type) {
|
||||
(Some(Some(current_arm_type)), Some(other_arm_type))
|
||||
if other_arm_type.original == current_arm_type.original =>
|
||||
{
|
||||
()
|
||||
}
|
||||
if other_arm_type.original == current_arm_type.original => {}
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
|
|||
|
||||
// => <expr>.field(field)
|
||||
let method_name = make::name_ref("field");
|
||||
let field_path = &format!("{}", name);
|
||||
let field_path = &name.to_string();
|
||||
let field_path = make::expr_path(make::ext::ident_path(field_path));
|
||||
let args = make::arg_list(vec![field_path]);
|
||||
expr = make::expr_method_call(expr, method_name, args);
|
||||
|
|
|
@ -108,7 +108,7 @@ impl FamousDefs<'_, '_> {
|
|||
self.test(),
|
||||
self.proc_macro(),
|
||||
])
|
||||
.filter_map(|it| it)
|
||||
.flatten()
|
||||
}
|
||||
|
||||
fn find_trait(&self, path: &str) -> Option<Trait> {
|
||||
|
|
|
@ -533,7 +533,7 @@ mod bar;
|
|||
|
||||
fn main() {{}}
|
||||
"#,
|
||||
PROJECT = project.to_string(),
|
||||
PROJECT = project,
|
||||
);
|
||||
|
||||
let server =
|
||||
|
|
|
@ -94,7 +94,7 @@ impl TextEdit {
|
|||
|
||||
let text_size = TextSize::of(&*text);
|
||||
let mut total_len = text_size;
|
||||
let mut max_total_len = text_size.clone();
|
||||
let mut max_total_len = text_size;
|
||||
for indel in &self.indels {
|
||||
total_len += TextSize::of(&indel.insert);
|
||||
total_len -= indel.delete.len();
|
||||
|
|
Loading…
Reference in a new issue