Skip to content

rustdoc: Record crate name instead of using None #83399

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 2 commits into from
Mar 24, 2021
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
2 changes: 0 additions & 2 deletions src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ impl Cache {
self.primitive_locations.insert(prim, def_id);
}

self.stack.push(krate.name.to_string());

krate = CacheBuilder { tcx, cache: self, empty_cache: Cache::default() }.fold_crate(krate);

for (trait_did, dids, impl_) in self.orphan_trait_impls.drain(..) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
&Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Public },
hir::CRATE_HIR_ID,
&krate.item.module,
None,
Some(self.cx.tcx.crate_name),
);
top_level_module.is_crate = true;
// Attach the crate's exported macros to the top-level module.
Expand Down
6 changes: 6 additions & 0 deletions src/test/rustdoc-ui/intra-doc/private-from-crate-level.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// check-pass

//! [my_module]
//~^ WARN public documentation for `private_from_crate_level` links to private item `my_module`

mod my_module {}
11 changes: 11 additions & 0 deletions src/test/rustdoc-ui/intra-doc/private-from-crate-level.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
warning: public documentation for `private_from_crate_level` links to private item `my_module`
--> $DIR/private-from-crate-level.rs:3:6
|
LL | //! [my_module]
| ^^^^^^^^^ this item is private
|
= note: `#[warn(rustdoc::private_intra_doc_links)]` on by default
= note: this link will resolve properly if you pass `--document-private-items`

warning: 1 warning emitted