@@ -6,12 +6,12 @@ The following [attributes] affect compile-time limits.
6
6
7
7
The * ` recursion_limit ` attribute* may be applied at the [ crate] level to set the
8
8
maximum 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_ ]
10
10
syntax to specify the recursion depth.
11
11
12
12
> Note: The default in ` rustc ` is 64.
13
13
14
- ``` rust,ignore
14
+ ``` rust,compile_fail
15
15
#![recursion_limit = "4"]
16
16
17
17
macro_rules! a {
@@ -26,6 +26,13 @@ macro_rules! a {
26
26
a!{}
27
27
```
28
28
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
+
29
36
## The ` type_length_limit ` attribute
30
37
31
38
The * ` 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.
35
42
36
43
> Note: The default in ` rustc ` is 1048576.
37
44
38
- ``` rust,ignore
45
+ ``` rust,compile_fail
39
46
#![type_length_limit = "8"]
40
47
41
- type A = (B, B, B);
42
- type B = (C, C, C);
43
- struct C;
48
+ fn f<T>(x: T) {}
44
49
45
50
// 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) );
49
54
```
50
55
51
56
[ _MetaNameValueStr_ ] : attributes.html#meta-item-attribute-syntax
0 commit comments