about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/assign_ops.rs2
-rw-r--r--clippy_lints/src/eval_order_dependence.rs6
-rw-r--r--clippy_lints/src/formatting.rs2
-rw-r--r--clippy_lints/src/functions.rs2
-rw-r--r--clippy_lints/src/let_if_seq.rs2
-rw-r--r--clippy_lints/src/loops.rs12
-rw-r--r--clippy_lints/src/misc.rs4
-rw-r--r--clippy_lints/src/misc_early.rs2
-rw-r--r--clippy_lints/src/slow_vector_initialization.rs2
-rw-r--r--clippy_lints/src/strings.rs4
-rw-r--r--clippy_lints/src/swap.rs8
-rw-r--r--clippy_lints/src/temporary_assignment.rs2
-rw-r--r--clippy_lints/src/utils/author.rs7
-rw-r--r--clippy_lints/src/utils/hir_utils.rs4
-rw-r--r--clippy_lints/src/utils/inspector.rs2
-rw-r--r--clippy_lints/src/write.rs2
-rw-r--r--tests/ui/author/for_loop.stdout2
-rw-r--r--tests/ui/missing_const_for_fn/could_be_const.rs2
-rw-r--r--tests/ui/missing_const_for_fn/could_be_const.stderr12
19 files changed, 45 insertions, 34 deletions
diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs
index 29dcffc32b7..1daaa6662bb 100644
--- a/clippy_lints/src/assign_ops.rs
+++ b/clippy_lints/src/assign_ops.rs
@@ -76,7 +76,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
                     }
                 }
             },
-            hir::ExprKind::Assign(assignee, e) => {
+            hir::ExprKind::Assign(assignee, e, _) => {
                 if let hir::ExprKind::Binary(op, l, r) = &e.kind {
                     #[allow(clippy::cognitive_complexity)]
                     let lint = |assignee: &hir::Expr, rhs: &hir::Expr| {
diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs
index 7967d99d104..7bf37f9d479 100644
--- a/clippy_lints/src/eval_order_dependence.rs
+++ b/clippy_lints/src/eval_order_dependence.rs
@@ -62,7 +62,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
         // Find a write to a local variable.
         match expr.kind {
-            ExprKind::Assign(ref lhs, _) | ExprKind::AssignOp(_, ref lhs, _) => {
+            ExprKind::Assign(ref lhs, ..) | ExprKind::AssignOp(_, ref lhs, _) => {
                 if let ExprKind::Path(ref qpath) = lhs.kind {
                     if let QPath::Resolved(_, ref path) = *qpath {
                         if path.segments.len() == 1 {
@@ -224,7 +224,7 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> St
         | ExprKind::Tup(_)
         | ExprKind::MethodCall(..)
         | ExprKind::Call(_, _)
-        | ExprKind::Assign(_, _)
+        | ExprKind::Assign(..)
         | ExprKind::Index(_, _)
         | ExprKind::Repeat(_, _)
         | ExprKind::Struct(_, _, _) => {
@@ -345,7 +345,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
 /// Returns `true` if `expr` is the LHS of an assignment, like `expr = ...`.
 fn is_in_assignment_position(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
     if let Some(parent) = get_parent_expr(cx, expr) {
-        if let ExprKind::Assign(ref lhs, _) = parent.kind {
+        if let ExprKind::Assign(ref lhs, ..) = parent.kind {
             return lhs.hir_id == expr.hir_id;
         }
     }
diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs
index b8f25ea1318..d31b15cba9e 100644
--- a/clippy_lints/src/formatting.rs
+++ b/clippy_lints/src/formatting.rs
@@ -131,7 +131,7 @@ impl EarlyLintPass for Formatting {
 
 /// Implementation of the `SUSPICIOUS_ASSIGNMENT_FORMATTING` lint.
 fn check_assign(cx: &EarlyContext<'_>, expr: &Expr) {
-    if let ExprKind::Assign(ref lhs, ref rhs) = expr.kind {
+    if let ExprKind::Assign(ref lhs, ref rhs, _) = expr.kind {
         if !differing_macro_contexts(lhs.span, rhs.span) && !lhs.span.from_expansion() {
             let eq_span = lhs.span.between(rhs.span);
             if let ExprKind::Unary(op, ref sub_rhs) = rhs.kind {
diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs
index de14f2327db..b0b82d98176 100644
--- a/clippy_lints/src/functions.rs
+++ b/clippy_lints/src/functions.rs
@@ -615,7 +615,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
                     tys.clear();
                 }
             },
-            Assign(ref target, _) | AssignOp(_, ref target, _) | AddrOf(_, hir::Mutability::Mut, ref target) => {
+            Assign(ref target, ..) | AssignOp(_, ref target, _) | AddrOf(_, hir::Mutability::Mut, ref target) => {
                 self.mutates_static |= is_mutated_static(self.cx, target)
             },
             _ => {},
diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs
index a7dae9497db..264982d5e5a 100644
--- a/clippy_lints/src/let_if_seq.rs
+++ b/clippy_lints/src/let_if_seq.rs
@@ -169,7 +169,7 @@ fn check_assign<'a, 'tcx>(
         if block.expr.is_none();
         if let Some(expr) = block.stmts.iter().last();
         if let hir::StmtKind::Semi(ref expr) = expr.kind;
-        if let hir::ExprKind::Assign(ref var, ref value) = expr.kind;
+        if let hir::ExprKind::Assign(ref var, ref value, _) = expr.kind;
         if let hir::ExprKind::Path(ref qpath) = var.kind;
         if let Res::Local(local_id) = qpath_res(cx, qpath, var.hir_id);
         if decl == local_id;
diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs
index 706d102177e..1127edd0896 100644
--- a/clippy_lints/src/loops.rs
+++ b/clippy_lints/src/loops.rs
@@ -682,7 +682,7 @@ fn never_loop_expr(expr: &Expr, main_loop_id: HirId) -> NeverLoopResult {
         },
         ExprKind::Call(ref e, ref es) => never_loop_expr_all(&mut once(&**e).chain(es.iter()), main_loop_id),
         ExprKind::Binary(_, ref e1, ref e2)
-        | ExprKind::Assign(ref e1, ref e2)
+        | ExprKind::Assign(ref e1, ref e2, _)
         | ExprKind::AssignOp(_, ref e1, ref e2)
         | ExprKind::Index(ref e1, ref e2) => never_loop_expr_all(&mut [&**e1, &**e2].iter().cloned(), main_loop_id),
         ExprKind::Loop(ref b, _, _) => {
@@ -887,7 +887,7 @@ fn get_indexed_assignments<'a, 'tcx>(
         e: &Expr,
         var: HirId,
     ) -> Option<(FixedOffsetVar, FixedOffsetVar)> {
-        if let ExprKind::Assign(ref lhs, ref rhs) = e.kind {
+        if let ExprKind::Assign(ref lhs, ref rhs, _) = e.kind {
             match (
                 get_fixed_offset_var(cx, lhs, var),
                 fetch_cloned_fixed_offset_var(cx, rhs, var),
@@ -1861,7 +1861,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
 
         let old = self.prefer_mutable;
         match expr.kind {
-            ExprKind::AssignOp(_, ref lhs, ref rhs) | ExprKind::Assign(ref lhs, ref rhs) => {
+            ExprKind::AssignOp(_, ref lhs, ref rhs) | ExprKind::Assign(ref lhs, ref rhs, _) => {
                 self.prefer_mutable = true;
                 self.visit_expr(lhs);
                 self.prefer_mutable = false;
@@ -2083,7 +2083,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> {
                             }
                         }
                     },
-                    ExprKind::Assign(ref lhs, _) if lhs.hir_id == expr.hir_id => *state = VarState::DontWarn,
+                    ExprKind::Assign(ref lhs, _, _) if lhs.hir_id == expr.hir_id => *state = VarState::DontWarn,
                     ExprKind::AddrOf(BorrowKind::Ref, mutability, _) if mutability == Mutability::Mut => {
                         *state = VarState::DontWarn
                     },
@@ -2161,7 +2161,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
                     ExprKind::AssignOp(_, ref lhs, _) if lhs.hir_id == expr.hir_id => {
                         self.state = VarState::DontWarn;
                     },
-                    ExprKind::Assign(ref lhs, ref rhs) if lhs.hir_id == expr.hir_id => {
+                    ExprKind::Assign(ref lhs, ref rhs, _) if lhs.hir_id == expr.hir_id => {
                         self.state = if is_integer_const(&self.cx, rhs, 0) && self.depth == 0 {
                             VarState::Warn
                         } else {
@@ -2303,7 +2303,7 @@ impl<'tcx> Visitor<'tcx> for LoopNestVisitor {
             return;
         }
         match expr.kind {
-            ExprKind::Assign(ref path, _) | ExprKind::AssignOp(_, ref path, _) => {
+            ExprKind::Assign(ref path, _, _) | ExprKind::AssignOp(_, ref path, _) => {
                 if match_var(path, self.iterator) {
                     self.nesting = RuledOut;
                 }
diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs
index 9c4769fa675..494f04d4bcd 100644
--- a/clippy_lints/src/misc.rs
+++ b/clippy_lints/src/misc.rs
@@ -590,7 +590,9 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
 fn is_used(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
     if let Some(parent) = get_parent_expr(cx, expr) {
         match parent.kind {
-            ExprKind::Assign(_, ref rhs) | ExprKind::AssignOp(_, _, ref rhs) => SpanlessEq::new(cx).eq_expr(rhs, expr),
+            ExprKind::Assign(_, ref rhs, _) | ExprKind::AssignOp(_, _, ref rhs) => {
+                SpanlessEq::new(cx).eq_expr(rhs, expr)
+            },
             _ => is_used(cx, parent),
         }
     } else {
diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs
index 7f70de01daa..f78e3594862 100644
--- a/clippy_lints/src/misc_early.rs
+++ b/clippy_lints/src/misc_early.rs
@@ -451,7 +451,7 @@ impl EarlyLintPass for MiscEarlyLints {
                 if let ExprKind::Closure(..) = t.kind;
                 if let PatKind::Ident(_, ident, _) = local.pat.kind;
                 if let StmtKind::Semi(ref second) = w[1].kind;
-                if let ExprKind::Assign(_, ref call) = second.kind;
+                if let ExprKind::Assign(_, ref call, _) = second.kind;
                 if let ExprKind::Call(ref closure, _) = call.kind;
                 if let ExprKind::Path(_, ref path) = closure.kind;
                 then {
diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs
index 115feefe2e7..093b99e17f1 100644
--- a/clippy_lints/src/slow_vector_initialization.rs
+++ b/clippy_lints/src/slow_vector_initialization.rs
@@ -63,7 +63,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SlowVectorInit {
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
         // Matches initialization on reassignements. For example: `vec = Vec::with_capacity(100)`
         if_chain! {
-            if let ExprKind::Assign(ref left, ref right) = expr.kind;
+            if let ExprKind::Assign(ref left, ref right, _) = expr.kind;
 
             // Extract variable name
             if let ExprKind::Path(QPath::Resolved(_, ref path)) = left.kind;
diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs
index d0f0bd6d94c..7b1be6f8c7c 100644
--- a/clippy_lints/src/strings.rs
+++ b/clippy_lints/src/strings.rs
@@ -96,7 +96,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringAdd {
                 if !is_allowed(cx, STRING_ADD_ASSIGN, e.hir_id) {
                     let parent = get_parent_expr(cx, e);
                     if let Some(p) = parent {
-                        if let ExprKind::Assign(ref target, _) = p.kind {
+                        if let ExprKind::Assign(ref target, _, _) = p.kind {
                             // avoid duplicate matches
                             if SpanlessEq::new(cx).eq_expr(target, left) {
                                 return;
@@ -111,7 +111,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringAdd {
                     "you added something to a string. Consider using `String::push_str()` instead",
                 );
             }
-        } else if let ExprKind::Assign(ref target, ref src) = e.kind {
+        } else if let ExprKind::Assign(ref target, ref src, _) = e.kind {
             if is_string(cx, target) && is_add(cx, src, target) {
                 span_lint(
                     cx,
diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs
index f47945f0a14..58b3f558e9c 100644
--- a/clippy_lints/src/swap.rs
+++ b/clippy_lints/src/swap.rs
@@ -86,11 +86,11 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) {
 
             // foo() = bar();
             if let StmtKind::Semi(ref first) = w[1].kind;
-            if let ExprKind::Assign(ref lhs1, ref rhs1) = first.kind;
+            if let ExprKind::Assign(ref lhs1, ref rhs1, _) = first.kind;
 
             // bar() = t;
             if let StmtKind::Semi(ref second) = w[2].kind;
-            if let ExprKind::Assign(ref lhs2, ref rhs2) = second.kind;
+            if let ExprKind::Assign(ref lhs2, ref rhs2, _) = second.kind;
             if let ExprKind::Path(QPath::Resolved(None, ref rhs2)) = rhs2.kind;
             if rhs2.segments.len() == 1;
 
@@ -222,8 +222,8 @@ fn check_suspicious_swap(cx: &LateContext<'_, '_>, block: &Block) {
             if let StmtKind::Semi(ref first) = w[0].kind;
             if let StmtKind::Semi(ref second) = w[1].kind;
             if !differing_macro_contexts(first.span, second.span);
-            if let ExprKind::Assign(ref lhs0, ref rhs0) = first.kind;
-            if let ExprKind::Assign(ref lhs1, ref rhs1) = second.kind;
+            if let ExprKind::Assign(ref lhs0, ref rhs0, _) = first.kind;
+            if let ExprKind::Assign(ref lhs1, ref rhs1, _) = second.kind;
             if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs0, rhs1);
             if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs1, rhs0);
             then {
diff --git a/clippy_lints/src/temporary_assignment.rs b/clippy_lints/src/temporary_assignment.rs
index 771be56cb70..4b0c4abc44e 100644
--- a/clippy_lints/src/temporary_assignment.rs
+++ b/clippy_lints/src/temporary_assignment.rs
@@ -42,7 +42,7 @@ declare_lint_pass!(TemporaryAssignment => [TEMPORARY_ASSIGNMENT]);
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TemporaryAssignment {
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
-        if let ExprKind::Assign(target, _) = &expr.kind {
+        if let ExprKind::Assign(target, ..) = &expr.kind {
             let mut base = target;
             while let ExprKind::Field(f, _) | ExprKind::Index(f, _) = &base.kind {
                 base = f;
diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs
index 4eb8bceba14..fe3bcfd2cc9 100644
--- a/clippy_lints/src/utils/author.rs
+++ b/clippy_lints/src/utils/author.rs
@@ -380,10 +380,13 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
                 self.current = block_pat;
                 self.visit_block(block);
             },
-            ExprKind::Assign(ref target, ref value) => {
+            ExprKind::Assign(ref target, ref value, _) => {
                 let target_pat = self.next("target");
                 let value_pat = self.next("value");
-                println!("Assign(ref {}, ref {}) = {};", target_pat, value_pat, current);
+                println!(
+                    "Assign(ref {}, ref {}, ref _span) = {};",
+                    target_pat, value_pat, current
+                );
                 self.current = target_pat;
                 self.visit_expr(target);
                 self.current = value_pat;
diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs
index c95287f83d1..a32614c8e07 100644
--- a/clippy_lints/src/utils/hir_utils.rs
+++ b/clippy_lints/src/utils/hir_utils.rs
@@ -84,7 +84,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
             (&ExprKind::Continue(li), &ExprKind::Continue(ri)) => {
                 both(&li.label, &ri.label, |l, r| l.ident.as_str() == r.ident.as_str())
             },
-            (&ExprKind::Assign(ref ll, ref lr), &ExprKind::Assign(ref rl, ref rr)) => {
+            (&ExprKind::Assign(ref ll, ref lr, _), &ExprKind::Assign(ref rl, ref rr, _)) => {
                 self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
             },
             (&ExprKind::AssignOp(ref lo, ref ll, ref lr), &ExprKind::AssignOp(ref ro, ref rl, ref rr)) => {
@@ -412,7 +412,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
                     self.hash_name(i.ident.name);
                 }
             },
-            ExprKind::Assign(ref l, ref r) => {
+            ExprKind::Assign(ref l, ref r, _) => {
                 self.hash_expr(l);
                 self.hash_expr(r);
             },
diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs
index bd8685cc487..ca933c65d6f 100644
--- a/clippy_lints/src/utils/inspector.rs
+++ b/clippy_lints/src/utils/inspector.rs
@@ -229,7 +229,7 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
         hir::ExprKind::Block(_, _) => {
             println!("{}Block", ind);
         },
-        hir::ExprKind::Assign(ref lhs, ref rhs) => {
+        hir::ExprKind::Assign(ref lhs, ref rhs, _) => {
             println!("{}Assign", ind);
             println!("{}lhs:", ind);
             print_expr(cx, lhs, indent + 1);
diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs
index 08e2d59b420..57ccd5ea190 100644
--- a/clippy_lints/src/write.rs
+++ b/clippy_lints/src/write.rs
@@ -395,7 +395,7 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &TokenStream, is_write: bool) -> (O
                 }
                 idx += 1;
             },
-            ExprKind::Assign(lhs, rhs) => {
+            ExprKind::Assign(lhs, rhs, _) => {
                 if let ExprKind::Lit(_) = rhs.kind {
                     if let ExprKind::Path(_, p) = &lhs.kind {
                         let mut all_simple = true;
diff --git a/tests/ui/author/for_loop.stdout b/tests/ui/author/for_loop.stdout
index 557d2894d37..81ede955347 100644
--- a/tests/ui/author/for_loop.stdout
+++ b/tests/ui/author/for_loop.stdout
@@ -26,7 +26,7 @@ if_chain! {
     if let ExprKind::Path(ref path3) = inner.kind;
     if match_qpath(path3, &["iter"]);
     if arms1.len() == 2;
-    if let ExprKind::Assign(ref target, ref value) = arms1[0].body.kind;
+    if let ExprKind::Assign(ref target, ref value, ref _span) = arms1[0].body.kind;
     if let ExprKind::Path(ref path4) = target.kind;
     if match_qpath(path4, &["__next"]);
     if let ExprKind::Path(ref path5) = value.kind;
diff --git a/tests/ui/missing_const_for_fn/could_be_const.rs b/tests/ui/missing_const_for_fn/could_be_const.rs
index 9109d255ca7..a05cc7fee81 100644
--- a/tests/ui/missing_const_for_fn/could_be_const.rs
+++ b/tests/ui/missing_const_for_fn/could_be_const.rs
@@ -41,8 +41,6 @@ fn generic<T>(t: T) -> T {
     t
 }
 
-// FIXME: Depends on the `const_transmute` and `const_fn` feature gates.
-// In the future Clippy should be able to suggest this as const, too.
 fn sub(x: u32) -> usize {
     unsafe { transmute(&x) }
 }
diff --git a/tests/ui/missing_const_for_fn/could_be_const.stderr b/tests/ui/missing_const_for_fn/could_be_const.stderr
index 0c0775764b7..708e7e467b9 100644
--- a/tests/ui/missing_const_for_fn/could_be_const.stderr
+++ b/tests/ui/missing_const_for_fn/could_be_const.stderr
@@ -50,12 +50,20 @@ LL | | }
    | |_^
 
 error: this could be a const_fn
-  --> $DIR/could_be_const.rs:65:9
+  --> $DIR/could_be_const.rs:44:1
+   |
+LL | / fn sub(x: u32) -> usize {
+LL | |     unsafe { transmute(&x) }
+LL | | }
+   | |_^
+
+error: this could be a const_fn
+  --> $DIR/could_be_const.rs:63:9
    |
 LL | /         pub fn b(self, a: &A) -> B {
 LL | |             B
 LL | |         }
    | |_________^
 
-error: aborting due to 7 previous errors
+error: aborting due to 8 previous errors