]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_privacy/lib.rs
Auto merge of #65912 - estebank:variants-orig, r=petrochenkov
[rust.git] / src / librustc_privacy / lib.rs
index a96d59340237defd64630410ca9053e9962321a2..70d4841ec244b15b91fabb6e6c9ffa8eb76058ea 100644 (file)
@@ -652,6 +652,9 @@ fn update_visibility_of_intermediate_use_statements(
             if let Some(item) = module
                 .res
                 .and_then(|res| res.mod_def_id())
+                // If the module is `self`, i.e. the current crate,
+                // there will be no corresponding item.
+                .filter(|def_id| def_id.index != CRATE_DEF_INDEX || def_id.krate != LOCAL_CRATE)
                 .and_then(|def_id| self.tcx.hir().as_local_hir_id(def_id))
                 .map(|module_hir_id| self.tcx.hir().expect_item(module_hir_id))
             {