Skip to content

Commit 914d07a

Browse files
committed
Auto merge of rust-lang#79511 - cjgillot:fitem-2, r=lcnr
Do not visit ForeignItemRef for HIR indexing and validation. Similarly to what is done for ImplItemRef and TraitItemRef. Fixes rust-lang#79487 r? `@lcnr`
2 parents e37f25a + 5bd1979 commit 914d07a

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

compiler/rustc_middle/src/hir/map/collector.rs

+8
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,14 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
572572

573573
self.visit_nested_impl_item(id);
574574
}
575+
576+
fn visit_foreign_item_ref(&mut self, fi: &'hir ForeignItemRef<'hir>) {
577+
// Do not visit the duplicate information in ForeignItemRef. We want to
578+
// map the actual nodes, not the duplicate ones in the *Ref.
579+
let ForeignItemRef { id, ident: _, span: _, vis: _ } = *fi;
580+
581+
self.visit_nested_foreign_item(id);
582+
}
575583
}
576584

577585
struct HirItemLike<T> {

compiler/rustc_passes/src/hir_id_validator.rs

+7
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
169169
// different owner.
170170
}
171171

172+
fn visit_foreign_item_ref(&mut self, _: &'hir hir::ForeignItemRef<'hir>) {
173+
// Explicitly do nothing here. ForeignItemRefs contain hir::Visibility
174+
// values that actually belong to an ForeignItem instead of the ItemKind::ForeignMod
175+
// we are currently in. So for those it's correct that they have a
176+
// different owner.
177+
}
178+
172179
fn visit_generic_param(&mut self, param: &'hir hir::GenericParam<'hir>) {
173180
if let hir::GenericParamKind::Type {
174181
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Test for #79487
2+
// check-pass
3+
4+
#![allow(dead_code)]
5+
6+
mod sha2 {
7+
extern "C" {
8+
pub(super) fn GFp_sha512_block_data_order();
9+
}
10+
}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)