Skip to content

Commit a39e98f

Browse files
committed
Add test for AdtDef::discriminant_for_variant polymorphic over parameter
1 parent becdd21 commit a39e98f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/ui-fulldeps/stable-mir/check_variant.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const CRATE_NAME: &str = "crate_variant_ty";
3131
fn test_def_tys() -> ControlFlow<()> {
3232
check_adt_mono();
3333
check_adt_poly();
34+
check_adt_poly2();
3435

3536
ControlFlow::Continue(())
3637
}
@@ -75,6 +76,26 @@ fn check_adt_poly() {
7576
);
7677
}
7778

79+
fn check_adt_poly2() {
80+
let poly = get_fn("poly2").expect_body();
81+
82+
check_statement_is_aggregate_assign(
83+
&poly.blocks[0].statements[0],
84+
0,
85+
RigidTy::Int(IntTy::Isize),
86+
);
87+
check_statement_is_aggregate_assign(
88+
&poly.blocks[1].statements[0],
89+
1,
90+
RigidTy::Int(IntTy::Isize),
91+
);
92+
check_statement_is_aggregate_assign(
93+
&poly.blocks[2].statements[0],
94+
2,
95+
RigidTy::Int(IntTy::Isize),
96+
);
97+
}
98+
7899
fn get_fn(name: &str) -> CrateItem {
79100
stable_mir::all_local_items().into_iter().find(|it| it.name().eq(name)).unwrap()
80101
}
@@ -135,6 +156,8 @@ fn generate_input(path: &str) -> std::io::Result<()> {
135156
136157
pub fn main() {{
137158
mono();
159+
poly();
160+
poly2::<i32>(1);
138161
}}
139162
140163
fn mono() {{
@@ -148,6 +171,12 @@ fn generate_input(path: &str) -> std::io::Result<()> {
148171
black_box(Poly::B(1i32));
149172
black_box(Poly::C {{ t: 1i32 }});
150173
}}
174+
175+
fn poly2<T: Copy>(t: T) {{
176+
black_box(Poly::<T>::A);
177+
black_box(Poly::B(t));
178+
black_box(Poly::C {{ t: t }});
179+
}}
151180
"#
152181
)?;
153182
Ok(())

0 commit comments

Comments
 (0)