Rollup merge of #74107 - nbdd0121:rustdoc, r=GuillaumeGomez
Hide `&mut self` methods from Deref in sidebar if there are no `DerefMut` impl for the type. This partially addresses #74083.
This commit is contained in:
commit
38541b742a
2 changed files with 28 additions and 1 deletions
|
@ -4054,6 +4054,10 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
let deref_mut = v
|
||||||
|
.iter()
|
||||||
|
.filter(|i| i.inner_impl().trait_.is_some())
|
||||||
|
.any(|i| i.inner_impl().trait_.def_id() == c.deref_mut_trait_did);
|
||||||
let inner_impl = target
|
let inner_impl = target
|
||||||
.def_id()
|
.def_id()
|
||||||
.or(target
|
.or(target
|
||||||
|
@ -4074,7 +4078,9 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
|
||||||
let mut ret = impls
|
let mut ret = impls
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|i| i.inner_impl().trait_.is_none())
|
.filter(|i| i.inner_impl().trait_.is_none())
|
||||||
.flat_map(|i| get_methods(i.inner_impl(), true, &mut used_links, true))
|
.flat_map(|i| {
|
||||||
|
get_methods(i.inner_impl(), true, &mut used_links, deref_mut)
|
||||||
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
// We want links' order to be reproducible so we don't use unstable sort.
|
// We want links' order to be reproducible so we don't use unstable sort.
|
||||||
ret.sort();
|
ret.sort();
|
||||||
|
|
21
src/test/rustdoc/issue-74083.rs
Normal file
21
src/test/rustdoc/issue-74083.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
use std::ops::Deref;
|
||||||
|
|
||||||
|
pub struct Foo;
|
||||||
|
|
||||||
|
impl Foo {
|
||||||
|
pub fn foo(&mut self) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @has issue_74083/struct.Bar.html
|
||||||
|
// !@has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo'
|
||||||
|
pub struct Bar {
|
||||||
|
foo: Foo,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Deref for Bar {
|
||||||
|
type Target = Foo;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Foo {
|
||||||
|
&self.foo
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue