rustdoc-json: Include items in stripped modules in Crate::paths
.
This commit is contained in:
parent
97ada592c0
commit
1fe3331899
3 changed files with 26 additions and 8 deletions
|
@ -140,6 +140,7 @@ struct CacheBuilder<'a, 'tcx> {
|
|||
/// This field is used to prevent duplicated impl blocks.
|
||||
impl_ids: DefIdMap<DefIdSet>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
is_json_output: bool,
|
||||
}
|
||||
|
||||
impl Cache {
|
||||
|
@ -184,8 +185,13 @@ impl Cache {
|
|||
}
|
||||
|
||||
let (krate, mut impl_ids) = {
|
||||
let mut cache_builder =
|
||||
CacheBuilder { tcx, cache: &mut cx.cache, impl_ids: Default::default() };
|
||||
let is_json_output = cx.is_json_output();
|
||||
let mut cache_builder = CacheBuilder {
|
||||
tcx,
|
||||
cache: &mut cx.cache,
|
||||
impl_ids: Default::default(),
|
||||
is_json_output,
|
||||
};
|
||||
krate = cache_builder.fold_crate(krate);
|
||||
(krate, cache_builder.impl_ids)
|
||||
};
|
||||
|
@ -307,12 +313,13 @@ impl DocFolder for CacheBuilder<'_, '_> {
|
|||
| clean::ProcMacroItem(..)
|
||||
| clean::VariantItem(..) => {
|
||||
use rustc_data_structures::fx::IndexEntry as Entry;
|
||||
if !self.cache.stripped_mod
|
||||
&& !matches!(
|
||||
item.stability.map(|stab| stab.level),
|
||||
Some(StabilityLevel::Stable { allowed_through_unstable_modules: true, .. })
|
||||
)
|
||||
{
|
||||
|
||||
let skip_because_unstable = matches!(
|
||||
item.stability.map(|stab| stab.level),
|
||||
Some(StabilityLevel::Stable { allowed_through_unstable_modules: true, .. })
|
||||
);
|
||||
|
||||
if (!self.cache.stripped_mod && !skip_because_unstable) || self.is_json_output {
|
||||
// Re-exported items mean that the same id can show up twice
|
||||
// in the rustdoc ast that we're looking at. We know,
|
||||
// however, that a re-exported item doesn't show up in the
|
||||
|
|
|
@ -12,3 +12,9 @@ mod inner {
|
|||
pub use inner::Public;
|
||||
|
||||
//@ ismany "$.index[*][?(@.name=='simple_private')].inner.module.items[*]" $use_id
|
||||
|
||||
// Test for https://github.com/rust-lang/rust/issues/135309
|
||||
//@ has "$.paths[*][?(@.kind=='module')].path" '["simple_private"]'
|
||||
//@ !has "$.paths[*].path" '["simple_private", "inner"]'
|
||||
//@ has "$.paths[*][?(@.kind=='struct')].path" '["simple_private", "inner", "Public"]'
|
||||
//@ !has "$.paths[*].path" '["simple_private", "Public"]'
|
||||
|
|
|
@ -14,3 +14,8 @@ pub mod inner {
|
|||
pub use inner::Public;
|
||||
|
||||
//@ ismany "$.index[*][?(@.name=='simple_public')].inner.module.items[*]" $import_id $inner_id
|
||||
|
||||
//@ has "$.paths[*][?(@.kind=='module')].path" '["simple_public"]'
|
||||
//@ has "$.paths[*][?(@.kind=='module')].path" '["simple_public", "inner"]'
|
||||
//@ has "$.paths[*][?(@.kind=='struct')].path" '["simple_public", "inner", "Public"]'
|
||||
//@ !has "$.paths[*].path" '["simple_public", "Public"]'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue