Skip to content

Commit e061383

Browse files
committed
Auto merge of rust-lang#45645 - fhartwig:39550, r=QuietMisdreavus
Make rustdoc not include self-by-value methods from Deref target Fixes rust-lang#39550
2 parents 26e881d + 32af136 commit e061383

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

src/librustdoc/html/render.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -3221,18 +3221,19 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
32213221
};
32223222

32233223
if let Some(self_ty) = self_type_opt {
3224-
let (by_mut_ref, by_box) = match self_ty {
3224+
let (by_mut_ref, by_box, by_value) = match self_ty {
32253225
SelfTy::SelfBorrowed(_, mutability) |
32263226
SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
3227-
(mutability == Mutability::Mutable, false)
3227+
(mutability == Mutability::Mutable, false, false)
32283228
},
32293229
SelfTy::SelfExplicit(clean::ResolvedPath { did, .. }) => {
3230-
(false, Some(did) == cache().owned_box_did)
3230+
(false, Some(did) == cache().owned_box_did, false)
32313231
},
3232-
_ => (false, false),
3232+
SelfTy::SelfValue => (false, false, true),
3233+
_ => (false, false, false),
32333234
};
32343235

3235-
(deref_mut_ || !by_mut_ref) && !by_box
3236+
(deref_mut_ || !by_mut_ref) && !by_box && !by_value
32363237
} else {
32373238
false
32383239
}

src/test/rustdoc/auxiliary/issue-19190-3.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use std::ops::Deref;
1515
pub struct Foo;
1616

1717
impl Deref for Foo {
18-
type Target = i32;
19-
fn deref(&self) -> &i32 { loop {} }
18+
type Target = String;
19+
fn deref(&self) -> &String { loop {} }
2020
}
2121

2222
pub struct Bar;

src/test/rustdoc/issue-19190-2.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use std::ops::Deref;
1313
pub struct Bar;
1414

1515
impl Deref for Bar {
16-
type Target = i32;
17-
fn deref(&self) -> &i32 { loop {} }
16+
type Target = String;
17+
fn deref(&self) -> &String { loop {} }
1818
}
1919

2020
// @has issue_19190_2/struct.Bar.html
21-
// @has - '//*[@id="method.count_ones"]' 'fn count_ones(self) -> u32'
22-
// @!has - '//*[@id="method.min_value"]' 'fn min_value() -> i32'
21+
// @!has - '//*[@id="method.new"]' 'fn new() -> String'
22+
// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str'

src/test/rustdoc/issue-19190-3.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use std::ops::Deref;
1717
use issue_19190_3::Baz;
1818

1919
// @has issue_19190_3/struct.Foo.html
20-
// @has - '//*[@id="method.count_ones"]' 'fn count_ones(self) -> u32'
21-
// @!has - '//*[@id="method.min_value"]' 'fn min_value() -> i32'
20+
// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str'
21+
// @!has - '//*[@id="method.new"]' 'fn new() -> String'
2222
pub use issue_19190_3::Foo;
2323

2424
// @has issue_19190_3/struct.Bar.html

0 commit comments

Comments
 (0)