diff --git a/tests/ui/codegen/normalization-overflow/recursion-issue-137823.rs b/tests/ui/codegen/normalization-overflow/recursion-issue-137823.rs new file mode 100644 index 000000000000..4ae8d84eba11 --- /dev/null +++ b/tests/ui/codegen/normalization-overflow/recursion-issue-137823.rs @@ -0,0 +1,39 @@ +//@ build-fail + +// Regression test for issue #137823 +// Tests that recursive monomorphization with associated types produces +// a proper "recursion limit" error instead of an ICE. + +fn convert() -> S::Out { + convert2::>() + //~^ ERROR: reached the recursion limit while instantiating +} + +fn convert2() -> S::Out { + convert::() +} + +fn main() { + convert::(); +} + +trait Converter { + type Out; +} + +struct Ser; + +impl Converter for Ser { + type Out = (); +} + +struct ConvertWrap { + _d: S, +} + +impl Converter for ConvertWrap +where + S: Converter, +{ + type Out = S::Out; +} diff --git a/tests/ui/codegen/normalization-overflow/recursion-issue-137823.stderr b/tests/ui/codegen/normalization-overflow/recursion-issue-137823.stderr new file mode 100644 index 000000000000..3d80c45685f5 --- /dev/null +++ b/tests/ui/codegen/normalization-overflow/recursion-issue-137823.stderr @@ -0,0 +1,14 @@ +error: reached the recursion limit while instantiating `convert2::>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/recursion-issue-137823.rs:8:5 + | +LL | convert2::>() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `convert2` defined here + --> $DIR/recursion-issue-137823.rs:12:1 + | +LL | fn convert2() -> S::Out { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error +