summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc/typedef-inner-variants.rs
blob: 4d0ff85551ce92b1b9435b28fb4b0bfe3f5ca106 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// This test checks different combinations of structs, enums, and unions
// for the "Show Aliased Type" feature on type definition.

#![crate_name = "inner_variants"]

// aux-build:cross_crate_generic_typedef.rs
extern crate cross_crate_generic_typedef;

pub struct Adt;
pub struct Ty;
pub struct TyCtxt;

pub trait Interner {
    type Adt;
    type Ty;
}

impl Interner for TyCtxt {
    type Adt = Adt;
    type Ty = Ty;
}

// @has 'inner_variants/type.AliasTy.html'
// @count - '//*[@id="variants"]' 0
// @count - '//*[@id="fields"]' 0
pub type AliasTy = Ty;

// @has 'inner_variants/enum.IrTyKind.html'
pub enum IrTyKind<A, I: Interner> {
    /// Doc comment for AdtKind
    AdtKind(I::Adt),
    /// and another one for TyKind
    TyKind(I::Adt, <I as Interner>::Ty),
    // no comment
    StructKind { a: A, },
    #[doc(hidden)]
    Unspecified,
}

// @has 'inner_variants/type.NearlyTyKind.html'
// @count - '//*[@id="aliased-type"]' 1
// @count - '//*[@id="variants"]' 1
// @count - '//*[@id="fields"]' 0
pub type NearlyTyKind<A> = IrTyKind<A, TyCtxt>;

// @has 'inner_variants/type.TyKind.html'
// @count - '//*[@id="aliased-type"]' 1
// @count - '//*[@id="variants"]' 1
// @count - '//*[@id="fields"]' 0
// @count - '//*[@class="variant"]' 3
// @matches - '//pre[@class="rust item-decl"]//code' "enum TyKind"
// @has - '//pre[@class="rust item-decl"]//code/a[1]' "Adt"
// @has - '//pre[@class="rust item-decl"]//code/a[2]' "Adt"
// @has - '//pre[@class="rust item-decl"]//code/a[3]' "Ty"
// @has - '//pre[@class="rust item-decl"]//code/a[4]' "i64"
pub type TyKind = IrTyKind<i64, TyCtxt>;

// @has 'inner_variants/union.OneOr.html'
pub union OneOr<A: Copy> {
    pub one: i64,
    pub or: A,
}

// @has 'inner_variants/type.OneOrF64.html'
// @count - '//*[@id="aliased-type"]' 1
// @count - '//*[@id="variants"]' 0
// @count - '//*[@id="fields"]' 1
// @count - '//*[@class="structfield section-header"]' 2
// @matches - '//pre[@class="rust item-decl"]//code' "union OneOrF64"
pub type OneOrF64 = OneOr<f64>;

// @has 'inner_variants/struct.One.html'
pub struct One<T> {
    pub val: T,
    #[doc(hidden)]
    pub __hidden: T,
    __private: T,
}

// @has 'inner_variants/type.OneU64.html'
// @count - '//*[@id="aliased-type"]' 1
// @count - '//*[@id="variants"]' 0
// @count - '//*[@id="fields"]' 1
// @count - '//*[@class="structfield section-header"]' 1
// @matches - '//pre[@class="rust item-decl"]//code' "struct OneU64"
// @matches - '//pre[@class="rust item-decl"]//code' "pub val"
pub type OneU64 = One<u64>;

// @has 'inner_variants/struct.OnceA.html'
pub struct OnceA<'a, A> {
    pub a: &'a A,
}

// @has 'inner_variants/type.Once.html'
// @count - '//*[@id="aliased-type"]' 1
// @count - '//*[@id="variants"]' 0
// @count - '//*[@id="fields"]' 1
// @matches - '//pre[@class="rust item-decl"]//code' "struct Once<'a>"
// @matches - '//pre[@class="rust item-decl"]//code' "&'a"
pub type Once<'a> = OnceA<'a, i64>;

// @has 'inner_variants/struct.HighlyGenericStruct.html'
pub struct HighlyGenericStruct<A, B, C, D> {
    pub z: (A, B, C, D)
}

// @has 'inner_variants/type.HighlyGenericAABB.html'
// @count - '//*[@id="aliased-type"]' 1
// @count - '//*[@id="variants"]' 0
// @count - '//*[@id="fields"]' 1
// @matches - '//pre[@class="rust item-decl"]//code' "struct HighlyGenericAABB<A, B>"
// @matches - '//pre[@class="rust item-decl"]//code' "pub z"
pub type HighlyGenericAABB<A, B> = HighlyGenericStruct<A, A, B, B>;

// @has 'inner_variants/type.InlineU64.html'
// @count - '//*[@id="aliased-type"]' 1
// @count - '//*[@id="variants"]' 0
// @count - '//*[@id="fields"]' 1
pub use cross_crate_generic_typedef::InlineU64;