未验证 提交 38541b74 编写于 作者: M Manish Goregaokar 提交者: GitHub

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.
......@@ -4054,6 +4054,10 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
_ => 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
.def_id()
.or(target
......@@ -4074,7 +4078,9 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
let mut ret = impls
.iter()
.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<_>>();
// We want links' order to be reproducible so we don't use unstable sort.
ret.sort();
......
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
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册