Skip to content

Commit 7dc71ec

Browse files
committedMar 9, 2018
Remove auto trait implementation section when empty
1 parent fedce67 commit 7dc71ec

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed
 

‎src/librustdoc/html/render.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -3181,14 +3181,16 @@ fn render_assoc_items(w: &mut fmt::Formatter,
31813181
render_impls(cx, w, concrete, containing_item)?;
31823182
write!(w, "</div>")?;
31833183

3184-
write!(w, "
3185-
<h2 id='synthetic-implementations' class='small-section-header'>
3186-
Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a>
3187-
</h2>
3188-
<div id='synthetic-implementations-list'>
3189-
")?;
3190-
render_impls(cx, w, synthetic, containing_item)?;
3191-
write!(w, "</div>")?;
3184+
if !synthetic.is_empty() {
3185+
write!(w, "
3186+
<h2 id='synthetic-implementations' class='small-section-header'>
3187+
Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a>
3188+
</h2>
3189+
<div id='synthetic-implementations-list'>
3190+
")?;
3191+
render_impls(cx, w, synthetic, containing_item)?;
3192+
write!(w, "</div>")?;
3193+
}
31923194
}
31933195
Ok(())
31943196
}

‎src/test/rustdoc/empty-section.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2017 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+
#![crate_name = "foo"]
12+
13+
#![feature(optin_builtin_traits)]
14+
15+
pub struct Foo;
16+
17+
// @has foo/struct.Foo.html
18+
// @!has - '//*[@class="synthetic-implementations"]' 'Auto Trait Implementations'
19+
impl !Send for Foo {}
20+
impl !Sync for Foo {}

0 commit comments

Comments
 (0)