Skip to content

Commit 56e9ec5

Browse files
committed
rustdoc: implement glob shadowing when doing local inlining
1 parent 624f972 commit 56e9ec5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/librustdoc/visit_ast.rs

+12
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,20 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
164164
self.inside_public_path &= self.cx.tcx.visibility(def_id).is_public();
165165
for &i in m.item_ids {
166166
let item = self.cx.tcx.hir().item(i);
167+
if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) {
168+
continue;
169+
}
167170
self.visit_item(item, None, &mut om);
168171
}
172+
for &i in m.item_ids {
173+
let item = self.cx.tcx.hir().item(i);
174+
// To match the way import precedence works, visit glob imports last.
175+
// Later passes in rustdoc will de-duplicate by name and kind, so if glob-
176+
// imported items appear last, then they'll be the ones that get discarded.
177+
if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) {
178+
self.visit_item(item, None, &mut om);
179+
}
180+
}
169181
self.inside_public_path = orig_inside_public_path;
170182
om
171183
}

0 commit comments

Comments
 (0)