You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> `rustc` currently warns in other positions, but this may be rejected in the future.
64
-
65
-
> [!NOTE]
66
-
> `rustc` currently warns on some positions where it is ignored, but this may become an error in the future.
116
+
> `rustc` ignoresusein other positions but lints against it.This may become an error in the future.
67
117
68
118
----
69
119
@@ -72,29 +122,40 @@ Explain the behavior if the attribute is specified multiple times on an element.
72
122
73
123
----
74
124
75
-
Duplicate instances of the `example` attribute on the same ... have no effect.
125
+
The`example` attribute may be used any number of times on a form.
76
126
77
127
----
78
128
79
-
The`example`attribute may only be specified once on a [THING].
129
+
Using `example` more than once on a form has the same effect as using it once.
80
130
81
131
----
82
132
83
-
Only the first instance of `example` on an item is honored. Subsequent `example` attributes are ignored.
133
+
The `example` attribute may be used only once on ...
134
+
135
+
----
136
+
137
+
Only the first use of `example` on an item has effect.
138
+
139
+
> [!NOTE]
140
+
> `rustc` lints against any use following the first.This may become an error in the future.
84
141
85
142
> [!NOTE]
86
-
> `rustc`currently warns on subsequent duplicate `example` attributes. This may become an error in the future.
143
+
> `rustc` lints against any use following the first with a future-compatibility warning.This may become an error in the future.
87
144
88
145
----
89
146
90
-
Only the last instance of `example` on an item is honored. Previous `example` attributes are ignored.
147
+
Only the last use of `example` on an item has effect.
91
148
92
149
> [!NOTE]
93
-
> `rustc`currently warns on preceding duplicate `example` attributes. This may become an error in the future.
150
+
> `rustc` lints against any usepreceding the last.This may become an error in the future.
94
151
95
-
---
152
+
----
153
+
154
+
Only the last use of `example` on an item is used to ...
155
+
156
+
----
96
157
97
-
If the `example` attribute is specified multiple times on an item, then the combination of all the specified values is used as ...explain how they are merged.
158
+
If the `example` attribute is used more than once on an item, then the combination of all the specified values is used as...explain how they are merged.
Copy file name to clipboardExpand all lines: src/attributes/limits.md
+30-16Lines changed: 30 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,34 +40,48 @@ a!{}
40
40
(|_: &u8| {})(&&&1);
41
41
```
42
42
43
+
<!-- template:attributes -->
43
44
r[attributes.limits.type_length_limit]
44
45
## The `type_length_limit` attribute
45
46
47
+
r[attributes.limits.type_length_limit.intro]
48
+
The *`type_length_limit`[attribute][attributes]* sets the maximum number of type substitutions allowed when constructing a concrete type during monomorphization.
49
+
46
50
> [!NOTE]
47
-
> This limit is only enforced when the nightly `-Zenforce-type-length-limit` flag is active.
51
+
> `rustc` only enforces the limit when the nightly `-Zenforce-type-length-limit` flag is active.
48
52
>
49
-
> For more information, see <https://github.com/rust-lang/rust/pull/127670>.
53
+
> For more information, see [Rust PR #127670](https://github.com/rust-lang/rust/pull/127670).
50
54
51
-
r[attributes.limits.type_length_limit.intro]
52
-
The *`type_length_limit` attribute* limits the maximum number of type
53
-
substitutions made when constructing a concrete type during monomorphization.
55
+
> [!EXAMPLE]
56
+
> <!-- ignore: not enforced without nightly flag -->
57
+
> ```rust,ignore
58
+
> #![type_length_limit = "4"]
59
+
>
60
+
> fn f<T>(x: T) {}
61
+
>
62
+
> // This fails to compile because monomorphizing to
63
+
> // `f::<((((i32,), i32), i32), i32)>` requires more
64
+
> // than 4 type elements.
65
+
> f(((((1,), 2), 3), 4));
66
+
> ```
67
+
68
+
> [!NOTE]
69
+
> The default value in `rustc` is `1048576`.
54
70
55
71
r[attributes.limits.type_length_limit.syntax]
56
-
It is applied at the [crate] level, and uses the [MetaNameValueStr] syntax
57
-
to set the limit based on the number of type substitutions.
72
+
The `type_length_limit` attribute uses the [MetaNameValueStr] syntax. The value in the string must be a non-negative number.
Copy file name to clipboardExpand all lines: src/attributes/testing.md
+15-12Lines changed: 15 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ tests. Compiling a crate in "test" mode enables building the test functions
6
6
along with a test harness for executing the tests. Enabling the test mode also
7
7
enables the [`test` conditional compilation option].
8
8
9
+
<!-- template:attributes -->
9
10
r[attributes.testing.test]
10
11
## The `test` attribute
11
12
@@ -23,7 +24,7 @@ The *`test` [attribute][attributes]* marks a function to be executed as a test.
23
24
> ```
24
25
25
26
r[attributes.testing.test.syntax]
26
-
The `test` attribute uses the [MetaWord] syntax and thus does not take any inputs.
27
+
The `test` attribute uses the [MetaWord] syntax.
27
28
28
29
r[attributes.testing.test.allowed-positions]
29
30
The `test` attribute may only be applied to [free functions] that are monomorphic, that take no arguments, and where the return type implements the [`Termination`] trait.
@@ -34,10 +35,10 @@ The `test` attribute may only be applied to [free functions] that are monomorphi
34
35
> * `Result<T, E> where T: Termination, E: Debug`
35
36
36
37
r[attributes.testing.test.duplicates]
37
-
Only the first instance of `test` on a function is honored.
38
+
Only the first use of `test` on a function has effect.
38
39
39
40
> [!NOTE]
40
-
> Subsequent `test` attributes are currently ignored and `rustc` warns about these.
41
+
> `rustc` lints against any use following the first. This may become an error in the future.
41
42
42
43
<!-- TODO: This is a minor lie. Currently rustc warns that duplicates are ignored, but it then generates multiple test entries with the same name. I would vote for rejecting this in the future. -->
43
44
@@ -71,6 +72,7 @@ In particular:
71
72
> }
72
73
> ```
73
74
75
+
<!-- template:attributes -->
74
76
r[attributes.testing.ignore]
75
77
## The `ignore` attribute
76
78
@@ -90,7 +92,7 @@ The *`ignore` [attribute][attributes]* can be used with the [`test` attribute][a
90
92
> The `rustc` test harness supports the `--include-ignored` flag to force ignored tests to be run.
91
93
92
94
r[attributes.testing.ignore.syntax]
93
-
The `ignore` attribute uses either the [MetaWord] or [MetaNameValueStr] syntax.
95
+
The `ignore` attribute uses the [MetaWord] and [MetaNameValueStr] syntaxes.
94
96
95
97
r[attributes.testing.ignore.reason]
96
98
The [MetaNameValueStr] form of the `ignore` attribute provides a way to specify a reason why the test is ignored.
@@ -105,20 +107,21 @@ The [MetaNameValueStr] form of the `ignore` attribute provides a way to specify
105
107
> ```
106
108
107
109
r[attributes.testing.ignore.allowed-positions]
108
-
The `ignore` attribute may be applied to functions annotated with the `test` attribute.
110
+
The `ignore` attribute may only be applied to functions annotated with the `test` attribute.
109
111
110
112
> [!NOTE]
111
-
> `rustc` currently warns when `ignore` is used in some other situations. This may become an error in the future.
113
+
> `rustc` ignores use in other positions but lints against it. This may become an error in the future.
112
114
113
115
r[attributes.testing.ignore.duplicates]
114
-
Only the first instance of `ignore` on a function is honored.
116
+
Only the first use of `ignore` on a function has effect.
115
117
116
118
> [!NOTE]
117
-
> `rustc` currently ignores duplicate `ignore` attributes. This may become an error in the future.
119
+
> `rustc` lints against any use following the first. This may become an error in the future.
118
120
119
121
r[attributes.testing.ignore.behavior]
120
122
Ignored tests are still compiled when in test mode, but they are not executed.
121
123
124
+
<!-- template:attributes -->
122
125
r[attributes.testing.should_panic]
123
126
## The `should_panic` attribute
124
127
@@ -135,7 +138,7 @@ The *`should_panic` [attribute][attributes]* causes a test to pass only if the [
135
138
> ```
136
139
137
140
r[attributes.testing.should_panic.syntax]
138
-
The `should_panic` attribute has one of the following forms:
The `should_panic` attribute may only be applied to functions annotated with the `test` attribute.
166
169
167
170
> [!NOTE]
168
-
> `rustc` currently accepts this attribute in other positions with a warning. This may become a hard error in the future.
171
+
> `rustc` ignores use in other positions but lints against it. This may become an error in the future.
169
172
170
173
r[attributes.testing.should_panic.duplicates]
171
-
Only the first instance of `should_panic` on a function is honored.
174
+
Only the first use of `should_panic` on a function has effect.
172
175
173
176
> [!NOTE]
174
-
> `rustc` currently ignores subsequent `should_panic` attributes and emits a future-compatibility warning. This may become a hard error in the future.
177
+
> `rustc` lints against any use following the first with a future-compatibility warning. This may become an error in the future.
175
178
176
179
r[attributes.testing.should_panic.expected]
177
180
When the [MetaNameValueStr] form or the [MetaListNameValueStr] form with the `expected` key is used, the given string must appear somewhere within the panic message for the test to pass.
0 commit comments