diff options
| author | Michael Howell <michael@notriddle.com> | 2022-09-09 18:04:27 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2022-09-09 18:04:27 -0700 |
| commit | 56e9ec547a8b4b39c0da7ea66d1575b9f78da1a8 (patch) | |
| tree | b3cde2ff1544d7019a8155c4be11dc7291ed29d2 | |
| parent | 624f972358b2d1a33ce50bc27d33074be24981e0 (diff) | |
| download | rust-56e9ec547a8b4b39c0da7ea66d1575b9f78da1a8.tar.gz rust-56e9ec547a8b4b39c0da7ea66d1575b9f78da1a8.zip | |
rustdoc: implement glob shadowing when doing local inlining
| -rw-r--r-- | src/librustdoc/visit_ast.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index ca7a20bf368..c27ac0ac40e 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -164,8 +164,20 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { self.inside_public_path &= self.cx.tcx.visibility(def_id).is_public(); for &i in m.item_ids { let item = self.cx.tcx.hir().item(i); + if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) { + continue; + } self.visit_item(item, None, &mut om); } + for &i in m.item_ids { + let item = self.cx.tcx.hir().item(i); + // To match the way import precedence works, visit glob imports last. + // Later passes in rustdoc will de-duplicate by name and kind, so if glob- + // imported items appear last, then they'll be the ones that get discarded. + if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) { + self.visit_item(item, None, &mut om); + } + } self.inside_public_path = orig_inside_public_path; om } |
