about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2020-01-10 22:29:57 +0000
committervarkor <github@varkor.com>2020-01-10 23:30:13 +0000
commit799efd3615f468c1382c61fe73b137fcffcd0a78 (patch)
tree263e67252c94d61c94595e22917fb4ed384f81b8
parent2d8d559bbecf6272eb41f8a800e319238aa9d621 (diff)
downloadrust-799efd3615f468c1382c61fe73b137fcffcd0a78.tar.gz
rust-799efd3615f468c1382c61fe73b137fcffcd0a78.zip
Fix issue with using `self` module via indirection
-rw-r--r--src/librustc_privacy/lib.rs3
-rw-r--r--src/test/ui/issues/issue-68103.rs6
2 files changed, 9 insertions, 0 deletions
diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs
index a96d5934023..70d4841ec24 100644
--- a/src/librustc_privacy/lib.rs
+++ b/src/librustc_privacy/lib.rs
@@ -652,6 +652,9 @@ impl EmbargoVisitor<'tcx> {
             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))
             {
diff --git a/src/test/ui/issues/issue-68103.rs b/src/test/ui/issues/issue-68103.rs
new file mode 100644
index 00000000000..e775678fc60
--- /dev/null
+++ b/src/test/ui/issues/issue-68103.rs
@@ -0,0 +1,6 @@
+// check-pass
+
+pub extern crate self as name;
+pub use name::name as bug;
+
+fn main() {}