diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/mir/issue-100476-recursion-check-blewup.rs | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/mir/issue-100476-recursion-check-blewup.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/test/ui/mir/issue-100476-recursion-check-blewup.rs b/src/test/ui/mir/issue-100476-recursion-check-blewup.rs new file mode 100644 index 000000000..bc2f32f4c --- /dev/null +++ b/src/test/ui/mir/issue-100476-recursion-check-blewup.rs @@ -0,0 +1,42 @@ +// check-pass + +// compile-flags: --emit=mir,link -O + +// At one point the MIR inlining, when guarding against infinitely (or even just +// excessive) recursion, was using `ty::Instance` as the basis for its history +// check. The problem is that when you have polymorphic recursion, you can have +// distinct instances of the same code (because you're inlining the same code +// with differing substitutions), causing the amount of inlining to blow up +// exponentially. +// +// This test illustrates an example of that filed in issue rust#100476. + +#![allow(unconditional_recursion)] +#![feature(decl_macro)] + +macro emit($($m:ident)*) {$( + // Randomize `def_path_hash` by defining them under a module with + // different names + pub mod $m { + pub trait Tr { + type Next: Tr; + } + + pub fn hoge<const N: usize, T: Tr>() { + inner::<N, T>(); + } + + #[inline(always)] + fn inner<const N: usize, T: Tr>() { + inner::<N, T::Next>(); + } + } +)*} + +// Increase the chance of triggering the bug +emit!( + m00 m01 m02 m03 m04 m05 m06 m07 m08 m09 + m10 m11 m12 m13 m14 m15 m16 m17 m18 m19 +); + +fn main() { } |