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;
// 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, _)| {
// 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
});
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