]> git.lizzy.rs Git - rust.git/commitdiff
Remove unneeded code.
authorJason Newcomb <jsnewcomb@pm.me>
Tue, 9 Mar 2021 15:37:15 +0000 (10:37 -0500)
committerJason Newcomb <jsnewcomb@pm.me>
Sat, 13 Mar 2021 13:39:56 +0000 (08:39 -0500)
clippy_lints/src/dereference.rs
clippy_lints/src/redundant_deref.rs [deleted file]

index a33634ca34ee6c54f9f5a845833c05b42c9d5a9d..6185cf50b358073def9388f7ca00f2ded8f13a7b 100644 (file)
@@ -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 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
         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 (file)
index 0295837..0000000
+++ /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,
-//                 );
-//             }
-//         }
-//     }
-// }