summaryrefslogtreecommitdiffstats
path: root/src/test/mir-opt/inline/polymorphic-recursion.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:06:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:06:37 +0000
commit246f239d9f40f633160f0c18f87a20922d4e77bb (patch)
tree5a88572663584b3d4d28e5a20e10abab1be40884 /src/test/mir-opt/inline/polymorphic-recursion.rs
parentReleasing progress-linux version 1.64.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-246f239d9f40f633160f0c18f87a20922d4e77bb.tar.xz
rustc-246f239d9f40f633160f0c18f87a20922d4e77bb.zip
Merging debian version 1.65.0+dfsg1-2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/mir-opt/inline/polymorphic-recursion.rs')
-rw-r--r--src/test/mir-opt/inline/polymorphic-recursion.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/mir-opt/inline/polymorphic-recursion.rs b/src/test/mir-opt/inline/polymorphic-recursion.rs
new file mode 100644
index 000000000..7388722b7
--- /dev/null
+++ b/src/test/mir-opt/inline/polymorphic-recursion.rs
@@ -0,0 +1,25 @@
+// Make sure that the MIR inliner does not loop indefinitely on polymorphic recursion.
+// compile-flags: --crate-type lib
+
+// Randomize `def_path_hash` by defining them under a module with different names
+macro_rules! emit {
+ ($($m:ident)*) => {$(
+ 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>();
+ 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);