]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #4166 - mati865:rustup, r=Manishearth
authorbors <bors@rust-lang.org>
Sun, 2 Jun 2019 17:07:33 +0000 (17:07 +0000)
committerbors <bors@rust-lang.org>
Sun, 2 Jun 2019 17:07:33 +0000 (17:07 +0000)
Rustup for https://github.com/rust-lang/rust/pull/61276

changelog: none

clippy_lints/src/escape.rs
clippy_lints/src/loops.rs
clippy_lints/src/misc.rs
clippy_lints/src/needless_pass_by_value.rs
clippy_lints/src/utils/usage.rs

index 8870b3f3b0ce28e96c86eac8bfdd94611c8b7b42..41312101417ae3f68056149277685da0aad3c92b 100644 (file)
@@ -79,7 +79,16 @@ fn check_fn(
 
         let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
         let region_scope_tree = &cx.tcx.region_scope_tree(fn_def_id);
-        ExprUseVisitor::new(&mut v, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).consume_body(body);
+        ExprUseVisitor::new(
+            &mut v,
+            cx.tcx,
+            fn_def_id,
+            cx.param_env,
+            region_scope_tree,
+            cx.tables,
+            None,
+        )
+        .consume_body(body);
 
         for node in v.set {
             span_lint(
index c4febdd4ddffb2453ac4171509f14d0e57d572d4..dcd89b7b85149fe254f876f8567ff7eafa727f66 100644 (file)
@@ -1662,7 +1662,16 @@ fn check_for_mutation(
     };
     let def_id = def_id::DefId::local(body.hir_id.owner);
     let region_scope_tree = &cx.tcx.region_scope_tree(def_id);
-    ExprUseVisitor::new(&mut delegate, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).walk_expr(body);
+    ExprUseVisitor::new(
+        &mut delegate,
+        cx.tcx,
+        def_id,
+        cx.param_env,
+        region_scope_tree,
+        cx.tables,
+        None,
+    )
+    .walk_expr(body);
     delegate.mutation_span()
 }
 
@@ -1769,7 +1778,7 @@ fn check(&mut self, idx: &'tcx Expr, seqexpr: &'tcx Expr, expr: &'tcx Expr) -> b
                     }
                     let res = self.cx.tables.qpath_res(seqpath, seqexpr.hir_id);
                     match res {
-                        Res::Local(hir_id) | Res::Upvar(hir_id, ..) => {
+                        Res::Local(hir_id) => {
                             let parent_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
                             let parent_def_id = self.cx.tcx.hir().local_def_id_from_hir_id(parent_id);
                             let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id);
@@ -1829,24 +1838,13 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
             if let QPath::Resolved(None, ref path) = *qpath;
             if path.segments.len() == 1;
             then {
-                match self.cx.tables.qpath_res(qpath, expr.hir_id) {
-                    Res::Upvar(local_id, ..) => {
-                        if local_id == self.var {
-                            // we are not indexing anything, record that
-                            self.nonindex = true;
-                        }
-                    }
-                    Res::Local(local_id) =>
-                    {
-
-                        if local_id == self.var {
-                            self.nonindex = true;
-                        } else {
-                            // not the correct variable, but still a variable
-                            self.referenced.insert(path.segments[0].ident.name);
-                        }
+                if let Res::Local(local_id) = self.cx.tables.qpath_res(qpath, expr.hir_id) {
+                    if local_id == self.var {
+                        self.nonindex = true;
+                    } else {
+                        // not the correct variable, but still a variable
+                        self.referenced.insert(path.segments[0].ident.name);
                     }
-                    _ => {}
                 }
             }
         }
@@ -2378,7 +2376,7 @@ fn insert_def_id(&mut self, ex: &'tcx Expr) {
             let res = self.cx.tables.qpath_res(qpath, ex.hir_id);
             then {
                 match res {
-                    Res::Local(node_id) | Res::Upvar(node_id, ..) => {
+                    Res::Local(node_id) => {
                         self.ids.insert(node_id);
                     },
                     Res::Def(DefKind::Static, def_id) => {
index 57751a03f5f0c7ec8e1ea83a1a0c6ebf439310fd..74368446d991298e23906b4177afff5cb8f6060b 100644 (file)
@@ -600,9 +600,10 @@ fn in_attributes_expansion(expr: &Expr) -> bool {
 
 /// Tests whether `res` is a variable defined outside a macro.
 fn non_macro_local(cx: &LateContext<'_, '_>, res: def::Res) -> bool {
-    match res {
-        def::Res::Local(id) | def::Res::Upvar(id, ..) => !in_macro_or_desugar(cx.tcx.hir().span_by_hir_id(id)),
-        _ => false,
+    if let def::Res::Local(id) = res {
+        !in_macro_or_desugar(cx.tcx.hir().span_by_hir_id(id))
+    } else {
+        false
     }
 }
 
index 0741fd52f4f8df0bf738d6501603553cdd7bc54b..424de64b5c7457aa1e96f44d731b1b6ef5a3727d 100644 (file)
@@ -137,8 +137,16 @@ fn check_fn(
         } = {
             let mut ctx = MovedVariablesCtxt::new(cx);
             let region_scope_tree = &cx.tcx.region_scope_tree(fn_def_id);
-            euv::ExprUseVisitor::new(&mut ctx, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None)
-                .consume_body(body);
+            euv::ExprUseVisitor::new(
+                &mut ctx,
+                cx.tcx,
+                fn_def_id,
+                cx.param_env,
+                region_scope_tree,
+                cx.tables,
+                None,
+            )
+            .consume_body(body);
             ctx
         };
 
index 4e66da8b19f42e331caa0fcfaa8dfb8b04a968a4..014dc9d4d8014a301093984148c85004c5bc1a40 100644 (file)
@@ -16,7 +16,16 @@ pub fn mutated_variables<'a, 'tcx: 'a>(expr: &'tcx Expr, cx: &'a LateContext<'a,
     };
     let def_id = def_id::DefId::local(expr.hir_id.owner);
     let region_scope_tree = &cx.tcx.region_scope_tree(def_id);
-    ExprUseVisitor::new(&mut delegate, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).walk_expr(expr);
+    ExprUseVisitor::new(
+        &mut delegate,
+        cx.tcx,
+        def_id,
+        cx.param_env,
+        region_scope_tree,
+        cx.tables,
+        None,
+    )
+    .walk_expr(expr);
 
     if delegate.skip {
         return None;
@@ -29,11 +38,11 @@ pub fn is_potentially_mutated<'a, 'tcx: 'a>(
     expr: &'tcx Expr,
     cx: &'a LateContext<'a, 'tcx>,
 ) -> bool {
-    let id = match variable.res {
-        Res::Local(id) | Res::Upvar(id, ..) => id,
-        _ => return true,
-    };
-    mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&id))
+    if let Res::Local(id) = variable.res {
+        mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&id))
+    } else {
+        return true;
+    }
 }
 
 struct MutVarsDelegate {