1
Fork 0

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 #21310
This commit is contained in:
Corey Richardson 2015-03-27 17:29:07 -04:00
parent 199bdcfeff
commit 8d6fb44c99

View file

@ -125,6 +125,7 @@ pub struct Implementor {
pub trait_: clean::Type, pub trait_: clean::Type,
pub for_: clean::Type, pub for_: clean::Type,
pub stability: Option<clean::Stability>, pub stability: Option<clean::Stability>,
pub polarity: Option<clean::ImplPolarity>,
} }
/// Metadata about implementations for a type. /// Metadata about implementations for a type.
@ -635,9 +636,11 @@ fn write_shared(cx: &Context,
// going on). If they're in different crates then the crate defining // going on). If they're in different crates then the crate defining
// the trait will be interested in our implementation. // the trait will be interested in our implementation.
if imp.def_id.krate == did.krate { continue } if imp.def_id.krate == did.krate { continue }
try!(write!(&mut f, r#""{}impl{} {} for {}","#, try!(write!(&mut f, r#""{}impl{} {}{} for {}","#,
ConciseStability(&imp.stability), ConciseStability(&imp.stability),
imp.generics, imp.trait_, imp.for_)); imp.generics,
if imp.polarity == Some(clean::ImplPolarity::Negative) { "!" } else { "" },
imp.trait_, imp.for_));
} }
try!(writeln!(&mut f, r"];")); try!(writeln!(&mut f, r"];"));
try!(writeln!(&mut f, "{}", r" try!(writeln!(&mut f, "{}", r"
@ -884,6 +887,7 @@ impl DocFolder for Cache {
trait_: i.trait_.as_ref().unwrap().clone(), trait_: i.trait_.as_ref().unwrap().clone(),
for_: i.for_.clone(), for_: i.for_.clone(),
stability: item.stability.clone(), stability: item.stability.clone(),
polarity: i.polarity.clone(),
}); });
} }
Some(..) | None => {} Some(..) | None => {}