Skip to content

Commit 3bf1328

Browse files
authored
Rollup merge of #46134 - GuillaumeGomez:negative-traits, r=QuietMisdreavus
Display negative traits implementation Fixes #45816. r? @QuietMisdreavus
2 parents e77f3e4 + 09dcc5f commit 3bf1328

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
@@ -3680,18 +3680,24 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
36803680
}
36813681
let mut links = HashSet::new();
36823682
let ret = v.iter()
3683-
.filter_map(|i| if let Some(ref i) = i.inner_impl().trait_ {
3684-
let i_display = format!("{:#}", i);
3685-
let out = Escape(&i_display);
3686-
let encoded = small_url_encode(&format!("{:#}", i));
3687-
let generated = format!("<a href=\"#impl-{}\">{}</a>", encoded, out);
3688-
if !links.contains(&generated) && links.insert(generated.clone()) {
3689-
Some(generated)
3683+
.filter_map(|i| {
3684+
let is_negative_impl = is_negative_impl(i.inner_impl());
3685+
if let Some(ref i) = i.inner_impl().trait_ {
3686+
let i_display = format!("{:#}", i);
3687+
let out = Escape(&i_display);
3688+
let encoded = small_url_encode(&format!("{:#}", i));
3689+
let generated = format!("<a href=\"#impl-{}\">{}{}</a>",
3690+
encoded,
3691+
if is_negative_impl { "!" } else { "" },
3692+
out);
3693+
if !links.contains(&generated) && links.insert(generated.clone()) {
3694+
Some(generated)
3695+
} else {
3696+
None
3697+
}
36903698
} else {
36913699
None
36923700
}
3693-
} else {
3694-
None
36953701
})
36963702
.collect::<String>();
36973703
if !ret.is_empty() {
@@ -3738,6 +3744,10 @@ fn extract_for_impl_name(item: &clean::Item) -> Option<(String, String)> {
37383744
}
37393745
}
37403746

3747+
fn is_negative_impl(i: &clean::Impl) -> bool {
3748+
i.polarity == Some(clean::ImplPolarity::Negative)
3749+
}
3750+
37413751
fn sidebar_trait(fmt: &mut fmt::Formatter, it: &clean::Item,
37423752
t: &clean::Trait) -> fmt::Result {
37433753
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)