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
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'inner_variants/type.AliasTy.html'
|
|
|
|
//@ count - '//*[@id="variants"]' 0
|
|
|
|
//@ count - '//*[@id="fields"]' 0
|
2023-08-15 07:13:17 -05:00
|
|
|
pub type AliasTy = Ty;
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ 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
|
|
|
}
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'inner_variants/type.NearlyTyKind.html'
|
|
|
|
//@ count - '//*[@id="aliased-type"]' 1
|
|
|
|
//@ count - '//*[@id="variants"]' 1
|
|
|
|
//@ 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
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ 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"
|
2023-08-18 12:02:45 -05:00
|
|
|
pub type TyKind = IrTyKind<i64, TyCtxt>;
|
2023-08-15 07:13:17 -05:00
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'inner_variants/union.OneOr.html'
|
2023-08-15 07:13:17 -05:00
|
|
|
pub union OneOr<A: Copy> {
|
|
|
|
pub one: i64,
|
|
|
|
pub or: A,
|
|
|
|
}
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ 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"
|
2023-08-15 07:13:17 -05:00
|
|
|
pub type OneOrF64 = OneOr<f64>;
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'inner_variants/struct.One.html'
|
2023-08-15 07:13:17 -05:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ 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"
|
2023-08-15 07:13:17 -05:00
|
|
|
pub type OneU64 = One<u64>;
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'inner_variants/struct.OnceA.html'
|
2023-08-15 07:13:17 -05:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ 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"
|
2023-08-15 07:13:17 -05:00
|
|
|
pub type Once<'a> = OnceA<'a, i64>;
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'inner_variants/struct.HighlyGenericStruct.html'
|
2023-08-15 07:13:17 -05:00
|
|
|
pub struct HighlyGenericStruct<A, B, C, D> {
|
|
|
|
pub z: (A, B, C, D)
|
|
|
|
}
|
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ 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"
|
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
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'inner_variants/type.InlineU64.html'
|
|
|
|
//@ count - '//*[@id="aliased-type"]' 1
|
|
|
|
//@ count - '//*[@id="variants"]' 0
|
|
|
|
//@ count - '//*[@id="fields"]' 1
|
2023-08-16 10:12:04 -05:00
|
|
|
pub use cross_crate_generic_typedef::InlineU64;
|
2024-05-19 19:12:37 -05:00
|
|
|
|
2024-06-21 07:03:08 -05:00
|
|
|
//@ has 'inner_variants/type.InlineEnum.html'
|
|
|
|
//@ count - '//*[@id="aliased-type"]' 1
|
|
|
|
//@ count - '//*[@id="variants"]' 1
|
|
|
|
//@ count - '//*[@id="fields"]' 0
|
|
|
|
//@ count - '//*[@class="variant"]' 2
|
2024-05-19 19:12:37 -05:00
|
|
|
pub type InlineEnum = cross_crate_generic_typedef::GenericEnum<i32>;
|