Skip to content

Not listed methods #62821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4579,12 +4579,13 @@ fn get_methods(
i: &clean::Impl,
for_deref: bool,
used_links: &mut FxHashSet<String>,
deref_mut: bool,
) -> Vec<String> {
i.items.iter().filter_map(|item| {
match item.name {
// Maybe check with clean::Visibility::Public as well?
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>",
get_next_url(used_links, format!("method.{}", name)),
name))
Expand Down Expand Up @@ -4625,7 +4626,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
.filter(|i| i.inner_impl().trait_.is_none())
.flat_map(move |i| get_methods(i.inner_impl(),
false,
&mut used_links_bor.borrow_mut()))
&mut used_links_bor.borrow_mut(), false))
.collect::<Vec<_>>();
// We want links' order to be reproducible so we don't use unstable sort.
ret.sort();
Expand Down Expand Up @@ -4659,7 +4660,8 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
.filter(|i| i.inner_impl().trait_.is_none())
.flat_map(|i| get_methods(i.inner_impl(),
true,
&mut used_links))
&mut used_links,
true))
.collect::<Vec<_>>();
// We want links' order to be reproducible so we don't use unstable sort.
ret.sort();
Expand Down
29 changes: 29 additions & 0 deletions src/test/rustdoc/deref-mut-methods.rs
Original file line number Diff line number Diff line change
@@ -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
}
}