Match the enum and union

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
hi-rustin 2022-03-17 21:18:52 +08:00
parent c6ef4e830e
commit 2bc545d9ef
2 changed files with 62 additions and 13 deletions

View file

@ -306,6 +306,7 @@ fn func() {
ev TupleV() TupleV(u32)
ev RecordV {} RecordV { field: u32 }
ev UnitV UnitV
ct ASSOC_CONST const ASSOC_CONST: ()
"#]],
);
}
@ -466,5 +467,53 @@ fn f(t: Ty) {
expect![[r#"
ct ABC const ABC: Self
"#]],
);
check_empty(
r#"
struct MyEnum;
impl MyEnum {
pub const A: i32 = 123;
pub const B: i32 = 456;
}
fn f(e: MyEnum) {
match e {
MyEnum::$0 => {}
_ => {}
}
}
"#,
expect![[r#"
ct A pub const A: i32
ct B pub const B: i32
"#]],
);
check_empty(
r#"
#[repr(C)]
union U {
i: i32,
f: f32,
}
impl U {
pub const C: i32 = 123;
pub const D: i32 = 456;
}
fn f(u: U) {
match u {
U::$0 => {}
_ => {}
}
}
"#,
expect![[r#"
ct C pub const C: i32
ct D pub const D: i32
"#]],
)
}