Skip to content

Commit 40d9740

Browse files
authored
Rollup merge of rust-lang#54087 - ollie27:rustdoc_blanket_impl, r=QuietMisdreavus
rustdoc: Remove generated blanket impls from trait pages rust-lang#53801 only deduped the generated blanket impls but they shouldn't be displayed at all because the original blanket impl is already in the "Implementors" section. This also removes the impls from the sidebar. Fixes rust-lang#53689 r? @QuietMisdreavus
2 parents 85b6bf9 + d3e5685 commit 40d9740

File tree

3 files changed

+49
-14
lines changed

3 files changed

+49
-14
lines changed

Diff for: src/librustdoc/html/render.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -1257,9 +1257,11 @@ impl DocFolder for Cache {
12571257
// Collect all the implementors of traits.
12581258
if let clean::ImplItem(ref i) = item.inner {
12591259
if let Some(did) = i.trait_.def_id() {
1260-
self.implementors.entry(did).or_default().push(Impl {
1261-
impl_item: item.clone(),
1262-
});
1260+
if i.blanket_impl.is_none() {
1261+
self.implementors.entry(did).or_default().push(Impl {
1262+
impl_item: item.clone(),
1263+
});
1264+
}
12631265
}
12641266
}
12651267

@@ -2931,7 +2933,6 @@ fn item_trait(
29312933

29322934

29332935
let (synthetic, concrete): (Vec<&&Impl>, Vec<&&Impl>) = local.iter()
2934-
.filter(|i| i.inner_impl().blanket_impl.is_none())
29352936
.partition(|i| i.inner_impl().synthetic);
29362937

29372938
if !foreign.is_empty() {
@@ -2941,17 +2942,14 @@ fn item_trait(
29412942
</h2>
29422943
")?;
29432944

2944-
let mut foreign_cache = FxHashSet();
29452945
for implementor in foreign {
2946-
if foreign_cache.insert(implementor.inner_impl().to_string()) {
2947-
let assoc_link = AssocItemLink::GotoSource(
2948-
implementor.impl_item.def_id,
2949-
&implementor.inner_impl().provided_trait_methods
2950-
);
2951-
render_impl(w, cx, &implementor, assoc_link,
2952-
RenderMode::Normal, implementor.impl_item.stable_since(), false,
2953-
None)?;
2954-
}
2946+
let assoc_link = AssocItemLink::GotoSource(
2947+
implementor.impl_item.def_id,
2948+
&implementor.inner_impl().provided_trait_methods
2949+
);
2950+
render_impl(w, cx, &implementor, assoc_link,
2951+
RenderMode::Normal, implementor.impl_item.stable_since(), false,
2952+
None)?;
29552953
}
29562954
}
29572955

Diff for: src/test/rustdoc/auxiliary/issue-53689.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub struct MyStruct;

Diff for: src/test/rustdoc/issue-53689.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:issue-53689.rs
12+
13+
#![crate_name = "foo"]
14+
15+
extern crate issue_53689;
16+
17+
// @has foo/trait.MyTrait.html
18+
// @!has - 'MyStruct'
19+
// @count - '//*[code="impl<T> MyTrait for T"]' 1
20+
pub trait MyTrait {}
21+
22+
impl<T> MyTrait for T {}
23+
24+
mod a {
25+
pub use issue_53689::MyStruct;
26+
}

0 commit comments

Comments
 (0)