about summary refs log tree commit diff
path: root/tests/ui/limits
diff options
context:
space:
mode:
authorKivooeo <Kivooeo123@gmail.com>2025-07-01 21:42:20 +0500
committerKivooeo <Kivooeo123@gmail.com>2025-07-01 21:42:20 +0500
commite9191ec57ee5bdd0961a22fd9852f361a5c97ea0 (patch)
treeb80afcfdeb6f41cfb107d212be070b6ca9773528 /tests/ui/limits
parentf46ce66fcc3d6058f90ac5bf0930f940f1e7b0ca (diff)
downloadrust-e9191ec57ee5bdd0961a22fd9852f361a5c97ea0.tar.gz
rust-e9191ec57ee5bdd0961a22fd9852f361a5c97ea0.zip
moved tests
Diffstat (limited to 'tests/ui/limits')
-rw-r--r--tests/ui/limits/type-length-limit-enforcement.rs34
-rw-r--r--tests/ui/limits/type-length-limit-enforcement.stderr15
2 files changed, 49 insertions, 0 deletions
diff --git a/tests/ui/limits/type-length-limit-enforcement.rs b/tests/ui/limits/type-length-limit-enforcement.rs
new file mode 100644
index 00000000000..87f5ffd76d7
--- /dev/null
+++ b/tests/ui/limits/type-length-limit-enforcement.rs
@@ -0,0 +1,34 @@
+//@ build-fail
+//@ compile-flags: -Copt-level=0 -Zenforce-type-length-limit
+//~^^ ERROR reached the type-length limit
+
+// Test that the type length limit can be changed.
+// The exact type depends on optimizations, so disable them.
+
+#![allow(dead_code)]
+#![type_length_limit="8"]
+
+macro_rules! link {
+    ($id:ident, $t:ty) => {
+        pub type $id = ($t, $t, $t);
+    }
+}
+
+link! { A1, B1 }
+link! { B1, C1 }
+link! { C1, D1 }
+link! { D1, E1 }
+link! { E1, A }
+link! { A, B }
+link! { B, C }
+link! { C, D }
+link! { D, E }
+link! { E, F }
+link! { F, G<Option<i32>, Option<i32>> }
+
+pub struct G<T, K>(std::marker::PhantomData::<(T, K)>);
+
+fn main() {
+    drop::<Option<A>>(None);
+    //~^ ERROR reached the type-length limit
+}
diff --git a/tests/ui/limits/type-length-limit-enforcement.stderr b/tests/ui/limits/type-length-limit-enforcement.stderr
new file mode 100644
index 00000000000..198d133c08c
--- /dev/null
+++ b/tests/ui/limits/type-length-limit-enforcement.stderr
@@ -0,0 +1,15 @@
+error: reached the type-length limit while instantiating `std::mem::drop::<Option<((((..., ..., ...), ..., ...), ..., ...), ..., ...)>>`
+  --> $DIR/type_length_limit.rs:32:5
+   |
+LL |     drop::<Option<A>>(None);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: consider adding a `#![type_length_limit="4010"]` attribute to your crate
+   = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit.long-type.txt'
+
+error: reached the type-length limit while instantiating `<{closure@rt::lang_start<()>::{closure#0}} as FnMut<()>>::call_mut`
+   |
+   = help: consider adding a `#![type_length_limit="10"]` attribute to your crate
+
+error: aborting due to 2 previous errors
+