Skip to content

Commit 8d6fb44

Browse files
committed
rustdoc: show negative impls properly in the implementors page
This isn't really possible to test in an automatic way, since the only traits you can negative impl are `Send` and `Sync`, and the implementors page for those only exists in libstd. Closes rust-lang#21310
1 parent 199bdcf commit 8d6fb44

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustdoc/html/render.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub struct Implementor {
125125
pub trait_: clean::Type,
126126
pub for_: clean::Type,
127127
pub stability: Option<clean::Stability>,
128+
pub polarity: Option<clean::ImplPolarity>,
128129
}
129130

130131
/// Metadata about implementations for a type.
@@ -635,9 +636,11 @@ fn write_shared(cx: &Context,
635636
// going on). If they're in different crates then the crate defining
636637
// the trait will be interested in our implementation.
637638
if imp.def_id.krate == did.krate { continue }
638-
try!(write!(&mut f, r#""{}impl{} {} for {}","#,
639+
try!(write!(&mut f, r#""{}impl{} {}{} for {}","#,
639640
ConciseStability(&imp.stability),
640-
imp.generics, imp.trait_, imp.for_));
641+
imp.generics,
642+
if imp.polarity == Some(clean::ImplPolarity::Negative) { "!" } else { "" },
643+
imp.trait_, imp.for_));
641644
}
642645
try!(writeln!(&mut f, r"];"));
643646
try!(writeln!(&mut f, "{}", r"
@@ -884,6 +887,7 @@ impl DocFolder for Cache {
884887
trait_: i.trait_.as_ref().unwrap().clone(),
885888
for_: i.for_.clone(),
886889
stability: item.stability.clone(),
890+
polarity: i.polarity.clone(),
887891
});
888892
}
889893
Some(..) | None => {}

0 commit comments

Comments
 (0)