Skip to content

Commit

Permalink
Delegate whether to print docblocks to 'document'
Browse files Browse the repository at this point in the history
Add test to check this resolves rust-lang#24838 and rust-lang#26871.
  • Loading branch information
pierzchalski committed Apr 14, 2016
1 parent 2b60207 commit d8d8669
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2540,11 +2540,10 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
_ => panic!("can't make docs for trait item with name {:?}", item.name)
}

match link {
AssocItemLink::Anchor if !is_static || render_static => {
document(w, cx, item)
},
_ => Ok(()),
if !is_static || render_static {
document(w, cx, item)
} else {
Ok(())
}
}

Expand Down
26 changes: 26 additions & 0 deletions src/test/rustdoc/manual_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub trait T {
fn a_method(&self) -> usize;
}

// @has manual_impl/struct.S.html '//*[@class="trait"]' 'T'
// @has - '//*[@class="docblock"]' 'Docs associated with the trait implementation.'
// @has - '//*[@class="docblock"]' 'Docs associated with the trait method implementation.'
pub struct S(usize);

/// Docs associated with the trait implementation.
impl T for S {
/// Docs associated with the trait method implementation.
fn a_method(&self) -> usize {
self.0
}
}

0 comments on commit d8d8669

Please sign in to comment.