diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-06 15:36:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-06 15:36:28 +0200 |
| commit | e6994714d96eceef35ce6c420acd2fa2a17542e2 (patch) | |
| tree | df330e82efae8cc7422c4f6fe25b8ac2dcc9ba26 /src | |
| parent | c32735d03c5dffe4acf79f500bb2f248469a4e66 (diff) | |
| parent | 4fb29f9fd2758a5c07328fc12aa771bb239f9450 (diff) | |
| download | rust-e6994714d96eceef35ce6c420acd2fa2a17542e2.tar.gz rust-e6994714d96eceef35ce6c420acd2fa2a17542e2.zip | |
Rollup merge of #62821 - GuillaumeGomez:not-listed-methods, r=Mark-Simulacrum
Not listed methods Fixes #60326. cc @rust-lang/rustdoc r? @QuietMisdreavus
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/render.rs | 8 | ||||
| -rw-r--r-- | src/test/rustdoc/deref-mut-methods.rs | 29 |
2 files changed, 34 insertions, 3 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 2774f2b4751..ea0ebe47100 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -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)) @@ -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(); @@ -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(); diff --git a/src/test/rustdoc/deref-mut-methods.rs b/src/test/rustdoc/deref-mut-methods.rs new file mode 100644 index 00000000000..0e27fc90b69 --- /dev/null +++ b/src/test/rustdoc/deref-mut-methods.rs @@ -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 + } +} |
