summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Hartwig <florian.j.hartwig@gmail.com>2017-10-31 02:01:23 +0100
committerFlorian Hartwig <florian.j.hartwig@gmail.com>2017-11-20 00:15:26 +0100
commit32af136fb0e9b3d5bdfcc5c2ce18e6de20dbd65c (patch)
tree0bc6db5d1a6a7d904dd4152a0529f200452cde92
parent5041b3bb3d953a14f32b15d1e41341c629acae12 (diff)
downloadrust-32af136fb0e9b3d5bdfcc5c2ce18e6de20dbd65c.tar.gz
rust-32af136fb0e9b3d5bdfcc5c2ce18e6de20dbd65c.zip
Make rustdoc not include self-by-value methods from Deref target
-rw-r--r--src/librustdoc/html/render.rs11
-rw-r--r--src/test/rustdoc/auxiliary/issue-19190-3.rs4
-rw-r--r--src/test/rustdoc/issue-19190-2.rs8
-rw-r--r--src/test/rustdoc/issue-19190-3.rs4
4 files changed, 14 insertions, 13 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 7760561c9bf..e79a63fb8d8 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -3221,18 +3221,19 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
     };
 
     if let Some(self_ty) = self_type_opt {
-        let (by_mut_ref, by_box) = match self_ty {
+        let (by_mut_ref, by_box, by_value) = match self_ty {
             SelfTy::SelfBorrowed(_, mutability) |
             SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
-                (mutability == Mutability::Mutable, false)
+                (mutability == Mutability::Mutable, false, false)
             },
             SelfTy::SelfExplicit(clean::ResolvedPath { did, .. }) => {
-                (false, Some(did) == cache().owned_box_did)
+                (false, Some(did) == cache().owned_box_did, false)
             },
-            _ => (false, false),
+            SelfTy::SelfValue => (false, false, true),
+            _ => (false, false, false),
         };
 
-        (deref_mut_ || !by_mut_ref) && !by_box
+        (deref_mut_ || !by_mut_ref) && !by_box && !by_value
     } else {
         false
     }
diff --git a/src/test/rustdoc/auxiliary/issue-19190-3.rs b/src/test/rustdoc/auxiliary/issue-19190-3.rs
index 2c9271202a6..44621643431 100644
--- a/src/test/rustdoc/auxiliary/issue-19190-3.rs
+++ b/src/test/rustdoc/auxiliary/issue-19190-3.rs
@@ -15,8 +15,8 @@ use std::ops::Deref;
 pub struct Foo;
 
 impl Deref for Foo {
-    type Target = i32;
-    fn deref(&self) -> &i32 { loop {} }
+    type Target = String;
+    fn deref(&self) -> &String { loop {} }
 }
 
 pub struct Bar;
diff --git a/src/test/rustdoc/issue-19190-2.rs b/src/test/rustdoc/issue-19190-2.rs
index 8835e18f1c5..5688c5cba0b 100644
--- a/src/test/rustdoc/issue-19190-2.rs
+++ b/src/test/rustdoc/issue-19190-2.rs
@@ -13,10 +13,10 @@ use std::ops::Deref;
 pub struct Bar;
 
 impl Deref for Bar {
-    type Target = i32;
-    fn deref(&self) -> &i32 { loop {} }
+    type Target = String;
+    fn deref(&self) -> &String { loop {} }
 }
 
 // @has issue_19190_2/struct.Bar.html
-// @has - '//*[@id="method.count_ones"]' 'fn count_ones(self) -> u32'
-// @!has - '//*[@id="method.min_value"]' 'fn min_value() -> i32'
+// @!has - '//*[@id="method.new"]' 'fn new() -> String'
+// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str'
diff --git a/src/test/rustdoc/issue-19190-3.rs b/src/test/rustdoc/issue-19190-3.rs
index 64c396b29f2..be2e15dffc0 100644
--- a/src/test/rustdoc/issue-19190-3.rs
+++ b/src/test/rustdoc/issue-19190-3.rs
@@ -17,8 +17,8 @@ use std::ops::Deref;
 use issue_19190_3::Baz;
 
 // @has issue_19190_3/struct.Foo.html
-// @has - '//*[@id="method.count_ones"]' 'fn count_ones(self) -> u32'
-// @!has - '//*[@id="method.min_value"]' 'fn min_value() -> i32'
+// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str'
+// @!has - '//*[@id="method.new"]' 'fn new() -> String'
 pub use issue_19190_3::Foo;
 
 // @has issue_19190_3/struct.Bar.html