Skip to content

Commit c634852

Browse files
Add test for impl blocks containing only private items
1 parent dd816a9 commit c634852

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// compile-flags: --document-private-items
2+
3+
#![feature(inherent_associated_types)]
4+
#![allow(incomplete_features)]
5+
#![crate_name = "foo"]
6+
7+
// @has 'foo/struct.Foo.html'
8+
pub struct Foo;
9+
10+
// There are 3 impl blocks with public item and one that should not be displayed
11+
// by default because it only contains private items (but not in this case because
12+
// we used `--document-private-items`).
13+
// @count - '//*[@class="impl has-srclink"]' 'impl Foo' 4
14+
15+
// Impl block only containing private items should not be displayed unless the
16+
// `--document-private-items` flag is used.
17+
/// Private
18+
impl Foo {
19+
const BAR: u32 = 0;
20+
type FOO = i32;
21+
fn hello() {}
22+
}
23+
24+
// But if any element of the impl block is public, it should be displayed.
25+
/// Not private
26+
impl Foo {
27+
pub const BAR: u32 = 0;
28+
type FOO = i32;
29+
fn hello() {}
30+
}
31+
32+
/// Not private
33+
impl Foo {
34+
const BAR: u32 = 0;
35+
pub type FOO = i32;
36+
fn hello() {}
37+
}
38+
39+
/// Not private
40+
impl Foo {
41+
const BAR: u32 = 0;
42+
type FOO = i32;
43+
pub fn hello() {}
44+
}

Diff for: src/test/rustdoc/empty-impl-block-private.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#![feature(inherent_associated_types)]
2+
#![allow(incomplete_features)]
3+
#![crate_name = "foo"]
4+
5+
// @has 'foo/struct.Foo.html'
6+
pub struct Foo;
7+
8+
// There are 3 impl blocks with public item and one that should not be displayed
9+
// because it only contains private items.
10+
// @count - '//*[@class="impl has-srclink"]' 'impl Foo' 3
11+
12+
// Impl block only containing private items should not be displayed.
13+
/// Private
14+
impl Foo {
15+
const BAR: u32 = 0;
16+
type FOO = i32;
17+
fn hello() {}
18+
}
19+
20+
// But if any element of the impl block is public, it should be displayed.
21+
/// Not private
22+
impl Foo {
23+
pub const BAR: u32 = 0;
24+
type FOO = i32;
25+
fn hello() {}
26+
}
27+
28+
/// Not private
29+
impl Foo {
30+
const BAR: u32 = 0;
31+
pub type FOO = i32;
32+
fn hello() {}
33+
}
34+
35+
/// Not private
36+
impl Foo {
37+
const BAR: u32 = 0;
38+
type FOO = i32;
39+
pub fn hello() {}
40+
}

0 commit comments

Comments
 (0)