Rollup merge of #68106 - varkor:self_self_use, r=estebank

Fix issue with using `self` module via indirection

Fixes https://github.com/rust-lang/rust/issues/68103.
This commit is contained in:
Mazdak Farrokhzad 2020-01-11 04:02:31 +01:00 committed by GitHub
commit 04a340f61f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -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))
{

View File

@ -0,0 +1,6 @@
// check-pass
pub extern crate self as name;
pub use name::name as bug;
fn main() {}