Skip to content

Commit d8d8669

Browse files
committed
Delegate whether to print docblocks to 'document'
Add test to check this resolves rust-lang#24838 and rust-lang#26871.
1 parent 2b60207 commit d8d8669

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

src/librustdoc/html/render.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2540,11 +2540,10 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
25402540
_ => panic!("can't make docs for trait item with name {:?}", item.name)
25412541
}
25422542

2543-
match link {
2544-
AssocItemLink::Anchor if !is_static || render_static => {
2545-
document(w, cx, item)
2546-
},
2547-
_ => Ok(()),
2543+
if !is_static || render_static {
2544+
document(w, cx, item)
2545+
} else {
2546+
Ok(())
25482547
}
25492548
}
25502549

src/test/rustdoc/manual_impl.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2015 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 trait T {
12+
fn a_method(&self) -> usize;
13+
}
14+
15+
// @has manual_impl/struct.S.html '//*[@class="trait"]' 'T'
16+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait implementation.'
17+
// @has - '//*[@class="docblock"]' 'Docs associated with the trait method implementation.'
18+
pub struct S(usize);
19+
20+
/// Docs associated with the trait implementation.
21+
impl T for S {
22+
/// Docs associated with the trait method implementation.
23+
fn a_method(&self) -> usize {
24+
self.0
25+
}
26+
}

0 commit comments

Comments
 (0)