about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-07-29 16:30:39 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2018-08-04 11:02:00 +0200
commit8301081c906b733576b15ee3125f23ff6d60c560 (patch)
tree109fab06bc57bc9f0c7f199db7cf68d9ff9a06ef
parent4aba7de2a77a95e2032eaf438e2e11b8e1a5eb82 (diff)
downloadrust-8301081c906b733576b15ee3125f23ff6d60c560.tar.gz
rust-8301081c906b733576b15ee3125f23ff6d60c560.zip
Fix primitive blanket impls not showing up
-rw-r--r--src/librustdoc/clean/blanket_impl.rs9
-rw-r--r--src/test/rustdoc/primitive-generic-impl.rs18
-rw-r--r--src/test/rustdoc/primitive/primitive-generic-impl.rs13
3 files changed, 35 insertions, 5 deletions
diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs
index bb86688447e..ade65ec99b1 100644
--- a/src/librustdoc/clean/blanket_impl.rs
+++ b/src/librustdoc/clean/blanket_impl.rs
@@ -65,9 +65,9 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
             );
             return impls;
         }
-        if self.cx.access_levels.borrow().is_doc_reachable(def_id) {
+        let ty = self.cx.tcx.type_of(def_id);
+        if self.cx.access_levels.borrow().is_doc_reachable(def_id) || ty.is_primitive() {
             let generics = self.cx.tcx.generics_of(def_id);
-            let ty = self.cx.tcx.type_of(def_id);
             let real_name = name.clone().map(|name| Ident::from_str(&name));
             let param_env = self.cx.tcx.param_env(def_id);
             for &trait_def_id in self.cx.all_traits.iter() {
@@ -84,8 +84,8 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
                         let trait_ref = infcx.tcx.impl_trait_ref(impl_def_id)
                                                  .expect("Cannot get impl trait");
 
-                        match infcx.tcx.type_of(impl_def_id).sty {
-                            ::rustc::ty::TypeVariants::TyParam(_) => {},
+                        match trait_ref.self_ty().sty {
+                            ty::TypeVariants::TyParam(_) => {},
                             _ => return,
                         }
 
@@ -153,7 +153,6 @@ impl<'a, 'tcx, 'rcx> BlanketImplFinder <'a, 'tcx, 'rcx> {
                                                                 .clean(self.cx)),
                                 }),
                             });
-                            debug!("{:?} => {}", trait_ref, may_apply);
                         }
                     });
                 });
diff --git a/src/test/rustdoc/primitive-generic-impl.rs b/src/test/rustdoc/primitive-generic-impl.rs
new file mode 100644
index 00000000000..b4351b8268c
--- /dev/null
+++ b/src/test/rustdoc/primitive-generic-impl.rs
@@ -0,0 +1,18 @@
+// Copyright 2018 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.
+
+#![crate_name = "foo"]
+
+// we need to reexport something from libstd so that `all_trait_implementations` is called.
+pub use std::string::String;
+
+include!("primitive/primitive-generic-impl.rs");
+
+// @has foo/primitive.i32.html '//h3[@id="impl-ToString"]//code' 'impl<T> ToString for T'
diff --git a/src/test/rustdoc/primitive/primitive-generic-impl.rs b/src/test/rustdoc/primitive/primitive-generic-impl.rs
new file mode 100644
index 00000000000..1ac1fc95338
--- /dev/null
+++ b/src/test/rustdoc/primitive/primitive-generic-impl.rs
@@ -0,0 +1,13 @@
+// Copyright 2018 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.
+
+#[doc(primitive = "i32")]
+/// Some useless docs, wouhou!
+mod i32 {}