about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-01-21 09:13:53 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-01-21 09:13:53 -0800
commit5123f75856c531913f60bf2343a5436d47a32ef7 (patch)
tree892c50570e83096ae2ffc95d2af8490d6c6d6708 /src
parent0c981875e46763a9b3cd53443bf73dfd3e291d18 (diff)
parenteb086505b805792a6afe67a644cde6b4ab002f14 (diff)
rollup merge of #21342: Diggsey/issue-21310
Fixes #21310
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/inline.rs2
-rw-r--r--src/librustdoc/clean/mod.rs17
-rw-r--r--src/librustdoc/html/render.rs4
-rw-r--r--src/test/run-make/rustdoc-negative-impl/Makefile6
-rw-r--r--src/test/run-make/rustdoc-negative-impl/foo.rs22
5 files changed, 51 insertions, 0 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index ccaefadc1fc..519292fa9e0 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -317,6 +317,7 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
             }
         }
     }).collect();
+    let polarity = csearch::get_impl_polarity(tcx, did);
     return Some(clean::Item {
         inner: clean::ImplItem(clean::Impl {
             derived: clean::detect_derived(attrs.as_slice()),
@@ -329,6 +330,7 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
             for_: ty.ty.clean(cx),
             generics: (&ty.generics, subst::TypeSpace).clean(cx),
             items: trait_items,
+            polarity: polarity.map(|p| { p.clean(cx) }),
         }),
         source: clean::Span::empty(),
         name: None,
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index adc3a2401a5..e1090391236 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -2082,6 +2082,21 @@ impl Clean<Mutability> for ast::Mutability {
     }
 }
 
+#[derive(Show, Clone, RustcEncodable, RustcDecodable, PartialEq, Copy)]
+pub enum ImplPolarity {
+    Positive,
+    Negative,
+}
+
+impl Clean<ImplPolarity> for ast::ImplPolarity {
+    fn clean(&self, _: &DocContext) -> ImplPolarity {
+        match self {
+            &ast::ImplPolarity::Positive => ImplPolarity::Positive,
+            &ast::ImplPolarity::Negative => ImplPolarity::Negative,
+        }
+    }
+}
+
 #[derive(Clone, RustcEncodable, RustcDecodable)]
 pub struct Impl {
     pub generics: Generics,
@@ -2089,6 +2104,7 @@ pub struct Impl {
     pub for_: Type,
     pub items: Vec<Item>,
     pub derived: bool,
+    pub polarity: Option<ImplPolarity>,
 }
 
 fn detect_derived<M: AttrMetaMethods>(attrs: &[M]) -> bool {
@@ -2115,6 +2131,7 @@ impl Clean<Item> for doctree::Impl {
                         }
                     }).collect(),
                 derived: detect_derived(self.attrs.as_slice()),
+                polarity: Some(self.polarity.clean(cx)),
             }),
         }
     }
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index ab9700d966a..9e94db33171 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -2085,6 +2085,10 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl) -> fmt::Result {
     try!(write!(w, "<h3 class='impl'>{}<code>impl{} ",
                 ConciseStability(&i.stability),
                 i.impl_.generics));
+    match i.impl_.polarity {
+        Some(clean::ImplPolarity::Negative) => try!(write!(w, "!")),
+        _ => {}
+    }
     match i.impl_.trait_ {
         Some(ref ty) => try!(write!(w, "{} for ", *ty)),
         None => {}
diff --git a/src/test/run-make/rustdoc-negative-impl/Makefile b/src/test/run-make/rustdoc-negative-impl/Makefile
new file mode 100644
index 00000000000..1316ee256e1
--- /dev/null
+++ b/src/test/run-make/rustdoc-negative-impl/Makefile
@@ -0,0 +1,6 @@
+-include ../tools.mk
+
+all: foo.rs
+	$(HOST_RPATH_ENV) $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs
+	$(HTMLDOCCK) $(TMPDIR)/doc foo.rs
+
diff --git a/src/test/run-make/rustdoc-negative-impl/foo.rs b/src/test/run-make/rustdoc-negative-impl/foo.rs
new file mode 100644
index 00000000000..eaa3af86563
--- /dev/null
+++ b/src/test/run-make/rustdoc-negative-impl/foo.rs
@@ -0,0 +1,22 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(optin_builtin_traits)]
+
+// @matches foo/struct.Alpha.html '//pre' "pub struct Alpha"
+pub struct Alpha;
+// @matches foo/struct.Bravo.html '//pre' "pub struct Bravo<B>"
+pub struct Bravo<B>;
+
+// @matches foo/struct.Alpha.html '//*[@class="impl"]//code' "impl !.*Send.* for .*Alpha"
+impl !Send for Alpha {}
+
+// @matches foo/struct.Bravo.html '//*[@class="impl"]//code' "impl<B> !.*Send.* for .*Bravo.*<B>"
+impl<B> !Send for Bravo<B> {}