Skip to content

Commit 09dcc5f

Browse files
Display negative traits implementation
1 parent e061383 commit 09dcc5f

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

src/librustdoc/html/render.rs

+19-9
Original file line numberDiff line numberDiff line change
@@ -3613,18 +3613,24 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
36133613
}
36143614
let mut links = HashSet::new();
36153615
let ret = v.iter()
3616-
.filter_map(|i| if let Some(ref i) = i.inner_impl().trait_ {
3617-
let i_display = format!("{:#}", i);
3618-
let out = Escape(&i_display);
3619-
let encoded = small_url_encode(&format!("{:#}", i));
3620-
let generated = format!("<a href=\"#impl-{}\">{}</a>", encoded, out);
3621-
if !links.contains(&generated) && links.insert(generated.clone()) {
3622-
Some(generated)
3616+
.filter_map(|i| {
3617+
let is_negative_impl = is_negative_impl(i.inner_impl());
3618+
if let Some(ref i) = i.inner_impl().trait_ {
3619+
let i_display = format!("{:#}", i);
3620+
let out = Escape(&i_display);
3621+
let encoded = small_url_encode(&format!("{:#}", i));
3622+
let generated = format!("<a href=\"#impl-{}\">{}{}</a>",
3623+
encoded,
3624+
if is_negative_impl { "!" } else { "" },
3625+
out);
3626+
if !links.contains(&generated) && links.insert(generated.clone()) {
3627+
Some(generated)
3628+
} else {
3629+
None
3630+
}
36233631
} else {
36243632
None
36253633
}
3626-
} else {
3627-
None
36283634
})
36293635
.collect::<String>();
36303636
if !ret.is_empty() {
@@ -3671,6 +3677,10 @@ fn extract_for_impl_name(item: &clean::Item) -> Option<(String, String)> {
36713677
}
36723678
}
36733679

3680+
fn is_negative_impl(i: &clean::Impl) -> bool {
3681+
i.polarity == Some(clean::ImplPolarity::Negative)
3682+
}
3683+
36743684
fn sidebar_trait(fmt: &mut fmt::Formatter, it: &clean::Item,
36753685
t: &clean::Trait) -> fmt::Result {
36763686
let mut sidebar = String::new();
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
#![feature(optin_builtin_traits)]
12+
#![crate_name = "foo"]
13+
14+
pub struct Foo;
15+
16+
// @has foo/struct.Foo.html
17+
// @has - '//*[@class="sidebar-title"][@href="#implementations"]' 'Trait Implementations'
18+
// @has - '//*[@class="sidebar-links"]/a' '!Sync'
19+
impl !Sync for Foo {}

0 commit comments

Comments
 (0)