Skip to content

Commit e699471

Browse files
authored
Rollup merge of #62821 - GuillaumeGomez:not-listed-methods, r=Mark-Simulacrum
Not listed methods Fixes #60326. cc @rust-lang/rustdoc r? @QuietMisdreavus
2 parents c32735d + 4fb29f9 commit e699471

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/librustdoc/html/render.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -4579,12 +4579,13 @@ fn get_methods(
45794579
i: &clean::Impl,
45804580
for_deref: bool,
45814581
used_links: &mut FxHashSet<String>,
4582+
deref_mut: bool,
45824583
) -> Vec<String> {
45834584
i.items.iter().filter_map(|item| {
45844585
match item.name {
45854586
// Maybe check with clean::Visibility::Public as well?
45864587
Some(ref name) if !name.is_empty() && item.visibility.is_some() && item.is_method() => {
4587-
if !for_deref || should_render_item(item, false) {
4588+
if !for_deref || should_render_item(item, deref_mut) {
45884589
Some(format!("<a href=\"#{}\">{}</a>",
45894590
get_next_url(used_links, format!("method.{}", name)),
45904591
name))
@@ -4625,7 +4626,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
46254626
.filter(|i| i.inner_impl().trait_.is_none())
46264627
.flat_map(move |i| get_methods(i.inner_impl(),
46274628
false,
4628-
&mut used_links_bor.borrow_mut()))
4629+
&mut used_links_bor.borrow_mut(), false))
46294630
.collect::<Vec<_>>();
46304631
// We want links' order to be reproducible so we don't use unstable sort.
46314632
ret.sort();
@@ -4659,7 +4660,8 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
46594660
.filter(|i| i.inner_impl().trait_.is_none())
46604661
.flat_map(|i| get_methods(i.inner_impl(),
46614662
true,
4662-
&mut used_links))
4663+
&mut used_links,
4664+
true))
46634665
.collect::<Vec<_>>();
46644666
// We want links' order to be reproducible so we don't use unstable sort.
46654667
ret.sort();

src/test/rustdoc/deref-mut-methods.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#![crate_name = "foo"]
2+
3+
use std::ops;
4+
5+
pub struct Foo;
6+
7+
impl Foo {
8+
pub fn foo(&mut self) {}
9+
}
10+
11+
// @has foo/struct.Bar.html
12+
// @has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo'
13+
pub struct Bar {
14+
foo: Foo,
15+
}
16+
17+
impl ops::Deref for Bar {
18+
type Target = Foo;
19+
20+
fn deref(&self) -> &Foo {
21+
&self.foo
22+
}
23+
}
24+
25+
impl ops::DerefMut for Bar {
26+
fn deref_mut(&mut self) -> &mut Foo {
27+
&mut self.foo
28+
}
29+
}

0 commit comments

Comments
 (0)