Files
rust/tests/ui/attributes/optimize.stderr
Nicholas Nethercote 35b1187a65 Improve consistency of InvalidTarget attribute error messages
Mostly in a fashion similar to the previous commit.

There is one exceptional case: for errors involving `repr` the argument
is significant. For these, the argument is included in the error line
and the caret highlighting, e.g.
```
error: the `repr(C)` attribute cannot be used on functions
  --> $DIR/naked-with-invalid-repr-attr.rs:10:3
   |
LL | #[repr(C)]
   |   ^^^^^^^
   |
   = help: the `repr(C)` attribute can only be applied to data types
```

Contrast this with a more typical argument-excluding case used
everywhere else:
```
error: the `rustc_abi` attribute cannot be used on associated consts
  --> $DIR/debug.rs:46:7
   |
LL |     #[rustc_abi(debug)]
   |       ^^^^^^^^^
   |
   = help: the `rustc_abi` attribute can be applied to functions and type aliases
```
2026-07-24 12:58:31 +10:00

83 lines
2.1 KiB
Plaintext

error: the `optimize` attribute cannot be used on structs
--> $DIR/optimize.rs:8:3
|
LL | #[optimize(speed)]
| ^^^^^^^^
|
= help: the `optimize` attribute can only be applied to functions
error: the `optimize` attribute cannot be used on expressions
--> $DIR/optimize.rs:12:7
|
LL | #[optimize(speed)]
| ^^^^^^^^
|
= help: the `optimize` attribute can only be applied to functions
error: the `optimize` attribute cannot be used on modules
--> $DIR/optimize.rs:21:3
|
LL | #[optimize(speed)]
| ^^^^^^^^
|
= help: the `optimize` attribute can only be applied to functions
error: the `optimize` attribute cannot be used on inherent impl blocks
--> $DIR/optimize.rs:24:3
|
LL | #[optimize(speed)]
| ^^^^^^^^
|
= help: the `optimize` attribute can only be applied to functions
error: the `optimize` attribute cannot be used on required trait methods
--> $DIR/optimize.rs:45:7
|
LL | #[optimize(speed)]
| ^^^^^^^^
|
= help: the `optimize` attribute can only be applied to functions with a body
error: multiple `optimize` attributes
--> $DIR/optimize.rs:59:1
|
LL | #[optimize(speed)]
| ^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/optimize.rs:58:1
|
LL | #[optimize(speed)]
| ^^^^^^^^^^^^^^^^^^
error: multiple `optimize` attributes
--> $DIR/optimize.rs:63:1
|
LL | #[optimize(size)]
| ^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/optimize.rs:62:1
|
LL | #[optimize(speed)]
| ^^^^^^^^^^^^^^^^^^
error: `#[optimize(none)]` cannot be used with `#[inline]` attributes
--> $DIR/optimize.rs:66:1
|
LL | #[optimize(none)]
| ^^^^^^^^^^^^^^^^^ `#[optimize(none)]` here
LL | #[inline]
| --------- `#[inline]` here
error: `#[optimize(none)]` cannot be used with `#[inline]` attributes
--> $DIR/optimize.rs:71:1
|
LL | #[inline(always)]
| ----------------- `#[inline]` here
LL | #[optimize(none)]
| ^^^^^^^^^^^^^^^^^ `#[optimize(none)]` here
error: aborting due to 9 previous errors