diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-05 09:33:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-05 09:33:24 +0200 |
| commit | bf44a87732496e4ea5e7f7cb11680bb68fd6cad4 (patch) | |
| tree | a8e3276b6c7928babd414057b34015a8a310c6d5 | |
| parent | 2a7e7bd0e0a2686429267d529d02f0df8129626c (diff) | |
| parent | 50cc0fa8abd0279608ce3434a5a3fe34dee62a70 (diff) | |
| download | rust-bf44a87732496e4ea5e7f7cb11680bb68fd6cad4.tar.gz rust-bf44a87732496e4ea5e7f7cb11680bb68fd6cad4.zip | |
Rollup merge of #95645 - GuillaumeGomez:intra-doc-link-ice-traits-in-scope-primitive, r=jyn514
Fix intra doc link ICE when trying to get traits in scope for primitive Fixes #95633. I think ``@notriddle`` was the one who worked on this part of the code last so: r? ``@notriddle``
| -rw-r--r-- | src/librustdoc/lib.rs | 8 | ||||
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links/early.rs | 5 | ||||
| -rw-r--r-- | src/test/rustdoc/issue-95633.rs | 7 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index f59222b780d..1d7a790bdb7 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -771,6 +771,7 @@ fn main_options(options: config::Options) -> MainResult { let externs = options.externs.clone(); let render_options = options.render_options.clone(); let scrape_examples_options = options.scrape_examples_options.clone(); + let document_private = options.render_options.document_private; let config = core::create_config(options); interface::create_compiler_and_run(config, |compiler| { @@ -791,7 +792,12 @@ fn main_options(options: config::Options) -> MainResult { let (resolver, resolver_caches) = { let (krate, resolver, _) = &*abort_on_err(queries.expansion(), sess).peek(); let resolver_caches = resolver.borrow_mut().access(|resolver| { - collect_intra_doc_links::early_resolve_intra_doc_links(resolver, krate, externs) + collect_intra_doc_links::early_resolve_intra_doc_links( + resolver, + krate, + externs, + document_private, + ) }); (resolver.clone(), resolver_caches) }; diff --git a/src/librustdoc/passes/collect_intra_doc_links/early.rs b/src/librustdoc/passes/collect_intra_doc_links/early.rs index 39900270ccb..44bf86b082a 100644 --- a/src/librustdoc/passes/collect_intra_doc_links/early.rs +++ b/src/librustdoc/passes/collect_intra_doc_links/early.rs @@ -22,6 +22,7 @@ crate fn early_resolve_intra_doc_links( resolver: &mut Resolver<'_>, krate: &ast::Crate, externs: Externs, + document_private_items: bool, ) -> ResolverCaches { let mut loader = IntraLinkCrateLoader { resolver, @@ -30,6 +31,7 @@ crate fn early_resolve_intra_doc_links( traits_in_scope: Default::default(), all_traits: Default::default(), all_trait_impls: Default::default(), + document_private_items, }; // Overridden `visit_item` below doesn't apply to the crate root, @@ -61,6 +63,7 @@ struct IntraLinkCrateLoader<'r, 'ra> { traits_in_scope: DefIdMap<Vec<TraitCandidate>>, all_traits: Vec<DefId>, all_trait_impls: Vec<DefId>, + document_private_items: bool, } impl IntraLinkCrateLoader<'_, '_> { @@ -167,7 +170,7 @@ impl IntraLinkCrateLoader<'_, '_> { } for child in self.resolver.module_children_or_reexports(module_id) { - if child.vis == Visibility::Public { + if child.vis == Visibility::Public || self.document_private_items { if let Some(def_id) = child.res.opt_def_id() { self.add_traits_in_parent_scope(def_id); } diff --git a/src/test/rustdoc/issue-95633.rs b/src/test/rustdoc/issue-95633.rs new file mode 100644 index 00000000000..a71d0a03731 --- /dev/null +++ b/src/test/rustdoc/issue-95633.rs @@ -0,0 +1,7 @@ +// compile-flags: --document-private-items + +// This ensures that no ICE is triggered when rustdoc is run on this code. + +mod stdlib { + pub (crate) use std::i8; +} |
