]> git.lizzy.rs Git - rust.git/commitdiff
Add flag for whether an item is default or not.
authorpierzchalski <e.a.pierzchalski@gmail.com>
Fri, 15 Apr 2016 04:41:54 +0000 (14:41 +1000)
committerpierzchalski <e.a.pierzchalski@gmail.com>
Fri, 15 Apr 2016 04:41:54 +0000 (14:41 +1000)
We don't want to render default item docs but previously
`doctraititem` naively delegated to the trait definition in those
cases.

Updated tests to also check that this doesn't strip default item
docs from the trait definition.

src/librustdoc/html/render.rs
src/test/rustdoc/manual_impl.rs

index 58901dcb380652da5ec2d667c0d7256ad4a51543..ba1fbc75c18a3b3343bac5c448eb4f853e9814e6 100644 (file)
@@ -2489,7 +2489,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
     }
 
     fn doctraititem(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
-                    link: AssocItemLink, render_static: bool,
+                    link: AssocItemLink, render_static: bool, is_default_item: bool,
                     outer_version: Option<&str>) -> fmt::Result {
         let shortty = shortty(item);
         let name = item.name.as_ref().unwrap();
@@ -2540,7 +2540,7 @@ fn doctraititem(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
             _ => panic!("can't make docs for trait item with name {:?}", item.name)
         }
 
-        if !is_static || render_static {
+        if !is_default_item && (!is_static || render_static) {
             document(w, cx, item)
         } else {
             Ok(())
@@ -2549,7 +2549,7 @@ fn doctraititem(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
 
     write!(w, "<div class='impl-items'>")?;
     for trait_item in &i.impl_.items {
-        doctraititem(w, cx, trait_item, link, render_header, outer_version)?;
+        doctraititem(w, cx, trait_item, link, render_header, false, outer_version)?;
     }
 
     fn render_default_items(w: &mut fmt::Formatter,
@@ -2566,7 +2566,7 @@ fn render_default_items(w: &mut fmt::Formatter,
             let did = i.trait_.as_ref().unwrap().def_id().unwrap();
             let assoc_link = AssocItemLink::GotoSource(did, &i.provided_trait_methods);
 
-            doctraititem(w, cx, trait_item, assoc_link, render_static,
+            doctraititem(w, cx, trait_item, assoc_link, render_static, true,
                          outer_version)?;
         }
         Ok(())
index 6675a0fd43b4efd289b99ba9501ae92246f00eec..5eccf97bb5f6f25fda3d1d43ee6f040358221d2e 100644 (file)
@@ -8,6 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// @has manual_impl/trait.T.html
+// @has  - '//*[@class="docblock"]' 'Docs associated with the trait definition.'
+// @has  - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
+// @has  - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
 /// Docs associated with the trait definition.
 pub trait T {
     /// Docs associated with the trait a_method definition.