Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add long explanation for E0722 #87321

Merged
merged 4 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ E0716: include_str!("./error_codes/E0716.md"),
E0718: include_str!("./error_codes/E0718.md"),
E0719: include_str!("./error_codes/E0719.md"),
E0720: include_str!("./error_codes/E0720.md"),
E0722: include_str!("./error_codes/E0722.md"),
E0724: include_str!("./error_codes/E0724.md"),
E0725: include_str!("./error_codes/E0725.md"),
E0727: include_str!("./error_codes/E0727.md"),
Expand Down Expand Up @@ -634,7 +635,6 @@ E0783: include_str!("./error_codes/E0783.md"),
E0711, // a feature has been declared with conflicting stability attributes
E0717, // rustc_promotable without stability attribute
// E0721, // `await` keyword
E0722, // Malformed `#[optimize]` attribute
// E0723, unstable feature in `const` context
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
Expand Down
34 changes: 34 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0722.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
The `optimize` attribute was malformed.

Erroneous code example:

```compile_fail,E0722
#![feature(optimize_attribute)]

#[optimize(something)] // error: invalid argument
pub fn something() {}

fn main() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unneeded.

```

The `#[optimize]` attribute should be used as follows:

- `#[optimize(size)]` -- instructs the optimization pipeline to generate code
that's smaller rather than faster

- `#[optimize(speed)]` -- instructs the optimization pipeline to generate code
that's faster rather than smaller

For example:
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an empty line before this one.

#![feature(optimize_attribute)]

#[optimize(size)]
pub fn something() {}

fn main() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unneeded.

```

See [RFC 2412] for more details.
GuillaumeGomez marked this conversation as resolved.
Show resolved Hide resolved

[RFC 2412]: https://rust-lang.github.io/rfcs/2412-optimize-attr.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ LL | #[optimize(banana)]

error: aborting due to 6 previous errors

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