Rollup merge of #62821 - GuillaumeGomez:not-listed-methods, r=Mark-Simulacrum
Not listed methods Fixes #60326. cc @rust-lang/rustdoc r? @QuietMisdreavus
This commit is contained in:
commit
e6994714d9
2 changed files with 34 additions and 3 deletions
|
@ -4579,12 +4579,13 @@ fn get_methods(
|
||||||
i: &clean::Impl,
|
i: &clean::Impl,
|
||||||
for_deref: bool,
|
for_deref: bool,
|
||||||
used_links: &mut FxHashSet<String>,
|
used_links: &mut FxHashSet<String>,
|
||||||
|
deref_mut: bool,
|
||||||
) -> Vec<String> {
|
) -> Vec<String> {
|
||||||
i.items.iter().filter_map(|item| {
|
i.items.iter().filter_map(|item| {
|
||||||
match item.name {
|
match item.name {
|
||||||
// Maybe check with clean::Visibility::Public as well?
|
// Maybe check with clean::Visibility::Public as well?
|
||||||
Some(ref name) if !name.is_empty() && item.visibility.is_some() && item.is_method() => {
|
Some(ref name) if !name.is_empty() && item.visibility.is_some() && item.is_method() => {
|
||||||
if !for_deref || should_render_item(item, false) {
|
if !for_deref || should_render_item(item, deref_mut) {
|
||||||
Some(format!("<a href=\"#{}\">{}</a>",
|
Some(format!("<a href=\"#{}\">{}</a>",
|
||||||
get_next_url(used_links, format!("method.{}", name)),
|
get_next_url(used_links, format!("method.{}", name)),
|
||||||
name))
|
name))
|
||||||
|
@ -4625,7 +4626,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
|
||||||
.filter(|i| i.inner_impl().trait_.is_none())
|
.filter(|i| i.inner_impl().trait_.is_none())
|
||||||
.flat_map(move |i| get_methods(i.inner_impl(),
|
.flat_map(move |i| get_methods(i.inner_impl(),
|
||||||
false,
|
false,
|
||||||
&mut used_links_bor.borrow_mut()))
|
&mut used_links_bor.borrow_mut(), false))
|
||||||
.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();
|
||||||
|
@ -4659,7 +4660,8 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
|
||||||
.filter(|i| i.inner_impl().trait_.is_none())
|
.filter(|i| i.inner_impl().trait_.is_none())
|
||||||
.flat_map(|i| get_methods(i.inner_impl(),
|
.flat_map(|i| get_methods(i.inner_impl(),
|
||||||
true,
|
true,
|
||||||
&mut used_links))
|
&mut used_links,
|
||||||
|
true))
|
||||||
.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();
|
||||||
|
|
29
src/test/rustdoc/deref-mut-methods.rs
Normal file
29
src/test/rustdoc/deref-mut-methods.rs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#![crate_name = "foo"]
|
||||||
|
|
||||||
|
use std::ops;
|
||||||
|
|
||||||
|
pub struct Foo;
|
||||||
|
|
||||||
|
impl Foo {
|
||||||
|
pub fn foo(&mut self) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @has foo/struct.Bar.html
|
||||||
|
// @has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo'
|
||||||
|
pub struct Bar {
|
||||||
|
foo: Foo,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ops::Deref for Bar {
|
||||||
|
type Target = Foo;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Foo {
|
||||||
|
&self.foo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ops::DerefMut for Bar {
|
||||||
|
fn deref_mut(&mut self) -> &mut Foo {
|
||||||
|
&mut self.foo
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue