Skip to content

Commit 23ecb8b

Browse files
Rollup merge of #87321 - midgleyc:add-E0722-long, r=GuillaumeGomez
Add long explanation for E0722 Helps with #61137
2 parents fc10326 + b24d491 commit 23ecb8b

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

Diff for: compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ E0716: include_str!("./error_codes/E0716.md"),
418418
E0718: include_str!("./error_codes/E0718.md"),
419419
E0719: include_str!("./error_codes/E0719.md"),
420420
E0720: include_str!("./error_codes/E0720.md"),
421+
E0722: include_str!("./error_codes/E0722.md"),
421422
E0724: include_str!("./error_codes/E0724.md"),
422423
E0725: include_str!("./error_codes/E0725.md"),
423424
E0727: include_str!("./error_codes/E0727.md"),
@@ -634,7 +635,6 @@ E0783: include_str!("./error_codes/E0783.md"),
634635
E0711, // a feature has been declared with conflicting stability attributes
635636
E0717, // rustc_promotable without stability attribute
636637
// E0721, // `await` keyword
637-
E0722, // Malformed `#[optimize]` attribute
638638
// E0723, unstable feature in `const` context
639639
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
640640
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.

Diff for: compiler/rustc_error_codes/src/error_codes/E0722.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
The `optimize` attribute was malformed.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0722
6+
#![feature(optimize_attribute)]
7+
8+
#[optimize(something)] // error: invalid argument
9+
pub fn something() {}
10+
```
11+
12+
The `#[optimize]` attribute should be used as follows:
13+
14+
- `#[optimize(size)]` -- instructs the optimization pipeline to generate code
15+
that's smaller rather than faster
16+
17+
- `#[optimize(speed)]` -- instructs the optimization pipeline to generate code
18+
that's faster rather than smaller
19+
20+
For example:
21+
22+
```
23+
#![feature(optimize_attribute)]
24+
25+
#[optimize(size)]
26+
pub fn something() {}
27+
```
28+
29+
See [RFC 2412] for more details.
30+
31+
[RFC 2412]: https://rust-lang.github.io/rfcs/2412-optimize-attr.html

Diff for: src/test/ui/feature-gates/feature-gate-optimize_attribute.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ LL | #[optimize(banana)]
5151

5252
error: aborting due to 6 previous errors
5353

54-
For more information about this error, try `rustc --explain E0658`.
54+
Some errors have detailed explanations: E0658, E0722.
55+
For more information about an error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)