@@ -6,12 +6,12 @@ The following [attributes] affect compile-time limits.
66
77The * ` recursion_limit ` attribute* may be applied at the [ crate] level to set the
88maximum depth for potentially infinitely-recursive compile-time operations
9- like auto-dereference or macro expansion. It uses the [ _ MetaNameValueStr_ ]
9+ like macro expansion or auto-dereference . It uses the [ _ MetaNameValueStr_ ]
1010syntax to specify the recursion depth.
1111
1212> Note: The default in ` rustc ` is 64.
1313
14- ``` rust,ignore
14+ ``` rust,compile_fail
1515#![recursion_limit = "4"]
1616
1717macro_rules! a {
@@ -26,6 +26,13 @@ macro_rules! a {
2626a!{}
2727```
2828
29+ ``` rust,compile_fail
30+ #![recursion_limit = "1"]
31+
32+ // This fails because it requires two recursive steps to auto-derefence.
33+ (|_: &u8| {})(&&1);
34+ ```
35+
2936## The ` type_length_limit ` attribute
3037
3138The * ` type_length_limit ` attribute* limits the maximum number of type
@@ -35,17 +42,15 @@ to set the limit based on the number of type substitutions.
3542
3643> Note: The default in ` rustc ` is 1048576.
3744
38- ``` rust,ignore
45+ ``` rust,compile_fail
3946#![type_length_limit = "8"]
4047
41- type A = (B, B, B);
42- type B = (C, C, C);
43- struct C;
48+ fn f<T>(x: T) {}
4449
4550// This fails to compile because monomorphizing to
46- // `drop ::<Option<((C, C, C), (C, C, C), (C, C, C)) >>` requires more than 8
47- // type elements.
48- drop::<Option<A>>(None );
51+ // `f ::<(i32, i32, i32, i32, i32, i32, i32, i32, i32) >>` requires more
52+ // than 8 type elements.
53+ f(((1, 2, 3, 4, 5, 6, 7, 8, 9) );
4954```
5055
5156[ _MetaNameValueStr_ ] : attributes.html#meta-item-attribute-syntax
0 commit comments