summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-04-07 17:35:23 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-04-07 17:54:35 -0700
commit77d164d8099abc17f97aa50442245e4fc88b36a2 (patch)
tree5d7789e68dcb263dfde71a22529f5dada93e5332 /src/librustdoc/html
parent1b568ba0fd531ff33d45cb52d5c8cbfe1908be86 (diff)
downloadrust-77d164d8099abc17f97aa50442245e4fc88b36a2.tar.gz
rust-77d164d8099abc17f97aa50442245e4fc88b36a2.zip
rustdoc: Index inherent methods on primitives
The set of types which can have an inherent impl changed slightly and rustdoc
just needed to catch up to understand what it means to see a `impl str`!

Closes #23511
Diffstat (limited to 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/render.rs59
1 files changed, 17 insertions, 42 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index a1ec58cd3dd..8e33a9bd80b 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1025,7 +1025,16 @@ impl DocFolder for Cache {
                         self.parent_stack.push(did);
                         true
                     }
-                    _ => false
+                    ref t => {
+                        match t.primitive_type() {
+                            Some(prim) => {
+                                let did = ast_util::local_def(prim.to_node_id());
+                                self.parent_stack.push(did);
+                                true
+                            }
+                            _ => false,
+                        }
+                    }
                 }
             }
             _ => false
@@ -1037,11 +1046,6 @@ impl DocFolder for Cache {
             Some(item) => {
                 match item {
                     clean::Item{ attrs, inner: clean::ImplItem(i), .. } => {
-                        use clean::{Primitive, Vector, ResolvedPath, BorrowedRef};
-                        use clean::PrimitiveType::{Array, Slice, PrimitiveTuple};
-                        use clean::PrimitiveType::{PrimitiveRawPointer};
-                        use clean::{FixedVector, Tuple, RawPointer};
-
                         // extract relevant documentation for this impl
                         let dox = match attrs.into_iter().find(|a| {
                             match *a {
@@ -1059,47 +1063,18 @@ impl DocFolder for Cache {
                         // Figure out the id of this impl. This may map to a
                         // primitive rather than always to a struct/enum.
                         let did = match i.for_ {
-                            ResolvedPath { did, .. } |
-                            BorrowedRef {
-                                type_: box ResolvedPath { did, .. }, ..
+                            clean::ResolvedPath { did, .. } |
+                            clean::BorrowedRef {
+                                type_: box clean::ResolvedPath { did, .. }, ..
                             } => {
                                 Some(did)
                             }
 
-                            // References to primitives are picked up as well to
-                            // recognize implementations for &str, this may not
-                            // be necessary in a DST world.
-                            Primitive(p) |
-                                BorrowedRef { type_: box Primitive(p), ..} =>
-                            {
-                                Some(ast_util::local_def(p.to_node_id()))
+                            ref t => {
+                                t.primitive_type().map(|p| {
+                                    ast_util::local_def(p.to_node_id())
+                                })
                             }
-
-                            FixedVector(..) |
-                                BorrowedRef { type_: box FixedVector(..), .. } =>
-                            {
-                                Some(ast_util::local_def(Array.to_node_id()))
-                            }
-
-                            // In a DST world, we may only need Vector, but for
-                            // now we also pick up borrowed references
-                            Vector(..) |
-                                BorrowedRef{ type_: box Vector(..), ..  } =>
-                            {
-                                Some(ast_util::local_def(Slice.to_node_id()))
-                            }
-
-                            Tuple(..) => {
-                                let id = PrimitiveTuple.to_node_id();
-                                Some(ast_util::local_def(id))
-                            }
-
-                            RawPointer(..) => {
-                                let id = PrimitiveRawPointer.to_node_id();
-                                Some(ast_util::local_def(id))
-                            }
-
-                            _ => None,
                         };
 
                         if let Some(did) = did {