1
Fork 0

Only show associated consts from inherent impls in sidebar

This commit is contained in:
Jules Bertholet 2022-03-30 10:37:55 -04:00
parent e50ff9b452
commit c8ab63b30f
2 changed files with 25 additions and 4 deletions

View file

@ -1987,6 +1987,7 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
let used_links_bor = &mut used_links; let used_links_bor = &mut used_links;
let mut assoc_consts = v let mut assoc_consts = v
.iter() .iter()
.filter(|i| i.inner_impl().trait_.is_none())
.flat_map(|i| get_associated_constants(i.inner_impl(), used_links_bor)) .flat_map(|i| get_associated_constants(i.inner_impl(), used_links_bor))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
if !assoc_consts.is_empty() { if !assoc_consts.is_empty() {

View file

@ -9,8 +9,8 @@ pub trait Trait {
pub struct Bar; pub struct Bar;
// @has 'foo/struct.Bar.html' // @has 'foo/struct.Bar.html'
// @has - '//h3[@class="sidebar-title"]' 'Associated Constants' // @!has - '//h3[@class="sidebar-title"]' 'Associated Constants'
// @has - '//div[@class="sidebar-elems"]//a' 'FOO' // @!has - '//div[@class="sidebar-elems"]//a' 'FOO'
impl Trait for Bar { impl Trait for Bar {
const FOO: u32 = 1; const FOO: u32 = 1;
@ -22,10 +22,30 @@ pub enum Foo {
} }
// @has 'foo/enum.Foo.html' // @has 'foo/enum.Foo.html'
// @has - '//h3[@class="sidebar-title"]' 'Associated Constants' // @!has - '//h3[@class="sidebar-title"]' 'Associated Constants'
// @has - '//div[@class="sidebar-elems"]//a' 'FOO' // @!has - '//div[@class="sidebar-elems"]//a' 'FOO'
impl Trait for Foo { impl Trait for Foo {
const FOO: u32 = 1; const FOO: u32 = 1;
fn foo() {} fn foo() {}
} }
pub struct Baz;
// @has 'foo/struct.Baz.html'
// @has - '//h3[@class="sidebar-title"]' 'Associated Constants'
// @has - '//div[@class="sidebar-elems"]//a' 'FOO'
impl Baz {
pub const FOO: u32 = 42;
}
pub enum Quux {
B,
}
// @has 'foo/enum.Quux.html'
// @has - '//h3[@class="sidebar-title"]' 'Associated Constants'
// @has - '//div[@class="sidebar-elems"]//a' 'FOO'
impl Quux {
pub const FOO: u32 = 42;
}