Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
2c752bc
Undeprecate env::home_dir
arlosi Feb 20, 2025
812b1de
ref_pat_eat_one_layer_2024: add context and examples to the unstable …
dianne Feb 21, 2025
9323ba5
Remove MaybeForgetReturn suggestion
compiler-errors Feb 20, 2025
a7bd4a3
Add DWARF test case for non-C-like `repr128` enums
beetrees Feb 25, 2025
fb3aa33
Revert "Derive `Clone` on fewer THIR types."
skius Feb 27, 2025
b5f0c82
Add note to Thir struct about necessity of Clone derive
skius Feb 27, 2025
b2bb7cc
Fix char count in Display for ByteStr
thaliaarchi Feb 28, 2025
41dd80a
add test to reproduce #137662 (using ty decl macro fragment in an att…
jdonszelmann Feb 26, 2025
50a37ca
miri native-call support: all previously exposed provenance is access…
RalfJung Feb 28, 2025
88f988c
use fixed-width integer types in C code
RalfJung Feb 28, 2025
476b098
adjust Layout debug printing to match the internal field names
RalfJung Feb 28, 2025
91034ad
Do not require that unsafe fields lack drop glue
jswrenn Feb 28, 2025
38b364b
rustc_fluent_macro: use CARGO_CRATE_NAME instead of CARGO_PKG_NAME
lolbinarycat Mar 1, 2025
adff091
Check dyn flavor before registering upcast goal on wide pointer cast …
compiler-errors Feb 25, 2025
649c0ff
Add minimal platform support documentation for powerpc-unknown-linux-…
taiki-e Mar 1, 2025
6867806
Document workings of successors more clearly
hkBst Jan 22, 2025
e213f4b
Improve error message for AsyncFn trait failure for RPIT
compiler-errors Mar 3, 2025
0aacfe9
interpret/provenance_map: consistently use range_is_empty
RalfJung Mar 3, 2025
133705c
[rustdoc] hide item that is not marked as doc(inline) and whose src i…
xizheyin Feb 27, 2025
a23566a
Provide more context on resolve error caused from incorrect RTN
estebank Feb 28, 2025
ab31129
Point of macro expansion from call expr if it involves macro var
compiler-errors Feb 24, 2025
e4dfca8
Point out macro expansion ident in resolver errors too
compiler-errors Feb 24, 2025
0607246
Fix associated type errors too
compiler-errors Feb 24, 2025
09e5846
Also note struct access, and fix macro expansion from foreign crates
compiler-errors Feb 24, 2025
69c4651
ci: use ubuntu 24 on arm large runner
marcoieni Mar 4, 2025
da3e736
Clarify why InhabitedPredicate::instantiate_opt exists
meithecatte Feb 28, 2025
a3d63fb
InhabitedPredicate: avoid using a wildcard branch
meithecatte Mar 3, 2025
3d62b27
Ensure that negative auto impls are always applicable
compiler-errors Feb 28, 2025
05a8060
Make rustdoc tests use always applicable negative auto impls
compiler-errors Feb 28, 2025
7923031
Update `compiler-builtins` to 0.1.151
tgross35 Mar 5, 2025
cb7d687
Implement `&pin const self` and `&pin mut self` sugars
frank-king Jan 19, 2025
52cd874
Simplify `parse_self_param`
frank-king Mar 5, 2025
50d0f99
Simplify `rewrite_explicit_self`
frank-king Mar 5, 2025
4f2b108
Prefer a two value enum over bool
oli-obk Feb 12, 2025
0e7b283
Avoid having to handle an `Option` in the type system
oli-obk Feb 5, 2025
e8f7a38
Remove the `Option` part of range ends in the HIR
oli-obk Feb 5, 2025
a2c1211
Hide the end of ranges in pretty printing if it's also the maximum of…
oli-obk Feb 5, 2025
91826b6
Rollup merge of #135733 - frank-king:feature/pin-self-receiver, r=oli…
compiler-errors Mar 6, 2025
5b07412
Rollup merge of #135895 - hkBst:patch-15, r=joboet
compiler-errors Mar 6, 2025
6ac714d
Rollup merge of #136922 - oli-obk:pattern-types-option-ends, r=BoxyUwU
compiler-errors Mar 6, 2025
ca9f615
Rollup merge of #137303 - compiler-errors:maybe-forgor, r=cjgillot
compiler-errors Mar 6, 2025
978893a
Rollup merge of #137327 - arlosi:home-dir, r=Mark-Simulacrum
compiler-errors Mar 6, 2025
98dfe93
Rollup merge of #137358 - dianne:new-match-ergonomics-examples, r=Nad…
compiler-errors Mar 6, 2025
cc5d90c
Rollup merge of #137534 - xizheyin:issue-137342, r=GuillaumeGomez
compiler-errors Mar 6, 2025
aab7b14
Rollup merge of #137565 - compiler-errors:macro-ex, r=estebank
compiler-errors Mar 6, 2025
3152f16
Rollup merge of #137637 - compiler-errors:dyn-cast-from-dyn-star, r=o…
compiler-errors Mar 6, 2025
e05a977
Rollup merge of #137643 - beetrees:repr128-dwarf-variant-test, r=jiey…
compiler-errors Mar 6, 2025
91175bd
Rollup merge of #137744 - skius:master, r=Nadrieril
compiler-errors Mar 6, 2025
34d273b
Rollup merge of #137758 - jdonszelmann:fix-137662, r=nnethercote
compiler-errors Mar 6, 2025
0013214
Rollup merge of #137764 - compiler-errors:always-applicable-negative-…
compiler-errors Mar 6, 2025
fe92638
Rollup merge of #137772 - thaliaarchi:bstr-display, r=joshtriplett
compiler-errors Mar 6, 2025
59cd967
Rollup merge of #137798 - marcoieni:ubuntu-24-large-runner-arm, r=Kobzol
compiler-errors Mar 6, 2025
b7b2179
Rollup merge of #137802 - RalfJung:miri-native-call-exposed, r=oli-obk
compiler-errors Mar 6, 2025
73d033f
Rollup merge of #137805 - RalfJung:layout-debug-print, r=Noratrieb
compiler-errors Mar 6, 2025
1c3733a
Rollup merge of #137808 - jswrenn:droppy-unsafe-fields, r=nnethercote
compiler-errors Mar 6, 2025
1e3a038
Rollup merge of #137820 - meithecatte:instantiate-opt, r=BoxyUwU
compiler-errors Mar 6, 2025
484d8dd
Rollup merge of #137825 - estebank:rtn-sugg-2, r=compiler-errors
compiler-errors Mar 6, 2025
56f0a60
Rollup merge of #137834 - lolbinarycat:rustc_fluent_macro-137815, r=B…
compiler-errors Mar 6, 2025
38b4820
Rollup merge of #137868 - taiki-e:powerpcspe-doc, r=workingjubilee
compiler-errors Mar 6, 2025
1458b35
Rollup merge of #137910 - compiler-errors:async-fn-goal-error, r=oli-obk
compiler-errors Mar 6, 2025
d21fc9d
Rollup merge of #137920 - RalfJung:provenance-map-emptiness, r=oli-obk
compiler-errors Mar 6, 2025
071bc46
Rollup merge of #138038 - tgross35:update-builtins, r=tgross35
compiler-errors Mar 6, 2025
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
Prev Previous commit
Next Next commit
[rustdoc] hide item that is not marked as doc(inline) and whose src i…
…s doc(hidden)

Signed-off-by: xizheyin <[email protected]>
  • Loading branch information
xizheyin committed Mar 3, 2025
commit 133705c402941c0825fe658a932289847478cf9f
22 changes: 20 additions & 2 deletions src/librustdoc/passes/strip_hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use rustc_middle::ty::TyCtxt;
use rustc_span::symbol::sym;
use tracing::debug;

use crate::clean;
use crate::clean::utils::inherits_doc_hidden;
use crate::clean::{Item, ItemIdSet};
use crate::clean::{self, Item, ItemIdSet, reexport_chain};
use crate::core::DocContext;
use crate::fold::{DocFolder, strip_item};
use crate::passes::{ImplStripper, Pass};
Expand Down Expand Up @@ -89,6 +88,25 @@ impl Stripper<'_, '_> {
impl DocFolder for Stripper<'_, '_> {
fn fold_item(&mut self, i: Item) -> Option<Item> {
let has_doc_hidden = i.is_doc_hidden();

if let clean::ImportItem(clean::Import { source, .. }) = &i.kind
&& let Some(source_did) = source.did
&& let Some(import_def_id) = i.def_id().and_then(|def_id| def_id.as_local())
{
let reexports = reexport_chain(self.tcx, import_def_id, source_did);

// Check if any reexport in the chain has a hidden source
let has_hidden_source = reexports
.iter()
.filter_map(|reexport| reexport.id())
.any(|reexport_did| self.tcx.is_doc_hidden(reexport_did))
|| self.tcx.is_doc_hidden(source_did);

if has_hidden_source {
return None;
}
}

let is_impl_or_exported_macro = match i.kind {
clean::ImplItem(..) => true,
// If the macro has the `#[macro_export]` attribute, it means it's accessible at the
Expand Down
18 changes: 9 additions & 9 deletions tests/rustdoc/doc-hidden-reexports-109449.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ pub mod single_reexport {
//@ has 'foo/single_reexport/index.html'

// First we check that we have 4 type aliases.
//@ count - '//*[@id="main-content"]/*[@class="item-table reexports"]//code' 4
//@ count - '//*[@id="main-content"]/*[@class="item-table reexports"]//code' 0

// Then we check that we have the correct link for each re-export.

//@ !has - '//*[@href="struct.Foo.html"]' 'Foo'
//@ has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;'
//@ !has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;'
pub use crate::private_module::Public as Foo;
//@ !has - '//*[@href="type.Foo2.html"]' 'Foo2'
//@ has - '//*[@id="reexport.Foo2"]/code' 'pub use crate::private_module::Bar as Foo2;'
//@ !has - '//*[@id="reexport.Foo2"]/code' 'pub use crate::private_module::Bar as Foo2;'
pub use crate::private_module::Bar as Foo2;
//@ !has - '//*[@href="type.Yo.html"]' 'Yo'
//@ has - '//*[@id="reexport.Yo"]/code' 'pub use crate::Bar3 as Yo;'
//@ !has - '//*[@id="reexport.Yo"]/code' 'pub use crate::Bar3 as Yo;'
pub use crate::Bar3 as Yo;
//@ !has - '//*[@href="struct.Yo2.html"]' 'Yo2'
//@ has - '//*[@id="reexport.Yo2"]/code' 'pub use crate::FooFoo as Yo2;'
//@ !has - '//*[@id="reexport.Yo2"]/code' 'pub use crate::FooFoo as Yo2;'
pub use crate::FooFoo as Yo2;

// Checking that each file is also created as expected.
Expand Down Expand Up @@ -70,19 +70,19 @@ pub mod single_reexport_no_inline {
//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports'

// Now we check that we don't have links to the items, just `pub use`.
//@ has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Public as XFoo;'
//@ !has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Public as XFoo;'
//@ !has - '//*[@id="main-content"]//a' 'XFoo'
#[doc(no_inline)]
pub use crate::private_module::Public as XFoo;
//@ has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Bar as Foo2;'
//@ !has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Bar as Foo2;'
//@ !has - '//*[@id="main-content"]//a' 'Foo2'
#[doc(no_inline)]
pub use crate::private_module::Bar as Foo2;
//@ has - '//*[@id="main-content"]//*' 'pub use crate::Bar3 as Yo;'
//@ !has - '//*[@id="main-content"]//*' 'pub use crate::Bar3 as Yo;'
//@ !has - '//*[@id="main-content"]//a' 'Yo'
#[doc(no_inline)]
pub use crate::Bar3 as Yo;
//@ has - '//*[@id="main-content"]//*' 'pub use crate::FooFoo as Yo2;'
//@ !has - '//*[@id="main-content"]//*' 'pub use crate::FooFoo as Yo2;'
//@ !has - '//*[@id="main-content"]//a' 'Yo2'
#[doc(no_inline)]
pub use crate::FooFoo as Yo2;
Expand Down
16 changes: 16 additions & 0 deletions tests/rustdoc/doc-hidden-source.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Test for <https://github.com/rust-lang/rust/issues/137342>.

#![crate_name = "foo"]

//@ has 'foo/index.html'
//@ !has - '//*[@id="main-content"]//*[@class="struct"]' 'Bar'
#[doc(hidden)]
pub struct Bar;

//@ !has - '//*' 'pub use crate::Bar as A;'
pub use crate::Bar as A;
//@ !has - '//*' 'pub use crate::A as B;'
pub use crate::A as B;
//@ has - '//dt/a[@class="struct"]' 'C'
#[doc(inline)]
pub use crate::Bar as C;
4 changes: 2 additions & 2 deletions tests/rustdoc/inline_cross/inline_hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern crate rustdoc_hidden;

//@ has inline_hidden/index.html
// Ensures this item is not inlined.
//@ has - '//*[@id="reexport.Foo"]/code' 'pub use rustdoc_hidden::Foo;'
//@ !has - '//*[@id="reexport.Foo"]/code' 'pub use rustdoc_hidden::Foo;'
#[doc(no_inline)]
pub use rustdoc_hidden::Foo;

Expand All @@ -16,7 +16,7 @@ pub use rustdoc_hidden::Foo;
pub use rustdoc_hidden::Foo as Inlined;

// Even with this import, we should not see `Foo`.
//@ count - '//dt' 4
//@ count - '//dt' 3
//@ has - '//dt/a[@class="struct"]' 'Bar'
//@ has - '//dt/a[@class="fn"]' 'foo'
pub use rustdoc_hidden::*;
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc/reexport-attr-merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub use Foo1 as Foo2;

// First we ensure that only the reexport `Bar2` and the inlined struct `Bar`
// are inlined.
//@ count - '//a[@class="struct"]' 2
//@ count - '//a[@class="struct"]' 1
// Then we check that `cfg` is displayed for base item, but not for intermediate re-exports.
//@ has - '//*[@class="stab portability"]' 'foo'
//@ !has - '//*[@class="stab portability"]' 'bar'
Expand All @@ -29,5 +29,5 @@ pub use Foo2 as Bar;

// This one should appear but `Bar2` won't be linked because there is no
// `#[doc(inline)]`.
//@ has - '//*[@id="reexport.Bar2"]' 'pub use Foo2 as Bar2;'
//@ !has - '//*[@id="reexport.Bar2"]' 'pub use Foo2 as Bar2;'
pub use Foo2 as Bar2;
4 changes: 2 additions & 2 deletions tests/rustdoc/reexport-doc-hidden-inside-private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mod private_module {
}

//@ has 'foo/index.html'
//@ has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;'
//@ !has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;'
pub use crate::private_module::Public as Foo;
// Glob re-exports with no visible items should not be displayed.
//@ count - '//*[@class="item-table reexports"]/dt' 1
//@ count - '//*[@class="item-table reexports"]/dt' 0
pub use crate::private_module::*;
4 changes: 2 additions & 2 deletions tests/rustdoc/reexport-doc-hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
pub type Type = u32;

//@ has 'foo/index.html'
//@ has - '//*[@id="reexport.Type2"]/code' 'pub use crate::Type as Type2;'
//@ !has - '//*[@id="reexport.Type2"]/code' 'pub use crate::Type as Type2;'
pub use crate::Type as Type2;

//@ count - '//*[@id="reexport.Type3"]' 0
Expand All @@ -21,5 +21,5 @@ macro_rules! foo {
() => {};
}

//@ has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
//@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
pub use crate::foo as Macro;
2 changes: 1 addition & 1 deletion tests/rustdoc/reexport-hidden-macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

//@ has 'foo/index.html'
//@ has - '//*[@id="main-content"]//a[@href="macro.Macro2.html"]' 'Macro2'
//@ has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
//@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'

//@ has 'foo/macro.Macro2.html'
//@ has - '//*[@class="docblock"]' 'Displayed'
Expand Down
12 changes: 6 additions & 6 deletions tests/rustdoc/reexport-of-doc-hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ macro_rules! foo {
}

//@ has 'foo/index.html'
//@ has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
//@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
pub use crate::foo as Macro;
//@ has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;'
//@ !has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;'
pub use crate::foo as Macro2;
//@ has - '//*[@id="reexport.Boo"]/code' 'pub use crate::Bar as Boo;'
//@ !has - '//*[@id="reexport.Boo"]/code' 'pub use crate::Bar as Boo;'
pub use crate::Bar as Boo;
//@ has - '//*[@id="reexport.Boo2"]/code' 'pub use crate::Bar as Boo2;'
//@ !has - '//*[@id="reexport.Boo2"]/code' 'pub use crate::Bar as Boo2;'
pub use crate::Bar as Boo2;

pub fn fofo() {}
Expand All @@ -30,9 +30,9 @@ pub use crate::fofo as f2;

pub mod sub {
//@ has 'foo/sub/index.html'
//@ has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
//@ !has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;'
pub use crate::foo as Macro;
//@ has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;'
//@ !has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;'
pub use crate::foo as Macro2;

//@ has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;'
Expand Down
Loading