Skip to content

Do not visit ForeignItemRef for HIR indexing and validation. #79511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions compiler/rustc_middle/src/hir/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,14 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {

self.visit_nested_impl_item(id);
}

fn visit_foreign_item_ref(&mut self, fi: &'hir ForeignItemRef<'hir>) {
// Do not visit the duplicate information in ForeignItemRef. We want to
// map the actual nodes, not the duplicate ones in the *Ref.
let ForeignItemRef { id, ident: _, span: _, vis: _ } = *fi;

self.visit_nested_foreign_item(id);
}
}

struct HirItemLike<T> {
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_passes/src/hir_id_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
// different owner.
}

fn visit_foreign_item_ref(&mut self, _: &'hir hir::ForeignItemRef<'hir>) {
// Explicitly do nothing here. ForeignItemRefs contain hir::Visibility
// values that actually belong to an ForeignItem instead of the ItemKind::ForeignMod
// we are currently in. So for those it's correct that they have a
// different owner.
}

fn visit_generic_param(&mut self, param: &'hir hir::GenericParam<'hir>) {
if let hir::GenericParamKind::Type {
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/foreign/foreign-pub-super.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Test for #79487
// check-pass

#![allow(dead_code)]

mod sha2 {
extern "C" {
pub(super) fn GFp_sha512_block_data_order();
}
}

fn main() {}