diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-25 14:57:21 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-25 16:17:09 +1100 |
| commit | 399620939844d7b2e4a93e450f8c578960d0b6f2 (patch) | |
| tree | b83ad750522f061f1dae7093fdb8c0860f0bded8 /tests/ui/coverage-attr | |
| parent | 9124662da3e0d573703c9bb07d5e3cf8d06f1b20 (diff) | |
| download | rust-399620939844d7b2e4a93e450f8c578960d0b6f2.tar.gz rust-399620939844d7b2e4a93e450f8c578960d0b6f2.zip | |
Overhaul error messages for disallowed coverage attributes
Diffstat (limited to 'tests/ui/coverage-attr')
| -rw-r--r-- | tests/ui/coverage-attr/allowed-positions.stderr | 102 | ||||
| -rw-r--r-- | tests/ui/coverage-attr/name-value.stderr | 42 | ||||
| -rw-r--r-- | tests/ui/coverage-attr/word-only.stderr | 42 |
3 files changed, 124 insertions, 62 deletions
diff --git a/tests/ui/coverage-attr/allowed-positions.stderr b/tests/ui/coverage-attr/allowed-positions.stderr index 08a578ddd83..34562a4da1b 100644 --- a/tests/ui/coverage-attr/allowed-positions.stderr +++ b/tests/ui/coverage-attr/allowed-positions.stderr @@ -8,15 +8,17 @@ LL | let _closure_expr = #[coverage(off)] || (); = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:14:1 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | type MyTypeAlias = (); - | ---------------------- not a function or closure + | ---------------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:17:1 | LL | #[coverage(off)] @@ -27,9 +29,11 @@ LL | | const TRAIT_ASSOC_CONST: u32; ... | LL | | fn trait_assoc_fn(); LL | | } - | |_- not a function or closure + | |_- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:61:1 | LL | #[coverage(off)] @@ -38,119 +42,149 @@ LL | / struct MyStruct { LL | | #[coverage(off)] LL | | field: u32, LL | | } - | |_- not a function or closure + | |_- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:63:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | field: u32, - | ---------- not a function or closure + | ---------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:88:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | let _ = (); - | ----------- not a function or closure + | ----------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:94:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | let _let_closure = || (); - | ------------------------- not a function or closure + | ------------------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:110:9 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | () => (), - | -------- not a function or closure + | -------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:114:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | return (); - | --------- not a function or closure + | --------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:19:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | const TRAIT_ASSOC_CONST: u32; - | ----------------------------- not a function or closure + | ----------------------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:22:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | type TraitAssocType; - | -------------------- not a function or closure + | -------------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:25:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | fn trait_method(&self); - | ----------------------- not a function or closure + | ----------------------- function has no body + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:31:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | fn trait_assoc_fn(); - | -------------------- not a function or closure + | -------------------- function has no body + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:39:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | type TraitAssocType = Self; - | --------------------------- not a function or closure + | --------------------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:56:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | type T = impl Copy; - | ------------------- not a function or closure + | ------------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:76:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | static X: u32; - | -------------- not a function or closure + | -------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:79:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | type T; - | ------- not a function or closure + | ------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/allowed-positions.rs:82:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | fn foreign_fn(); - | ---------------- not a function or closure + | ---------------- function has no body + | + = help: coverage attribute can be applied to a function (with body), impl block, or module error: aborting due to 18 previous errors diff --git a/tests/ui/coverage-attr/name-value.stderr b/tests/ui/coverage-attr/name-value.stderr index 84a57f575f9..bfd22ed5451 100644 --- a/tests/ui/coverage-attr/name-value.stderr +++ b/tests/ui/coverage-attr/name-value.stderr @@ -154,16 +154,18 @@ LL | #[coverage(off)] LL | #[coverage(on)] | -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/name-value.rs:21:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | struct MyStruct; - | ---------------- not a function or closure + | ---------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/name-value.rs:35:1 | LL | #[coverage = "off"] @@ -174,52 +176,64 @@ LL | | #[coverage = "off"] ... | LL | | type T; LL | | } - | |_- not a function or closure + | |_- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/name-value.rs:39:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | const X: u32; - | ------------- not a function or closure + | ------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/name-value.rs:44:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | type T; - | ------- not a function or closure + | ------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/name-value.rs:29:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | const X: u32 = 7; - | ----------------- not a function or closure + | ----------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/name-value.rs:53:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | const X: u32 = 8; - | ----------------- not a function or closure + | ----------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/name-value.rs:58:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | type T = (); - | ------------ not a function or closure + | ------------ not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module error: aborting due to 19 previous errors diff --git a/tests/ui/coverage-attr/word-only.stderr b/tests/ui/coverage-attr/word-only.stderr index 97a0723988f..bad50b0c961 100644 --- a/tests/ui/coverage-attr/word-only.stderr +++ b/tests/ui/coverage-attr/word-only.stderr @@ -154,16 +154,18 @@ LL | #[coverage(off)] LL | #[coverage(on)] | -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/word-only.rs:21:1 | LL | #[coverage] | ^^^^^^^^^^^ ... LL | struct MyStruct; - | ---------------- not a function or closure + | ---------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/word-only.rs:35:1 | LL | #[coverage] @@ -174,52 +176,64 @@ LL | | #[coverage] ... | LL | | type T; LL | | } - | |_- not a function or closure + | |_- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/word-only.rs:39:5 | LL | #[coverage] | ^^^^^^^^^^^ ... LL | const X: u32; - | ------------- not a function or closure + | ------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/word-only.rs:44:5 | LL | #[coverage] | ^^^^^^^^^^^ ... LL | type T; - | ------- not a function or closure + | ------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/word-only.rs:29:5 | LL | #[coverage] | ^^^^^^^^^^^ ... LL | const X: u32 = 7; - | ----------------- not a function or closure + | ----------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/word-only.rs:53:5 | LL | #[coverage] | ^^^^^^^^^^^ ... LL | const X: u32 = 8; - | ----------------- not a function or closure + | ----------------- not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module -error[E0788]: attribute should be applied to a function definition or closure +error[E0788]: coverage attribute not allowed here --> $DIR/word-only.rs:58:5 | LL | #[coverage] | ^^^^^^^^^^^ ... LL | type T = (); - | ------------ not a function or closure + | ------------ not a function, impl block, or module + | + = help: coverage attribute can be applied to a function (with body), impl block, or module error: aborting due to 19 previous errors |
