Skip to content

Commit c8ab63b

Browse files
Only show associated consts from inherent impls in sidebar
1 parent e50ff9b commit c8ab63b

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/librustdoc/html/render/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,7 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
19871987
let used_links_bor = &mut used_links;
19881988
let mut assoc_consts = v
19891989
.iter()
1990+
.filter(|i| i.inner_impl().trait_.is_none())
19901991
.flat_map(|i| get_associated_constants(i.inner_impl(), used_links_bor))
19911992
.collect::<Vec<_>>();
19921993
if !assoc_consts.is_empty() {

src/test/rustdoc/associated-consts.rs

+24-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ pub trait Trait {
99
pub struct Bar;
1010

1111
// @has 'foo/struct.Bar.html'
12-
// @has - '//h3[@class="sidebar-title"]' 'Associated Constants'
13-
// @has - '//div[@class="sidebar-elems"]//a' 'FOO'
12+
// @!has - '//h3[@class="sidebar-title"]' 'Associated Constants'
13+
// @!has - '//div[@class="sidebar-elems"]//a' 'FOO'
1414
impl Trait for Bar {
1515
const FOO: u32 = 1;
1616

@@ -22,10 +22,30 @@ pub enum Foo {
2222
}
2323

2424
// @has 'foo/enum.Foo.html'
25-
// @has - '//h3[@class="sidebar-title"]' 'Associated Constants'
26-
// @has - '//div[@class="sidebar-elems"]//a' 'FOO'
25+
// @!has - '//h3[@class="sidebar-title"]' 'Associated Constants'
26+
// @!has - '//div[@class="sidebar-elems"]//a' 'FOO'
2727
impl Trait for Foo {
2828
const FOO: u32 = 1;
2929

3030
fn foo() {}
3131
}
32+
33+
pub struct Baz;
34+
35+
// @has 'foo/struct.Baz.html'
36+
// @has - '//h3[@class="sidebar-title"]' 'Associated Constants'
37+
// @has - '//div[@class="sidebar-elems"]//a' 'FOO'
38+
impl Baz {
39+
pub const FOO: u32 = 42;
40+
}
41+
42+
pub enum Quux {
43+
B,
44+
}
45+
46+
// @has 'foo/enum.Quux.html'
47+
// @has - '//h3[@class="sidebar-title"]' 'Associated Constants'
48+
// @has - '//div[@class="sidebar-elems"]//a' 'FOO'
49+
impl Quux {
50+
pub const FOO: u32 = 42;
51+
}

0 commit comments

Comments
 (0)