diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d33f12a973fdc..5f8e4a8b7a761 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -369,13 +369,16 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } - /// Checks that `#[coverage(..)]` is applied to a function or closure. + /// Checks that `#[coverage(..)]` is applied to a function/closure/method, + /// or to an impl block or module. fn check_coverage(&self, attr: &Attribute, span: Span, target: Target) -> bool { match target { - // #[coverage(..)] on function is fine Target::Fn | Target::Closure - | Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true, + | Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) + | Target::Impl + | Target::Mod => true, + _ => { self.dcx().emit_err(errors::CoverageNotFnOrClosure { attr_span: attr.span, diff --git a/tests/coverage/attr/impl.cov-map b/tests/coverage/attr/impl.cov-map new file mode 100644 index 0000000000000..9b0deed8b64c0 --- /dev/null +++ b/tests/coverage/attr/impl.cov-map @@ -0,0 +1,24 @@ +Function name: ::off_on (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 00, 0e, 05, 00, 13] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Zero) at (prev + 14, 5) to (start + 0, 19) + +Function name: ::on_inherit (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 00, 16, 05, 00, 17] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Zero) at (prev + 22, 5) to (start + 0, 23) + +Function name: ::on_on (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 00, 19, 05, 00, 12] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Zero) at (prev + 25, 5) to (start + 0, 18) + diff --git a/tests/coverage/attr/impl.coverage b/tests/coverage/attr/impl.coverage new file mode 100644 index 0000000000000..560429fb5fe5d --- /dev/null +++ b/tests/coverage/attr/impl.coverage @@ -0,0 +1,42 @@ + LL| |#![feature(coverage_attribute)] + LL| |//@ edition: 2021 + LL| | + LL| |// Checks that `#[coverage(..)]` can be applied to impl and impl-trait blocks, + LL| |// and is inherited by any enclosed functions. + LL| | + LL| |struct MyStruct; + LL| | + LL| |#[coverage(off)] + LL| |impl MyStruct { + LL| | fn off_inherit() {} + LL| | + LL| | #[coverage(on)] + LL| 0| fn off_on() {} + LL| | + LL| | #[coverage(off)] + LL| | fn off_off() {} + LL| |} + LL| | + LL| |#[coverage(on)] + LL| |impl MyStruct { + LL| 0| fn on_inherit() {} + LL| | + LL| | #[coverage(on)] + LL| 0| fn on_on() {} + LL| | + LL| | #[coverage(off)] + LL| | fn on_off() {} + LL| |} + LL| | + LL| |trait MyTrait { + LL| | fn method(); + LL| |} + LL| | + LL| |#[coverage(off)] + LL| |impl MyTrait for MyStruct { + LL| | fn method() {} + LL| |} + LL| | + LL| |#[coverage(off)] + LL| |fn main() {} + diff --git a/tests/coverage/attr/impl.rs b/tests/coverage/attr/impl.rs new file mode 100644 index 0000000000000..d4d784a3502b9 --- /dev/null +++ b/tests/coverage/attr/impl.rs @@ -0,0 +1,41 @@ +#![feature(coverage_attribute)] +//@ edition: 2021 + +// Checks that `#[coverage(..)]` can be applied to impl and impl-trait blocks, +// and is inherited by any enclosed functions. + +struct MyStruct; + +#[coverage(off)] +impl MyStruct { + fn off_inherit() {} + + #[coverage(on)] + fn off_on() {} + + #[coverage(off)] + fn off_off() {} +} + +#[coverage(on)] +impl MyStruct { + fn on_inherit() {} + + #[coverage(on)] + fn on_on() {} + + #[coverage(off)] + fn on_off() {} +} + +trait MyTrait { + fn method(); +} + +#[coverage(off)] +impl MyTrait for MyStruct { + fn method() {} +} + +#[coverage(off)] +fn main() {} diff --git a/tests/coverage/attr/module.cov-map b/tests/coverage/attr/module.cov-map new file mode 100644 index 0000000000000..34898eb4ca81d --- /dev/null +++ b/tests/coverage/attr/module.cov-map @@ -0,0 +1,24 @@ +Function name: module::off::on (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 00, 0c, 05, 00, 0f] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Zero) at (prev + 12, 5) to (start + 0, 15) + +Function name: module::on::inherit (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 00, 14, 05, 00, 14] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Zero) at (prev + 20, 5) to (start + 0, 20) + +Function name: module::on::on (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 00, 17, 05, 00, 0f] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Zero) at (prev + 23, 5) to (start + 0, 15) + diff --git a/tests/coverage/attr/module.coverage b/tests/coverage/attr/module.coverage new file mode 100644 index 0000000000000..c1b9f0e35c0b1 --- /dev/null +++ b/tests/coverage/attr/module.coverage @@ -0,0 +1,38 @@ + LL| |#![feature(coverage_attribute)] + LL| |//@ edition: 2021 + LL| | + LL| |// Checks that `#[coverage(..)]` can be applied to modules, and is inherited + LL| |// by any enclosed functions. + LL| | + LL| |#[coverage(off)] + LL| |mod off { + LL| | fn inherit() {} + LL| | + LL| | #[coverage(on)] + LL| 0| fn on() {} + LL| | + LL| | #[coverage(off)] + LL| | fn off() {} + LL| |} + LL| | + LL| |#[coverage(on)] + LL| |mod on { + LL| 0| fn inherit() {} + LL| | + LL| | #[coverage(on)] + LL| 0| fn on() {} + LL| | + LL| | #[coverage(off)] + LL| | fn off() {} + LL| |} + LL| | + LL| |#[coverage(off)] + LL| |mod nested_a { + LL| | mod nested_b { + LL| | fn inner() {} + LL| | } + LL| |} + LL| | + LL| |#[coverage(off)] + LL| |fn main() {} + diff --git a/tests/coverage/attr/module.rs b/tests/coverage/attr/module.rs new file mode 100644 index 0000000000000..4bfb1e7729b7d --- /dev/null +++ b/tests/coverage/attr/module.rs @@ -0,0 +1,37 @@ +#![feature(coverage_attribute)] +//@ edition: 2021 + +// Checks that `#[coverage(..)]` can be applied to modules, and is inherited +// by any enclosed functions. + +#[coverage(off)] +mod off { + fn inherit() {} + + #[coverage(on)] + fn on() {} + + #[coverage(off)] + fn off() {} +} + +#[coverage(on)] +mod on { + fn inherit() {} + + #[coverage(on)] + fn on() {} + + #[coverage(off)] + fn off() {} +} + +#[coverage(off)] +mod nested_a { + mod nested_b { + fn inner() {} + } +} + +#[coverage(off)] +fn main() {} diff --git a/tests/ui/coverage-attr/name-value.rs b/tests/ui/coverage-attr/name-value.rs index cfd78a03e438a..24a0feb0710f6 100644 --- a/tests/ui/coverage-attr/name-value.rs +++ b/tests/ui/coverage-attr/name-value.rs @@ -10,13 +10,11 @@ #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input -//~| ERROR attribute should be applied to a function definition or closure mod my_mod {} mod my_mod_inner { #![coverage = "off"] //~^ ERROR malformed `coverage` attribute input - //~| ERROR attribute should be applied to a function definition or closure } #[coverage = "off"] @@ -26,7 +24,6 @@ struct MyStruct; #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input -//~| ERROR attribute should be applied to a function definition or closure impl MyStruct { #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input @@ -51,7 +48,6 @@ trait MyTrait { #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input -//~| ERROR attribute should be applied to a function definition or closure impl MyTrait for MyStruct { #[coverage = "off"] //~^ ERROR malformed `coverage` attribute input diff --git a/tests/ui/coverage-attr/name-value.stderr b/tests/ui/coverage-attr/name-value.stderr index caac687c94d01..986467dda698e 100644 --- a/tests/ui/coverage-attr/name-value.stderr +++ b/tests/ui/coverage-attr/name-value.stderr @@ -12,7 +12,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:17:5 + --> $DIR/name-value.rs:16:5 | LL | #![coverage = "off"] | ^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | #![coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:22:1 + --> $DIR/name-value.rs:20:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -38,7 +38,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:31:5 + --> $DIR/name-value.rs:28:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:27:1 + --> $DIR/name-value.rs:25:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:41:5 + --> $DIR/name-value.rs:38:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -77,7 +77,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:46:5 + --> $DIR/name-value.rs:43:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:37:1 + --> $DIR/name-value.rs:34:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:56:5 + --> $DIR/name-value.rs:52:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -116,7 +116,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:61:5 + --> $DIR/name-value.rs:57:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:52:1 + --> $DIR/name-value.rs:49:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -142,7 +142,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:67:1 + --> $DIR/name-value.rs:63:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -155,27 +155,7 @@ LL | #[coverage(on)] | error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/name-value.rs:11:1 - | -LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ -... -LL | mod my_mod {} - | ------------- not a function or closure - -error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/name-value.rs:17:5 - | -LL | / mod my_mod_inner { -LL | | #![coverage = "off"] - | | ^^^^^^^^^^^^^^^^^^^^ -LL | | -LL | | -LL | | } - | |_- not a function or closure - -error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/name-value.rs:22:1 + --> $DIR/name-value.rs:20:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -184,21 +164,7 @@ LL | struct MyStruct; | ---------------- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/name-value.rs:27:1 - | -LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ -... -LL | / impl MyStruct { -LL | | #[coverage = "off"] -LL | | -LL | | -LL | | const X: u32 = 7; -LL | | } - | |_- not a function or closure - -error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/name-value.rs:37:1 + --> $DIR/name-value.rs:34:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -213,22 +179,7 @@ LL | | } | |_- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/name-value.rs:52:1 - | -LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ -... -LL | / impl MyTrait for MyStruct { -LL | | #[coverage = "off"] -LL | | -LL | | -... | -LL | | type T = (); -LL | | } - | |_- not a function or closure - -error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/name-value.rs:41:5 + --> $DIR/name-value.rs:38:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -237,7 +188,7 @@ LL | const X: u32; | ------------- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/name-value.rs:46:5 + --> $DIR/name-value.rs:43:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -246,7 +197,7 @@ LL | type T; | ------- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/name-value.rs:31:5 + --> $DIR/name-value.rs:28:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -255,7 +206,7 @@ LL | const X: u32 = 7; | ----------------- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/name-value.rs:56:5 + --> $DIR/name-value.rs:52:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -264,7 +215,7 @@ LL | const X: u32 = 8; | ----------------- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/name-value.rs:61:5 + --> $DIR/name-value.rs:57:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ @@ -272,6 +223,6 @@ LL | #[coverage = "off"] LL | type T = (); | ------------ not a function or closure -error: aborting due to 23 previous errors +error: aborting due to 19 previous errors For more information about this error, try `rustc --explain E0788`. diff --git a/tests/ui/coverage-attr/no-coverage.rs b/tests/ui/coverage-attr/no-coverage.rs index 5290fccca6100..9545b0b55cf24 100644 --- a/tests/ui/coverage-attr/no-coverage.rs +++ b/tests/ui/coverage-attr/no-coverage.rs @@ -2,7 +2,7 @@ #![feature(coverage_attribute)] #![feature(impl_trait_in_assoc_type)] #![warn(unused_attributes)] -#![coverage(off)] //~ ERROR attribute should be applied to a function definition or closure +#![coverage(off)] #[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure trait Trait { @@ -15,7 +15,7 @@ trait Trait { type U; } -#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure +#[coverage(off)] impl Trait for () { const X: u32 = 0; diff --git a/tests/ui/coverage-attr/no-coverage.stderr b/tests/ui/coverage-attr/no-coverage.stderr index c5e3b0922cb42..3897d295940ef 100644 --- a/tests/ui/coverage-attr/no-coverage.stderr +++ b/tests/ui/coverage-attr/no-coverage.stderr @@ -11,20 +11,6 @@ LL | | type U; LL | | } | |_- not a function or closure -error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/no-coverage.rs:18:1 - | -LL | #[coverage(off)] - | ^^^^^^^^^^^^^^^^ -LL | / impl Trait for () { -LL | | const X: u32 = 0; -LL | | -LL | | #[coverage(off)] -... | -LL | | type U = impl Trait; -LL | | } - | |_- not a function or closure - error[E0788]: attribute should be applied to a function definition or closure --> $DIR/no-coverage.rs:39:5 | @@ -97,12 +83,6 @@ LL | #[coverage(off)] LL | type T; | ------- not a function or closure -error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/no-coverage.rs:5:1 - | -LL | #![coverage(off)] - | ^^^^^^^^^^^^^^^^^ not a function or closure - error: unconstrained opaque type --> $DIR/no-coverage.rs:26:14 | @@ -111,6 +91,6 @@ LL | type U = impl Trait; | = note: `U` must be used in combination with a concrete type within the same impl -error: aborting due to 13 previous errors +error: aborting due to 11 previous errors For more information about this error, try `rustc --explain E0788`. diff --git a/tests/ui/coverage-attr/word-only.rs b/tests/ui/coverage-attr/word-only.rs index 0a61d1e709f51..ea12e7b19eeff 100644 --- a/tests/ui/coverage-attr/word-only.rs +++ b/tests/ui/coverage-attr/word-only.rs @@ -10,13 +10,11 @@ #[coverage] //~^ ERROR malformed `coverage` attribute input -//~| ERROR attribute should be applied to a function definition or closure mod my_mod {} mod my_mod_inner { #![coverage] //~^ ERROR malformed `coverage` attribute input - //~| ERROR attribute should be applied to a function definition or closure } #[coverage] @@ -26,7 +24,6 @@ struct MyStruct; #[coverage] //~^ ERROR malformed `coverage` attribute input -//~| ERROR attribute should be applied to a function definition or closure impl MyStruct { #[coverage] //~^ ERROR malformed `coverage` attribute input @@ -51,7 +48,6 @@ trait MyTrait { #[coverage] //~^ ERROR malformed `coverage` attribute input -//~| ERROR attribute should be applied to a function definition or closure impl MyTrait for MyStruct { #[coverage] //~^ ERROR malformed `coverage` attribute input diff --git a/tests/ui/coverage-attr/word-only.stderr b/tests/ui/coverage-attr/word-only.stderr index 18b5fed748476..1ce149724c6f4 100644 --- a/tests/ui/coverage-attr/word-only.stderr +++ b/tests/ui/coverage-attr/word-only.stderr @@ -12,7 +12,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/word-only.rs:17:5 + --> $DIR/word-only.rs:16:5 | LL | #![coverage] | ^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | #![coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/word-only.rs:22:1 + --> $DIR/word-only.rs:20:1 | LL | #[coverage] | ^^^^^^^^^^^ @@ -38,7 +38,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/word-only.rs:31:5 + --> $DIR/word-only.rs:28:5 | LL | #[coverage] | ^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/word-only.rs:27:1 + --> $DIR/word-only.rs:25:1 | LL | #[coverage] | ^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/word-only.rs:41:5 + --> $DIR/word-only.rs:38:5 | LL | #[coverage] | ^^^^^^^^^^^ @@ -77,7 +77,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/word-only.rs:46:5 + --> $DIR/word-only.rs:43:5 | LL | #[coverage] | ^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/word-only.rs:37:1 + --> $DIR/word-only.rs:34:1 | LL | #[coverage] | ^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/word-only.rs:56:5 + --> $DIR/word-only.rs:52:5 | LL | #[coverage] | ^^^^^^^^^^^ @@ -116,7 +116,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/word-only.rs:61:5 + --> $DIR/word-only.rs:57:5 | LL | #[coverage] | ^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/word-only.rs:52:1 + --> $DIR/word-only.rs:49:1 | LL | #[coverage] | ^^^^^^^^^^^ @@ -142,7 +142,7 @@ LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/word-only.rs:67:1 + --> $DIR/word-only.rs:63:1 | LL | #[coverage] | ^^^^^^^^^^^ @@ -155,27 +155,7 @@ LL | #[coverage(on)] | error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/word-only.rs:11:1 - | -LL | #[coverage] - | ^^^^^^^^^^^ -... -LL | mod my_mod {} - | ------------- not a function or closure - -error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/word-only.rs:17:5 - | -LL | / mod my_mod_inner { -LL | | #![coverage] - | | ^^^^^^^^^^^^ -LL | | -LL | | -LL | | } - | |_- not a function or closure - -error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/word-only.rs:22:1 + --> $DIR/word-only.rs:20:1 | LL | #[coverage] | ^^^^^^^^^^^ @@ -184,21 +164,7 @@ LL | struct MyStruct; | ---------------- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/word-only.rs:27:1 - | -LL | #[coverage] - | ^^^^^^^^^^^ -... -LL | / impl MyStruct { -LL | | #[coverage] -LL | | -LL | | -LL | | const X: u32 = 7; -LL | | } - | |_- not a function or closure - -error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/word-only.rs:37:1 + --> $DIR/word-only.rs:34:1 | LL | #[coverage] | ^^^^^^^^^^^ @@ -213,22 +179,7 @@ LL | | } | |_- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/word-only.rs:52:1 - | -LL | #[coverage] - | ^^^^^^^^^^^ -... -LL | / impl MyTrait for MyStruct { -LL | | #[coverage] -LL | | -LL | | -... | -LL | | type T = (); -LL | | } - | |_- not a function or closure - -error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/word-only.rs:41:5 + --> $DIR/word-only.rs:38:5 | LL | #[coverage] | ^^^^^^^^^^^ @@ -237,7 +188,7 @@ LL | const X: u32; | ------------- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/word-only.rs:46:5 + --> $DIR/word-only.rs:43:5 | LL | #[coverage] | ^^^^^^^^^^^ @@ -246,7 +197,7 @@ LL | type T; | ------- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/word-only.rs:31:5 + --> $DIR/word-only.rs:28:5 | LL | #[coverage] | ^^^^^^^^^^^ @@ -255,7 +206,7 @@ LL | const X: u32 = 7; | ----------------- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/word-only.rs:56:5 + --> $DIR/word-only.rs:52:5 | LL | #[coverage] | ^^^^^^^^^^^ @@ -264,7 +215,7 @@ LL | const X: u32 = 8; | ----------------- not a function or closure error[E0788]: attribute should be applied to a function definition or closure - --> $DIR/word-only.rs:61:5 + --> $DIR/word-only.rs:57:5 | LL | #[coverage] | ^^^^^^^^^^^ @@ -272,6 +223,6 @@ LL | #[coverage] LL | type T = (); | ------------ not a function or closure -error: aborting due to 23 previous errors +error: aborting due to 19 previous errors For more information about this error, try `rustc --explain E0788`.