]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/mixed_read_write_in_expression.rs
Rollup merge of #101498 - petrochenkov:visparam, r=cjgillot
[rust.git] / clippy_lints / src / mixed_read_write_in_expression.rs
index 024bd0760715e449fffa03f4bcb77f2cae98a79b..a2419c277e9c27d2b270961e6c860c99f306ffe3 100644 (file)
     /// ```rust
     /// let mut x = 0;
     ///
-    /// // Bad
     /// let a = {
     ///     x = 1;
     ///     1
     /// } + x;
     /// // Unclear whether a is 1 or 2.
+    /// ```
     ///
-    /// // Good
+    /// Use instead:
+    /// ```rust
+    /// # let mut x = 0;
     /// let tmp = {
     ///     x = 1;
     ///     1
@@ -112,7 +114,7 @@ struct DivergenceVisitor<'a, 'tcx> {
 impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
     fn maybe_walk_expr(&mut self, e: &'tcx Expr<'_>) {
         match e.kind {
-            ExprKind::Closure(..) => {},
+            ExprKind::Closure { .. } => {},
             ExprKind::Match(e, arms, _) => {
                 self.visit_expr(e);
                 for arm in arms {
@@ -243,7 +245,7 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr<'_>) -
                 walk_expr(vis, expr);
             }
         },
-        ExprKind::Closure(_, _, _, _, _) => {
+        ExprKind::Closure { .. } => {
             // Either
             //
             // * `var` is defined in the closure body, in which case we've reached the top of the enclosing
@@ -315,7 +317,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
             // We're about to descend a closure. Since we don't know when (or
             // if) the closure will be evaluated, any reads in it might not
             // occur here (or ever). Like above, bail to avoid false positives.
-            ExprKind::Closure(_, _, _, _, _) |
+            ExprKind::Closure{..} |
 
             // We want to avoid a false positive when a variable name occurs
             // only to have its address taken, so we stop here. Technically,