From 966c23f5290275ce17564f6027a17ec20cd6078f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 17 Mar 2021 01:27:56 +0100 Subject: avoid converting types into themselves via .into() (clippy::useless-conversion) example: let x: String = String::from("hello world").into(); --- crates/hir_ty/src/diagnostics/decl_check.rs | 18 +++++++++--------- crates/hir_ty/src/diagnostics/expr.rs | 18 +++++++++--------- crates/hir_ty/src/diagnostics/unsafe_check.rs | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) (limited to 'crates/hir_ty/src/diagnostics') diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs index 982ad5b9e..bfe239793 100644 --- a/crates/hir_ty/src/diagnostics/decl_check.rs +++ b/crates/hir_ty/src/diagnostics/decl_check.rs @@ -203,7 +203,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { let diagnostic = IncorrectCase { file: fn_src.file_id, ident_type: IdentType::Function, - ident: AstPtr::new(&ast_ptr).into(), + ident: AstPtr::new(&ast_ptr), expected_case: replacement.expected_case, ident_text: replacement.current_name.to_string(), suggested_text: replacement.suggested_text, @@ -261,7 +261,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { let diagnostic = IncorrectCase { file: fn_src.file_id, ident_type: IdentType::Argument, - ident: AstPtr::new(&ast_ptr).into(), + ident: AstPtr::new(&ast_ptr), expected_case: param_to_rename.expected_case, ident_text: param_to_rename.current_name.to_string(), suggested_text: param_to_rename.suggested_text, @@ -313,7 +313,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { let diagnostic = IncorrectCase { file: source_ptr.file_id, ident_type: IdentType::Variable, - ident: AstPtr::new(&name_ast).into(), + ident: AstPtr::new(&name_ast), expected_case: replacement.expected_case, ident_text: replacement.current_name.to_string(), suggested_text: replacement.suggested_text, @@ -403,7 +403,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { let diagnostic = IncorrectCase { file: struct_src.file_id, ident_type: IdentType::Structure, - ident: AstPtr::new(&ast_ptr).into(), + ident: AstPtr::new(&ast_ptr), expected_case: replacement.expected_case, ident_text: replacement.current_name.to_string(), suggested_text: replacement.suggested_text, @@ -448,7 +448,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { let diagnostic = IncorrectCase { file: struct_src.file_id, ident_type: IdentType::Field, - ident: AstPtr::new(&ast_ptr).into(), + ident: AstPtr::new(&ast_ptr), expected_case: field_to_rename.expected_case, ident_text: field_to_rename.current_name.to_string(), suggested_text: field_to_rename.suggested_text, @@ -527,7 +527,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { let diagnostic = IncorrectCase { file: enum_src.file_id, ident_type: IdentType::Enum, - ident: AstPtr::new(&ast_ptr).into(), + ident: AstPtr::new(&ast_ptr), expected_case: replacement.expected_case, ident_text: replacement.current_name.to_string(), suggested_text: replacement.suggested_text, @@ -572,7 +572,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { let diagnostic = IncorrectCase { file: enum_src.file_id, ident_type: IdentType::Variant, - ident: AstPtr::new(&ast_ptr).into(), + ident: AstPtr::new(&ast_ptr), expected_case: variant_to_rename.expected_case, ident_text: variant_to_rename.current_name.to_string(), suggested_text: variant_to_rename.suggested_text, @@ -617,7 +617,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { let diagnostic = IncorrectCase { file: const_src.file_id, ident_type: IdentType::Constant, - ident: AstPtr::new(&ast_ptr).into(), + ident: AstPtr::new(&ast_ptr), expected_case: replacement.expected_case, ident_text: replacement.current_name.to_string(), suggested_text: replacement.suggested_text, @@ -665,7 +665,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { let diagnostic = IncorrectCase { file: static_src.file_id, ident_type: IdentType::StaticVariable, - ident: AstPtr::new(&ast_ptr).into(), + ident: AstPtr::new(&ast_ptr), expected_case: replacement.expected_case, ident_text: replacement.current_name.to_string(), suggested_text: replacement.suggested_text, diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index b2bfd68d4..71b2cade0 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs @@ -44,7 +44,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) { self.check_for_filter_map_next(db); - let body = db.body(self.owner.into()); + let body = db.body(self.owner); for (id, expr) in body.exprs.iter() { if let Some((variant_def, missed_fields, true)) = @@ -98,7 +98,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { missed_fields: Vec, ) { // XXX: only look at source_map if we do have missing fields - let (_, source_map) = db.body_with_source_map(self.owner.into()); + let (_, source_map) = db.body_with_source_map(self.owner); if let Ok(source_ptr) = source_map.expr_syntax(id) { let root = source_ptr.file_syntax(db.upcast()); @@ -128,7 +128,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { missed_fields: Vec, ) { // XXX: only look at source_map if we do have missing fields - let (_, source_map) = db.body_with_source_map(self.owner.into()); + let (_, source_map) = db.body_with_source_map(self.owner); if let Ok(source_ptr) = source_map.pat_syntax(id) { if let Some(expr) = source_ptr.value.as_ref().left() { @@ -175,7 +175,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { }; // Search function body for instances of .filter_map(..).next() - let body = db.body(self.owner.into()); + let body = db.body(self.owner); let mut prev = None; for (id, expr) in body.exprs.iter() { if let Expr::MethodCall { receiver, .. } = expr { @@ -192,7 +192,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { if function_id == *next_function_id { if let Some(filter_map_id) = prev { if *receiver == filter_map_id { - let (_, source_map) = db.body_with_source_map(self.owner.into()); + let (_, source_map) = db.body_with_source_map(self.owner); if let Ok(next_source_ptr) = source_map.expr_syntax(id) { self.sink.push(ReplaceFilterMapNextWithFindMap { file: next_source_ptr.file_id, @@ -262,7 +262,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { let mut arg_count = args.len(); if arg_count != param_count { - let (_, source_map) = db.body_with_source_map(self.owner.into()); + let (_, source_map) = db.body_with_source_map(self.owner); if let Ok(source_ptr) = source_map.expr_syntax(call_id) { if is_method_call { param_count -= 1; @@ -287,7 +287,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { infer: Arc, ) { let (body, source_map): (Arc, Arc) = - db.body_with_source_map(self.owner.into()); + db.body_with_source_map(self.owner); let match_expr_ty = if infer.type_of_expr[match_expr].is_unknown() { return; @@ -393,7 +393,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { }; if params.len() > 0 && params[0] == mismatch.actual { - let (_, source_map) = db.body_with_source_map(self.owner.into()); + let (_, source_map) = db.body_with_source_map(self.owner); if let Ok(source_ptr) = source_map.expr_syntax(id) { self.sink.push(MissingOkOrSomeInTailExpr { @@ -425,7 +425,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { return; } - let (_, source_map) = db.body_with_source_map(self.owner.into()); + let (_, source_map) = db.body_with_source_map(self.owner); if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) { self.sink diff --git a/crates/hir_ty/src/diagnostics/unsafe_check.rs b/crates/hir_ty/src/diagnostics/unsafe_check.rs index 44a7e5506..1f49a4909 100644 --- a/crates/hir_ty/src/diagnostics/unsafe_check.rs +++ b/crates/hir_ty/src/diagnostics/unsafe_check.rs @@ -29,7 +29,7 @@ impl<'a, 'b> UnsafeValidator<'a, 'b> { } pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) { - let def = self.owner.into(); + let def = self.owner; let unsafe_expressions = unsafe_expressions(db, self.infer.as_ref(), def); let is_unsafe = match self.owner { DefWithBodyId::FunctionId(it) => db.function_data(it).qualifier.is_unsafe, -- cgit v1.2.3