Skip to content

Commit 0e48e96

Browse files
authored
Rollup merge of #135171 - notriddle:notriddle/stable-path-is-better, r=GuillaumeGomez
rustdoc: use stable paths as preferred canonical paths This accomplishes something like 16a4ad7, but with the `rustc_allowed_through_unstable_modules` attribute instead of the path length. Fixes #131676
2 parents 3e12d4d + c7a806a commit 0e48e96

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

Diff for: src/librustdoc/formats/cache.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::mem;
22

3+
use rustc_attr_parsing::StabilityLevel;
34
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
45
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet};
56
use rustc_middle::ty::{self, TyCtxt};
@@ -306,7 +307,12 @@ impl DocFolder for CacheBuilder<'_, '_> {
306307
| clean::ProcMacroItem(..)
307308
| clean::VariantItem(..) => {
308309
use rustc_data_structures::fx::IndexEntry as Entry;
309-
if !self.cache.stripped_mod {
310+
if !self.cache.stripped_mod
311+
&& !matches!(
312+
item.stability.map(|stab| stab.level),
313+
Some(StabilityLevel::Stable { allowed_through_unstable_modules: true, .. })
314+
)
315+
{
310316
// Re-exported items mean that the same id can show up twice
311317
// in the rustdoc ast that we're looking at. We know,
312318
// however, that a re-exported item doesn't show up in the
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//! Test case for [134702]
2+
//!
3+
//! [134702]: https://github.com/rust-lang/rust/issues/134702
4+
#![crate_name = "foo"]
5+
#![stable(since = "1.0", feature = "v1")]
6+
7+
#![feature(staged_api, rustc_attrs)]
8+
9+
#[stable(since = "1.0", feature = "stb1")]
10+
pub mod stb1 {
11+
#[doc(inline)]
12+
#[stable(since = "1.0", feature = "stb1")]
13+
pub use crate::uns::Inside1;
14+
}
15+
16+
#[unstable(feature = "uns", issue = "135003")]
17+
pub mod uns {
18+
#[stable(since = "1.0", feature = "stb1")]
19+
#[rustc_allowed_through_unstable_modules]
20+
pub struct Inside1;
21+
#[stable(since = "1.0", feature = "stb2")]
22+
#[rustc_allowed_through_unstable_modules]
23+
pub struct Inside2;
24+
}
25+
26+
#[stable(since = "1.0", feature = "stb2")]
27+
pub mod stb2 {
28+
#[doc(inline)]
29+
#[stable(since = "1.0", feature = "stb2")]
30+
pub use crate::uns::Inside2;
31+
}
32+
33+
#[stable(since = "1.0", feature = "nested")]
34+
pub mod nested {
35+
//! [Inside1] [Inside2]
36+
//@ has foo/nested/index.html '//a[@href="../stb1/struct.Inside1.html"]' 'Inside1'
37+
//@ has foo/nested/index.html '//a[@href="../stb2/struct.Inside2.html"]' 'Inside2'
38+
use crate::stb1::Inside1;
39+
use crate::stb2::Inside2;
40+
}

0 commit comments

Comments
 (0)