Skip to content

Commit d3e5685

Browse files
committed
rustdoc: Remove generated blanket impls from trait pages
1 parent df6ba0c commit d3e5685

File tree

3 files changed

+49
-14
lines changed

3 files changed

+49
-14
lines changed

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

+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;

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)