Skip to content

Commit

Permalink
Auto merge of #45645 - fhartwig:39550, r=QuietMisdreavus
Browse files Browse the repository at this point in the history
Make rustdoc not include self-by-value methods from Deref target

Fixes #39550
  • Loading branch information
bors committed Nov 20, 2017
2 parents 26e881d + 32af136 commit e061383
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
11 changes: 6 additions & 5 deletions src/librustdoc/html/render.rs
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc/auxiliary/issue-19190-3.rs
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/test/rustdoc/issue-19190-2.rs
Expand Up @@ -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'
4 changes: 2 additions & 2 deletions src/test/rustdoc/issue-19190-3.rs
Expand Up @@ -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
Expand Down

0 comments on commit e061383

Please sign in to comment.