Skip to content

Commit 770f6cd

Browse files
authored
Rollup merge of #110533 - GuillaumeGomez:missing-blanket-impl-trait-not-public, r=notriddle
Missing blanket impl trait not public Fixes #94183. The problem was that we should have checked if the trait was reachable instead of only "directly public". r? `@notriddle`
2 parents 75de33c + 96f4f4e commit 770f6cd

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/librustdoc/clean/blanket_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
2020
trace!("get_blanket_impls({:?})", ty);
2121
let mut impls = Vec::new();
2222
for trait_def_id in cx.tcx.all_traits() {
23-
if !cx.cache.effective_visibilities.is_directly_public(cx.tcx, trait_def_id)
23+
if !cx.cache.effective_visibilities.is_reachable(cx.tcx, trait_def_id)
2424
|| cx.generated_synthetics.get(&(ty.0, trait_def_id)).is_some()
2525
{
2626
continue;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/94183>.
2+
// This test ensures that a publicly re-exported private trait will
3+
// appear in the blanket impl list.
4+
5+
#![crate_name = "foo"]
6+
7+
// @has 'foo/struct.S.html'
8+
9+
mod actual_sub {
10+
pub trait Actual {}
11+
pub trait Another {}
12+
13+
// `Another` is publicly re-exported so it should appear in the blanket impl list.
14+
// @has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Another for T'
15+
impl<T> Another for T {}
16+
17+
trait Foo {}
18+
19+
// `Foo` is not publicly re-exported nor reachable so it shouldn't appear in the
20+
// blanket impl list.
21+
// @!has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Foo for T'
22+
impl<T> Foo for T {}
23+
}
24+
25+
pub use actual_sub::{Actual, Another};
26+
27+
// `Actual` is publicly re-exported so it should appear in the blanket impl list.
28+
// @has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Actual for T'
29+
impl<T> Actual for T {}
30+
31+
pub struct S;

0 commit comments

Comments
 (0)