From 351f3b5a930e16d360f74bbaf8cd10c7b8520fd8 Mon Sep 17 00:00:00 2001 From: Jason Newcomb Date: Tue, 9 Mar 2021 10:37:15 -0500 Subject: [PATCH] Remove unneeded code. --- clippy_lints/src/dereference.rs | 9 +---- clippy_lints/src/redundant_deref.rs | 63 ----------------------------- 2 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 clippy_lints/src/redundant_deref.rs diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index a33634ca34ee..6185cf50b358 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -1,6 +1,4 @@ -use crate::utils::{ - get_node_span, get_parent_node, in_macro, is_allowed, peel_mid_ty_refs, snippet_with_context, span_lint_and_sugg, -}; +use crate::utils::{get_parent_node, in_macro, is_allowed, peel_mid_ty_refs, snippet_with_context, span_lint_and_sugg}; use rustc_ast::util::parser::PREC_PREFIX; use rustc_errors::Applicability; use rustc_hir::{BorrowKind, Destination, Expr, ExprKind, HirId, MatchSource, Mutability, Node, UnOp}; @@ -102,11 +100,6 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing { match (self.state.take(), kind) { (None, kind) => { let parent = get_parent_node(cx.tcx, expr.hir_id); - // This is an odd case. The expression is a macro argument, but the top level - // address of expression is inserted by the compiler. - if matches!(kind, RefOp::AddrOf) && parent.and_then(get_node_span).map_or(false, in_macro) { - return; - } let expr_adjustments = find_adjustments(cx.tcx, typeck, expr); let expr_ty = typeck.expr_ty(expr); diff --git a/clippy_lints/src/redundant_deref.rs b/clippy_lints/src/redundant_deref.rs deleted file mode 100644 index 029583720d2f..000000000000 --- a/clippy_lints/src/redundant_deref.rs +++ /dev/null @@ -1,63 +0,0 @@ -// use crate::utils::{get_parent_expr, snippet_with_applicability, span_lint_and_sugg}; -// use if_chain::if_chain; -// use rustc_errors::Applicability; -// use rustc_hir::{Expr, ExprKind, UnOp}; -// use rustc_lint::{LateContext, LateLintPass, LintContext}; -// use rustc_middle::lint::in_external_macro; -// use rustc_session::{declare_lint_pass, declare_tool_lint}; - -// declare_clippy_lint! { -// /// **What it does:** Checks for uses of the dereference operator which would be covered by -// /// auto-dereferencing. -// /// -// /// **Why is this bad?** This unnecessarily complicates the code. -// /// -// /// **Known problems:** None. -// /// -// /// **Example:** -// /// -// /// ```rust -// /// fn foo(_: &str) {} -// /// foo(&*String::new()) -// /// ``` -// /// Use instead: -// /// ```rust -// /// fn foo(_: &str) {} -// /// foo(&String::new()) -// /// ``` -// pub REDUNDANT_DEREF, -// style, -// "default lint description" -// } - -// declare_lint_pass!(RedundantDeref => [REDUNDANT_DEREF]); - -// impl LateLintPass<'_> for RedundantDeref { -// fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { -// if_chain! { -// if let ExprKind::AddrOf(_, _, addr_expr) = expr.kind; -// if let ExprKind::Unary(UnOp::UnDeref, deref_expr) = addr_expr.kind; -// if !in_external_macro(cx.sess(), expr.span); -// if let Some(parent_expr) = get_parent_expr(cx, expr); -// if match parent_expr.kind { -// ExprKind::Call(func, _) => func.hir_id != expr.hir_id, -// ExprKind::MethodCall(..) => true, -// _ => false, -// }; -// if !cx.typeck_results().expr_ty(deref_expr).is_unsafe_ptr(); -// then { -// let mut app = Applicability::MachineApplicable; -// let sugg = format!("&{}", snippet_with_applicability(cx, deref_expr.span, "_", &mut app)); -// span_lint_and_sugg( -// cx, -// REDUNDANT_DEREF, -// expr.span, -// "redundant dereference", -// "remove the dereference", -// sugg, -// app, -// ); -// } -// } -// } -// }