Skip to content

Commit 3d645a3

Browse files
authored
Rollup merge of #83399 - camelid:rustdoc-priv-link-from-crate, r=jyn514
rustdoc: Record crate name instead of using `None` Fixes #83365. r? `@jyn514`
2 parents 8c1c7a7 + c9ae359 commit 3d645a3

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/librustdoc/formats/cache.rs

-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ impl Cache {
182182
self.primitive_locations.insert(prim, def_id);
183183
}
184184

185-
self.stack.push(krate.name.to_string());
186-
187185
krate = CacheBuilder { tcx, cache: self, empty_cache: Cache::default() }.fold_crate(krate);
188186

189187
for (trait_did, dids, impl_) in self.orphan_trait_impls.drain(..) {

src/librustdoc/visit_ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
7676
&Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Public },
7777
hir::CRATE_HIR_ID,
7878
&krate.item.module,
79-
None,
79+
Some(self.cx.tcx.crate_name),
8080
);
8181
top_level_module.is_crate = true;
8282
// Attach the crate's exported macros to the top-level module.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// check-pass
2+
3+
//! [my_module]
4+
//~^ WARN public documentation for `private_from_crate_level` links to private item `my_module`
5+
6+
mod my_module {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: public documentation for `private_from_crate_level` links to private item `my_module`
2+
--> $DIR/private-from-crate-level.rs:3:6
3+
|
4+
LL | //! [my_module]
5+
| ^^^^^^^^^ this item is private
6+
|
7+
= note: `#[warn(rustdoc::private_intra_doc_links)]` on by default
8+
= note: this link will resolve properly if you pass `--document-private-items`
9+
10+
warning: 1 warning emitted
11+

0 commit comments

Comments
 (0)