]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/check_unused.rs
bootstrap: Configurable musl libdir
[rust.git] / src / librustc_typeck / check_unused.rs
index dfe86aecbf727c41d00b12e69912e201e8cb5c83..eaaff70472bfb212e2c59e661ca9946b780587ac 100644 (file)
@@ -1,7 +1,7 @@
 use rustc_data_structures::fx::FxHashMap;
 use rustc_errors::Applicability;
 use rustc_hir as hir;
-use rustc_hir::def_id::{DefId, DefIdSet, LOCAL_CRATE};
+use rustc_hir::def_id::{DefId, DefIdSet, LocalDefId, LOCAL_CRATE};
 use rustc_hir::itemlikevisit::ItemLikeVisitor;
 use rustc_middle::ty::TyCtxt;
 use rustc_session::lint;
@@ -70,7 +70,7 @@ fn unused_crates_lint(tcx: TyCtxt<'_>) {
     // Collect first the crates that are completely unused.  These we
     // can always suggest removing (no matter which edition we are
     // in).
-    let unused_extern_crates: FxHashMap<DefId, Span> = tcx
+    let unused_extern_crates: FxHashMap<LocalDefId, Span> = tcx
         .maybe_unused_extern_crates(LOCAL_CRATE)
         .iter()
         .filter(|&&(def_id, _)| {
@@ -88,7 +88,7 @@ fn unused_crates_lint(tcx: TyCtxt<'_>) {
             // Note that if we carry through to the `extern_mod_stmt_cnum` query
             // below it'll cause a panic because `def_id` is actually bogus at this
             // point in time otherwise.
-            if tcx.hir().find(tcx.hir().as_local_hir_id(def_id.expect_local())).is_none() {
+            if tcx.hir().find(tcx.hir().as_local_hir_id(def_id)).is_none() {
                 return false;
             }
             true
@@ -112,13 +112,14 @@ fn unused_crates_lint(tcx: TyCtxt<'_>) {
     });
 
     for extern_crate in &crates_to_lint {
-        let id = tcx.hir().as_local_hir_id(extern_crate.def_id.expect_local());
+        let def_id = extern_crate.def_id.expect_local();
+        let id = tcx.hir().as_local_hir_id(def_id);
         let item = tcx.hir().expect_item(id);
 
         // If the crate is fully unused, we suggest removing it altogether.
         // We do this in any edition.
         if extern_crate.warn_if_unused {
-            if let Some(&span) = unused_extern_crates.get(&extern_crate.def_id) {
+            if let Some(&span) = unused_extern_crates.get(&def_id) {
                 tcx.struct_span_lint_hir(lint, id, span, |lint| {
                     // Removal suggestion span needs to include attributes (Issue #54400)
                     let span_with_attrs = tcx