]> git.lizzy.rs Git - rust.git/commitdiff
Remove uses of span_if_local.
authorEduard-Mihai Burtescu <edy.burt@gmail.com>
Sun, 11 Jun 2017 03:15:53 +0000 (06:15 +0300)
committerEduard-Mihai Burtescu <edy.burt@gmail.com>
Sun, 11 Jun 2017 03:15:53 +0000 (06:15 +0300)
clippy_lints/src/misc.rs
clippy_lints/src/new_without_default.rs

index fda048110fe4641e460adfb108677fc458a20477..fe19a82a12d74975d2b8c7f142a2d3194731e90e 100644 (file)
@@ -514,13 +514,11 @@ fn in_attributes_expansion(expr: &Expr) -> bool {
 /// Test whether `def` is a variable defined outside a macro.
 fn non_macro_local(cx: &LateContext, def: &def::Def) -> bool {
     match *def {
-        def::Def::Local(id) |
-        def::Def::Upvar(id, _, _) => {
-            if let Some(span) = cx.tcx.hir.span_if_local(id) {
-                !in_macro(span)
-            } else {
-                true
-            }
+        def::Def::Local(def_id) |
+        def::Def::Upvar(def_id, _, _) => {
+            let id = cx.tcx.hir.as_local_node_id(def_id)
+                .expect("local variables should be found in the same crate");
+            !in_macro(cx.tcx.hir.span(id))
         },
         _ => false,
     }
index 9cebe4b0be6e1a245f0b1a45ab70c950d5d34163..34f467184f3b9ed4cd865bdba2eee9db28bc16a0 100644 (file)
@@ -159,7 +159,7 @@ fn can_derive_default<'t, 'c>(ty: Ty<'t>, cx: &LateContext<'c, 't>, default_trai
                     return None;
                 }
             }
-            cx.tcx.hir.span_if_local(adt_def.did)
+            Some(cx.tcx.def_span(adt_def.did))
         },
         _ => None,
     }