Skip to content

Commit b28c987

Browse files
Rollup merge of rust-lang#129757 - saethlin:half-a-recursion, r=compiler-errors
Add a test for trait solver overflow in MIR inliner cycle detection This test is a combination of the reproducer posted here: rust-lang#128887 (comment) and the existing test for polymorphic recursion: https://github.com/rust-lang/rust/blob/784d444733d65c3d305ce5edcbb41e3d0d0aee2e/tests/mir-opt/inline/polymorphic_recursion.rs r? `@compiler-errors`
2 parents c6a17b1 + c71ede3 commit b28c987

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/mir-opt/inline/type_overflow.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// This is a regression test for one of the problems in #128887; it checks that the
2+
// strategy in #129714 avoids trait solver overflows in this specific case.
3+
4+
// skip-filecheck
5+
//@ compile-flags: -Zinline-mir
6+
7+
pub trait Foo {
8+
type Associated;
9+
type Chain: Foo<Associated = Self::Associated>;
10+
}
11+
12+
trait FooExt {
13+
fn do_ext() {}
14+
}
15+
impl<T: Foo<Associated = f64>> FooExt for T {}
16+
17+
#[allow(unconditional_recursion)]
18+
fn recurse<T: Foo<Associated = f64>>() {
19+
T::do_ext();
20+
recurse::<T::Chain>();
21+
}
22+
23+
macro_rules! emit {
24+
($($m:ident)*) => {$(
25+
pub fn $m<T: Foo<Associated = f64>>() {
26+
recurse::<T>();
27+
}
28+
)*}
29+
}
30+
31+
// Increase the chance of triggering the bug
32+
emit!(m00 m01 m02 m03 m04 m05 m06 m07 m08 m09 m10 m11 m12 m13 m14 m15 m16 m17 m18 m19);

0 commit comments

Comments
 (0)