mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
fix clippy::useless_conversion
This commit is contained in:
parent
451fcd3c79
commit
62ed658311
11 changed files with 25 additions and 29 deletions
|
@ -82,8 +82,8 @@ impl From<GenericParam> for GenericParamId {
|
|||
fn from(id: GenericParam) -> Self {
|
||||
match id {
|
||||
GenericParam::LifetimeParam(it) => GenericParamId::LifetimeParamId(it.id),
|
||||
GenericParam::ConstParam(it) => GenericParamId::ConstParamId(it.id.into()),
|
||||
GenericParam::TypeParam(it) => GenericParamId::TypeParamId(it.id.into()),
|
||||
GenericParam::ConstParam(it) => GenericParamId::ConstParamId(it.id),
|
||||
GenericParam::TypeParam(it) => GenericParamId::TypeParamId(it.id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -570,7 +570,7 @@ impl DefCollector<'_> {
|
|||
|
||||
let proc_macro_id =
|
||||
ProcMacroLoc { container: module_id, id, expander, kind }.intern(self.db);
|
||||
self.define_proc_macro(def.name.clone(), proc_macro_id.into());
|
||||
self.define_proc_macro(def.name.clone(), proc_macro_id);
|
||||
if let ProcMacroKind::CustomDerive { helpers } = def.kind {
|
||||
self.def_map
|
||||
.exported_derives
|
||||
|
|
|
@ -146,7 +146,7 @@ pub fn expand_eager_macro(
|
|||
if let MacroDefKind::BuiltInEager(eager, _) = def.kind {
|
||||
let res = eager.expand(db, arg_id, &subtree);
|
||||
if let Some(err) = res.err {
|
||||
diagnostic_sink(err.into());
|
||||
diagnostic_sink(err);
|
||||
}
|
||||
|
||||
let loc = MacroCallLoc {
|
||||
|
|
|
@ -1059,7 +1059,7 @@ pub(crate) fn generic_predicates_for_param_query(
|
|||
| WherePredicate::TypeBound { target, bound, .. } => {
|
||||
match target {
|
||||
WherePredicateTypeTarget::TypeRef(type_ref) => {
|
||||
if ctx.lower_ty_only_param(type_ref) != Some(param_id.into()) {
|
||||
if ctx.lower_ty_only_param(type_ref) != Some(param_id) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1518,7 +1518,7 @@ fn make_body(
|
|||
make::expr_path(make::path_from_text("ControlFlow::Continue")),
|
||||
make::arg_list(iter::once(make::expr_unit())),
|
||||
);
|
||||
with_tail_expr(block, controlflow_continue.into())
|
||||
with_tail_expr(block, controlflow_continue)
|
||||
}
|
||||
FlowHandler::IfOption { .. } => {
|
||||
let none = make::expr_path(make::ext::ident_path("None"));
|
||||
|
|
|
@ -267,7 +267,7 @@ impl Module {
|
|||
match (item.syntax()) {
|
||||
ast::Adt(it) => {
|
||||
if let Some( nod ) = ctx.sema.to_def(&it) {
|
||||
let node_def = Definition::Adt(nod.into());
|
||||
let node_def = Definition::Adt(nod);
|
||||
self.expand_and_group_usages_file_wise(ctx, node_def, &mut refs);
|
||||
|
||||
//Enum Fields are not allowed to explicitly specify pub, it is implied
|
||||
|
@ -301,25 +301,25 @@ impl Module {
|
|||
},
|
||||
ast::TypeAlias(it) => {
|
||||
if let Some( nod ) = ctx.sema.to_def(&it) {
|
||||
let node_def = Definition::TypeAlias(nod.into());
|
||||
let node_def = Definition::TypeAlias(nod);
|
||||
self.expand_and_group_usages_file_wise(ctx, node_def, &mut refs);
|
||||
}
|
||||
},
|
||||
ast::Const(it) => {
|
||||
if let Some( nod ) = ctx.sema.to_def(&it) {
|
||||
let node_def = Definition::Const(nod.into());
|
||||
let node_def = Definition::Const(nod);
|
||||
self.expand_and_group_usages_file_wise(ctx, node_def, &mut refs);
|
||||
}
|
||||
},
|
||||
ast::Static(it) => {
|
||||
if let Some( nod ) = ctx.sema.to_def(&it) {
|
||||
let node_def = Definition::Static(nod.into());
|
||||
let node_def = Definition::Static(nod);
|
||||
self.expand_and_group_usages_file_wise(ctx, node_def, &mut refs);
|
||||
}
|
||||
},
|
||||
ast::Fn(it) => {
|
||||
if let Some( nod ) = ctx.sema.to_def(&it) {
|
||||
let node_def = Definition::Function(nod.into());
|
||||
let node_def = Definition::Function(nod);
|
||||
self.expand_and_group_usages_file_wise(ctx, node_def, &mut refs);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -86,7 +86,7 @@ fn gen_clone_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
|
|||
None => {
|
||||
let pattern = make::path_pat(variant_name.clone());
|
||||
let variant_expr = make::expr_path(variant_name);
|
||||
arms.push(make::match_arm(Some(pattern.into()), None, variant_expr));
|
||||
arms.push(make::match_arm(Some(pattern), None, variant_expr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ fn gen_clone_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
|
|||
let mut fields = vec![];
|
||||
for (i, _) in field_list.fields().enumerate() {
|
||||
let f_path = make::expr_path(make::ext::ident_path("self"));
|
||||
let target = make::expr_field(f_path, &format!("{}", i)).into();
|
||||
let target = make::expr_field(f_path, &format!("{}", i));
|
||||
fields.push(gen_clone_call(target));
|
||||
}
|
||||
let struct_name = make::expr_path(make::ext::ident_path("Self"));
|
||||
|
@ -151,7 +151,7 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
|
|||
for variant in list.variants() {
|
||||
let name = variant.name()?;
|
||||
let variant_name = make::ext::path_from_idents(["Self", &format!("{}", name)])?;
|
||||
let target = make::expr_path(make::ext::ident_path("f").into());
|
||||
let target = make::expr_path(make::ext::ident_path("f"));
|
||||
|
||||
match variant.field_list() {
|
||||
Some(ast::FieldList::RecordFieldList(list)) => {
|
||||
|
@ -227,11 +227,7 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
|
|||
let macro_call = make::expr_macro_call(macro_name, args);
|
||||
|
||||
let variant_name = make::path_pat(variant_name);
|
||||
arms.push(make::match_arm(
|
||||
Some(variant_name.into()),
|
||||
None,
|
||||
macro_call.into(),
|
||||
));
|
||||
arms.push(make::match_arm(Some(variant_name), None, macro_call));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +260,7 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
|
|||
let f_name = make::expr_literal(&(format!("\"{}\"", name))).into();
|
||||
let f_path = make::expr_path(make::ext::ident_path("self"));
|
||||
let f_path = make::expr_ref(f_path, false);
|
||||
let f_path = make::expr_field(f_path, &format!("{}", name)).into();
|
||||
let f_path = make::expr_field(f_path, &format!("{}", name));
|
||||
let args = make::arg_list([f_name, f_path]);
|
||||
expr = make::expr_method_call(expr, make::name_ref("field"), args);
|
||||
}
|
||||
|
@ -278,7 +274,7 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
|
|||
for (i, _) in field_list.fields().enumerate() {
|
||||
let f_path = make::expr_path(make::ext::ident_path("self"));
|
||||
let f_path = make::expr_ref(f_path, false);
|
||||
let f_path = make::expr_field(f_path, &format!("{}", i)).into();
|
||||
let f_path = make::expr_field(f_path, &format!("{}", i));
|
||||
let method = make::name_ref("field");
|
||||
expr = make::expr_method_call(expr, method, make::arg_list(Some(f_path)));
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use std::collections::VecDeque;
|
||||
|
||||
use base_db::FileId;
|
||||
use hir::{ItemInNs, Macro, ModuleDef, Name, Semantics};
|
||||
use hir::{ItemInNs, ModuleDef, Name, Semantics};
|
||||
use syntax::{
|
||||
ast::{self, make},
|
||||
AstToken, SyntaxKind, SyntaxToken, TokenAtOffset,
|
||||
|
@ -13,9 +13,9 @@ use crate::{defs::Definition, generated, RootDatabase};
|
|||
|
||||
pub fn item_name(db: &RootDatabase, item: ItemInNs) -> Option<Name> {
|
||||
match item {
|
||||
ItemInNs::Types(module_def_id) => ModuleDef::from(module_def_id).name(db),
|
||||
ItemInNs::Values(module_def_id) => ModuleDef::from(module_def_id).name(db),
|
||||
ItemInNs::Macros(macro_def_id) => Some(Macro::from(macro_def_id).name(db)),
|
||||
ItemInNs::Types(module_def_id) => module_def_id.name(db),
|
||||
ItemInNs::Values(module_def_id) => module_def_id.name(db),
|
||||
ItemInNs::Macros(macro_def_id) => Some(macro_def_id.name(db)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -430,8 +430,8 @@ fn module_with_segment_name(
|
|||
candidate: ItemInNs,
|
||||
) -> Option<Module> {
|
||||
let mut current_module = match candidate {
|
||||
ItemInNs::Types(module_def_id) => ModuleDef::from(module_def_id).module(db),
|
||||
ItemInNs::Values(module_def_id) => ModuleDef::from(module_def_id).module(db),
|
||||
ItemInNs::Types(module_def_id) => module_def_id.module(db),
|
||||
ItemInNs::Values(module_def_id) => module_def_id.module(db),
|
||||
ItemInNs::Macros(macro_def_id) => ModuleDef::from(macro_def_id).module(db),
|
||||
};
|
||||
while let Some(module) = current_module {
|
||||
|
|
|
@ -115,7 +115,7 @@ fn find_items<'a>(
|
|||
});
|
||||
|
||||
// Query the local crate using the symbol index.
|
||||
let local_results = symbol_index::crate_symbols(db, krate.into(), local_query)
|
||||
let local_results = symbol_index::crate_symbols(db, krate, local_query)
|
||||
.into_iter()
|
||||
.filter_map(move |local_candidate| get_name_definition(sema, &local_candidate))
|
||||
.filter_map(|name_definition_to_import| match name_definition_to_import {
|
||||
|
|
|
@ -101,7 +101,7 @@ impl TextEdit {
|
|||
max_total_len = max(max_total_len, total_len);
|
||||
}
|
||||
|
||||
if let Some(additional) = max_total_len.checked_sub(text_size.into()) {
|
||||
if let Some(additional) = max_total_len.checked_sub(text_size) {
|
||||
text.reserve(additional.into());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue