From d8d8669439bd9e636b9209733c24c32063cc611d Mon Sep 17 00:00:00 2001 From: pierzchalski Date: Thu, 14 Apr 2016 13:57:01 +1000 Subject: [PATCH] Delegate whether to print docblocks to 'document' Add test to check this resolves #24838 and #26871. --- src/librustdoc/html/render.rs | 9 ++++----- src/test/rustdoc/manual_impl.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 src/test/rustdoc/manual_impl.rs diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index c5850089578cd..58901dcb38065 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -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(()) } } diff --git a/src/test/rustdoc/manual_impl.rs b/src/test/rustdoc/manual_impl.rs new file mode 100644 index 0000000000000..540cf58d38ebe --- /dev/null +++ b/src/test/rustdoc/manual_impl.rs @@ -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 or the MIT license +// , 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 + } +}