]> git.lizzy.rs Git - rust.git/commitdiff
Add long explanation for E0722
authorChris Midgley <chris.midgley@dunecomputers.co.uk>
Tue, 20 Jul 2021 19:13:08 +0000 (20:13 +0100)
committerChris Midgley <chris.midgley@dunecomputers.co.uk>
Tue, 20 Jul 2021 19:30:07 +0000 (20:30 +0100)
compiler/rustc_error_codes/src/error_codes.rs
compiler/rustc_error_codes/src/error_codes/E0722.md [new file with mode: 0644]
src/test/ui/feature-gates/feature-gate-optimize_attribute.stderr

index df162f8dce0267456005a54055e3dd31e2127d88..902c7c47873234e48e4d560074578cfa7b2e9729 100644 (file)
 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"),
     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" { ... }`.
diff --git a/compiler/rustc_error_codes/src/error_codes/E0722.md b/compiler/rustc_error_codes/src/error_codes/E0722.md
new file mode 100644 (file)
index 0000000..4a687d7
--- /dev/null
@@ -0,0 +1,24 @@
+The `optimize` attribute was malformed.
+
+Erroneous code example:
+
+```compile_fail,E0722
+#![feature(optimize_attribute)]
+
+#[optimize(something)] // error: invalid argument
+pub fn something() {}
+
+fn main() {}
+```
+
+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
+
+See [RFC 2412] for more details.
+
+[RFC 2412]: https://rust-lang.github.io/rfcs/2412-optimize-attr.html
index 50ce6427e8b584cd497a51e58f7c5768d1514310..a3ced35155f370a465449d788fe91e75202c83aa 100644 (file)
@@ -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`.