2023-08-16 10:12:04 -05:00
|
|
|
// This test checks different combinations of structs, enums, and unions
|
|
|
|
// for the "Show Aliased Type" feature on type definition.
|
|
|
|
|
2023-08-15 07:13:17 -05:00
|
|
|
#![crate_name = "inner_variants"]
|
|
|
|
|
2023-08-16 10:12:04 -05:00
|
|
|
// aux-build:cross_crate_generic_typedef.rs
|
|
|
|
extern crate cross_crate_generic_typedef;
|
|
|
|
|
2023-08-15 07:13:17 -05:00
|
|
|
pub struct Adt;
|
|
|
|
pub struct Ty;
|
2023-08-18 12:02:45 -05:00
|
|
|
pub struct TyCtxt;
|
|
|
|
|
|
|
|
pub trait Interner {
|
|
|
|
type Adt;
|
|
|
|
type Ty;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Interner for TyCtxt {
|
|
|
|
type Adt = Adt;
|
|
|
|
type Ty = Ty;
|
|
|
|
}
|
2023-08-15 07:13:17 -05:00
|
|
|
|
|
|
|
// @has 'inner_variants/type.AliasTy.html'
|
|
|
|
// @count - '//*[@id="variants"]' 0
|
|
|
|
// @count - '//*[@id="fields"]' 0
|
|
|
|
pub type AliasTy = Ty;
|
|
|
|
|
|
|
|
// @has 'inner_variants/enum.IrTyKind.html'
|
2023-08-18 12:02:45 -05:00
|
|
|
pub enum IrTyKind<A, I: Interner> {
|
2023-08-15 07:13:17 -05:00
|
|
|
/// Doc comment for AdtKind
|
2023-08-18 12:02:45 -05:00
|
|
|
AdtKind(I::Adt),
|
2023-08-15 07:13:17 -05:00
|
|
|
/// and another one for TyKind
|
2023-08-18 12:02:45 -05:00
|
|
|
TyKind(I::Adt, <I as Interner>::Ty),
|
2023-08-15 07:13:17 -05:00
|
|
|
// no comment
|
|
|
|
StructKind { a: A, },
|
2023-08-18 10:57:20 -05:00
|
|
|
#[doc(hidden)]
|
|
|
|
Unspecified,
|
2023-08-15 07:13:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// @has 'inner_variants/type.NearlyTyKind.html'
|
2023-08-25 16:07:03 -05:00
|
|
|
// @count - '//*[@id="aliased-type"]' 1
|
|
|
|
// @count - '//*[@id="variants"]' 1
|
2023-08-15 07:13:17 -05:00
|
|
|
// @count - '//*[@id="fields"]' 0
|
2023-08-18 12:02:45 -05:00
|
|
|
pub type NearlyTyKind<A> = IrTyKind<A, TyCtxt>;
|
2023-08-15 07:13:17 -05:00
|
|
|
|
|
|
|
// @has 'inner_variants/type.TyKind.html'
|
2023-08-25 15:36:58 -05:00
|
|
|
// @count - '//*[@id="aliased-type"]' 1
|
2023-08-15 07:13:17 -05:00
|
|
|
// @count - '//*[@id="variants"]' 1
|
|
|
|
// @count - '//*[@id="fields"]' 0
|
|
|
|
// @count - '//*[@class="variant"]' 3
|
2023-08-25 15:36:58 -05:00
|
|
|
// @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"
|
2023-08-18 12:02:45 -05:00
|
|
|
pub type TyKind = IrTyKind<i64, TyCtxt>;
|
2023-08-15 07:13:17 -05:00
|
|
|
|
|
|
|
// @has 'inner_variants/union.OneOr.html'
|
|
|
|
pub union OneOr<A: Copy> {
|
|
|
|
pub one: i64,
|
|
|
|
pub or: A,
|
|
|
|
}
|
|
|
|
|
|
|
|
// @has 'inner_variants/type.OneOrF64.html'
|
2023-08-25 15:36:58 -05:00
|
|
|
// @count - '//*[@id="aliased-type"]' 1
|
2023-08-15 07:13:17 -05:00
|
|
|
// @count - '//*[@id="variants"]' 0
|
|
|
|
// @count - '//*[@id="fields"]' 1
|
|
|
|
// @count - '//*[@class="structfield small-section-header"]' 2
|
2023-08-25 15:36:58 -05:00
|
|
|
// @matches - '//pre[@class="rust item-decl"]//code' "union OneOrF64"
|
2023-08-15 07:13:17 -05:00
|
|
|
pub type OneOrF64 = OneOr<f64>;
|
|
|
|
|
|
|
|
// @has 'inner_variants/struct.One.html'
|
|
|
|
pub struct One<T> {
|
|
|
|
pub val: T,
|
2023-08-18 10:57:20 -05:00
|
|
|
#[doc(hidden)]
|
|
|
|
pub __hidden: T,
|
|
|
|
__private: T,
|
2023-08-15 07:13:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// @has 'inner_variants/type.OneU64.html'
|
2023-08-25 15:36:58 -05:00
|
|
|
// @count - '//*[@id="aliased-type"]' 1
|
2023-08-15 07:13:17 -05:00
|
|
|
// @count - '//*[@id="variants"]' 0
|
|
|
|
// @count - '//*[@id="fields"]' 1
|
|
|
|
// @count - '//*[@class="structfield small-section-header"]' 1
|
2023-08-25 15:36:58 -05:00
|
|
|
// @matches - '//pre[@class="rust item-decl"]//code' "struct OneU64"
|
|
|
|
// @matches - '//pre[@class="rust item-decl"]//code' "pub val"
|
2023-08-15 07:13:17 -05:00
|
|
|
pub type OneU64 = One<u64>;
|
|
|
|
|
|
|
|
// @has 'inner_variants/struct.OnceA.html'
|
|
|
|
pub struct OnceA<'a, A> {
|
2023-08-18 12:02:45 -05:00
|
|
|
pub a: &'a A,
|
2023-08-15 07:13:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// @has 'inner_variants/type.Once.html'
|
2023-08-25 15:36:58 -05:00
|
|
|
// @count - '//*[@id="aliased-type"]' 1
|
2023-08-15 07:13:17 -05:00
|
|
|
// @count - '//*[@id="variants"]' 0
|
2023-08-18 12:02:45 -05:00
|
|
|
// @count - '//*[@id="fields"]' 1
|
2023-08-25 15:36:58 -05:00
|
|
|
// @matches - '//pre[@class="rust item-decl"]//code' "struct Once<'a>"
|
|
|
|
// @matches - '//pre[@class="rust item-decl"]//code' "&'a"
|
2023-08-15 07:13:17 -05:00
|
|
|
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'
|
2023-08-25 15:36:58 -05:00
|
|
|
// @count - '//*[@id="aliased-type"]' 1
|
2023-08-15 07:13:17 -05:00
|
|
|
// @count - '//*[@id="variants"]' 0
|
2023-08-25 16:07:03 -05:00
|
|
|
// @count - '//*[@id="fields"]' 1
|
|
|
|
// @matches - '//pre[@class="rust item-decl"]//code' "struct HighlyGenericAABB<A, B>"
|
|
|
|
// @matches - '//pre[@class="rust item-decl"]//code' "pub z"
|
2023-08-15 07:13:17 -05:00
|
|
|
pub type HighlyGenericAABB<A, B> = HighlyGenericStruct<A, A, B, B>;
|
2023-08-16 10:12:04 -05:00
|
|
|
|
|
|
|
// @has 'inner_variants/type.InlineU64.html'
|
2023-08-25 15:36:58 -05:00
|
|
|
// @count - '//*[@id="aliased-type"]' 1
|
2023-08-16 10:12:04 -05:00
|
|
|
// @count - '//*[@id="variants"]' 0
|
|
|
|
// @count - '//*[@id="fields"]' 1
|
|
|
|
pub use cross_crate_generic_typedef::InlineU64;
|