Skip to content

Commit cb63d99

Browse files
Add regression test for #140739
1 parent 376e51e commit cb63d99

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/rustdoc/type-alias/repr.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This test ensures that the `repr` attribute is displayed in type aliases.
2+
//
3+
// Regression test for <https://github.com/rust-lang/rust/issues/140739>.
4+
5+
#![crate_name = "foo"]
6+
7+
/// bla
8+
#[repr(C)]
9+
pub struct Foo1;
10+
11+
//@ has 'foo/type.Bar1.html'
12+
//@ has - '//*[@class="rust item-decl"]/code' '#[repr(C)]pub struct Bar1;'
13+
// Ensures that we see the doc comment of the type alias and not of the aliased type.
14+
//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'bar'
15+
/// bar
16+
pub type Bar1 = Foo1;
17+
18+
/// bla
19+
#[repr(C)]
20+
pub union Foo2 {
21+
pub a: u8,
22+
}
23+
24+
//@ has 'foo/type.Bar2.html'
25+
//@ matches - '//*[@class="rust item-decl"]' '#\[repr\(C\)\]\npub union Bar2 \{*'
26+
// Ensures that we see the doc comment of the type alias and not of the aliased type.
27+
//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'bar'
28+
/// bar
29+
pub type Bar2 = Foo2;
30+
31+
/// bla
32+
#[repr(C)]
33+
pub enum Foo3 {
34+
A,
35+
}
36+
37+
//@ has 'foo/type.Bar3.html'
38+
//@ matches - '//*[@class="rust item-decl"]' '#\[repr\(C\)\]pub enum Bar3 \{*'
39+
// Ensures that we see the doc comment of the type alias and not of the aliased type.
40+
//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'bar'
41+
/// bar
42+
pub type Bar3 = Foo3;

0 commit comments

Comments
 (0)