Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 70b69a2

Browse files
authoredJun 27, 2024
Rollup merge of #126721 - Zalathar:nested-cov-attr, r=oli-obk
coverage: Make `#[coverage(..)]` apply recursively to nested functions This PR makes the (currently-unstable) `#[coverage(off)]` and `#[coverage(on)]` attributes apply recursively to all nested functions/closures, instead of just the function they are directly attached to. Those attributes can now also be applied to modules and to impl/impl-trait blocks, where they have no direct effect, but will be inherited by all enclosed functions/closures/methods that don't override the inherited value. --- Fixes #126625.
2 parents 5ec93b8 + 7f37f8a commit 70b69a2

File tree

23 files changed

+344
-344
lines changed

23 files changed

+344
-344
lines changed
 

‎compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
124124
.emit();
125125
}
126126
}
127-
sym::coverage => {
128-
let inner = attr.meta_item_list();
129-
match inner.as_deref() {
130-
Some([item]) if item.has_name(sym::off) => {
131-
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_COVERAGE;
132-
}
133-
Some([item]) if item.has_name(sym::on) => {
134-
// Allow #[coverage(on)] for being explicit, maybe also in future to enable
135-
// coverage on a smaller scope within an excluded larger scope.
136-
}
137-
Some(_) | None => {
138-
tcx.dcx()
139-
.span_delayed_bug(attr.span, "unexpected value of coverage attribute");
140-
}
141-
}
142-
}
143127
sym::rustc_std_internal_symbol => {
144128
codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL
145129
}
@@ -584,7 +568,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
584568
}
585569

586570
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
587-
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_COVERAGE;
588571
codegen_fn_attrs.inline = InlineAttr::Never;
589572
}
590573

‎compiler/rustc_middle/src/middle/codegen_fn_attrs.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ bitflags::bitflags! {
8787
/// #[cmse_nonsecure_entry]: with a TrustZone-M extension, declare a
8888
/// function as an entry function from Non-Secure code.
8989
const CMSE_NONSECURE_ENTRY = 1 << 13;
90-
/// `#[coverage(off)]`: indicates that the function should be ignored by
91-
/// the MIR `InstrumentCoverage` pass and not added to the coverage map
92-
/// during codegen.
93-
const NO_COVERAGE = 1 << 14;
90+
// (Bit 14 was used for `#[coverage(off)]`, but is now unused.)
9491
/// `#[used(linker)]`:
9592
/// indicates that neither LLVM nor the linker will eliminate this function.
9693
const USED_LINKER = 1 << 15;

‎compiler/rustc_middle/src/query/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,15 @@ rustc_queries! {
572572
separate_provide_extern
573573
}
574574

575+
/// Checks for the nearest `#[coverage(off)]` or `#[coverage(on)]` on
576+
/// this def and any enclosing defs, up to the crate root.
577+
///
578+
/// Returns `false` if `#[coverage(off)]` was found, or `true` if
579+
/// either `#[coverage(on)]` or no coverage attribute was found.
580+
query coverage_attr_on(key: LocalDefId) -> bool {
581+
desc { |tcx| "checking for `#[coverage(..)]` on `{}`", tcx.def_path_str(key) }
582+
}
583+
575584
/// Summarizes coverage IDs inserted by the `InstrumentCoverage` MIR pass
576585
/// (for compiler option `-Cinstrument-coverage`), after MIR optimizations
577586
/// have had a chance to potentially remove some of them.

‎compiler/rustc_mir_transform/src/coverage/query.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ use rustc_middle::query::TyCtxtAt;
66
use rustc_middle::ty::{self, TyCtxt};
77
use rustc_middle::util::Providers;
88
use rustc_span::def_id::LocalDefId;
9+
use rustc_span::sym;
910

1011
/// Registers query/hook implementations related to coverage.
1112
pub(crate) fn provide(providers: &mut Providers) {
1213
providers.hooks.is_eligible_for_coverage =
1314
|TyCtxtAt { tcx, .. }, def_id| is_eligible_for_coverage(tcx, def_id);
15+
providers.queries.coverage_attr_on = coverage_attr_on;
1416
providers.queries.coverage_ids_info = coverage_ids_info;
1517
}
1618

@@ -38,14 +40,43 @@ fn is_eligible_for_coverage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
3840
return false;
3941
}
4042

41-
if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::NO_COVERAGE) {
43+
if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::NAKED) {
44+
trace!("InstrumentCoverage skipped for {def_id:?} (`#[naked]`)");
45+
return false;
46+
}
47+
48+
if !tcx.coverage_attr_on(def_id) {
4249
trace!("InstrumentCoverage skipped for {def_id:?} (`#[coverage(off)]`)");
4350
return false;
4451
}
4552

4653
true
4754
}
4855

56+
/// Query implementation for `coverage_attr_on`.
57+
fn coverage_attr_on(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
58+
// Check for annotations directly on this def.
59+
if let Some(attr) = tcx.get_attr(def_id, sym::coverage) {
60+
match attr.meta_item_list().as_deref() {
61+
Some([item]) if item.has_name(sym::off) => return false,
62+
Some([item]) if item.has_name(sym::on) => return true,
63+
Some(_) | None => {
64+
// Other possibilities should have been rejected by `rustc_parse::validate_attr`.
65+
tcx.dcx().span_bug(attr.span, "unexpected value of coverage attribute");
66+
}
67+
}
68+
}
69+
70+
match tcx.opt_local_parent(def_id) {
71+
// Check the parent def (and so on recursively) until we find an
72+
// enclosing attribute or reach the crate root.
73+
Some(parent) => tcx.coverage_attr_on(parent),
74+
// We reached the crate root without seeing a coverage attribute, so
75+
// allow coverage instrumentation by default.
76+
None => true,
77+
}
78+
}
79+
4980
/// Query implementation for `coverage_ids_info`.
5081
fn coverage_ids_info<'tcx>(
5182
tcx: TyCtxt<'tcx>,

‎compiler/rustc_passes/src/check_attr.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,16 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
369369
}
370370
}
371371

372-
/// Checks that `#[coverage(..)]` is applied to a function or closure.
372+
/// Checks that `#[coverage(..)]` is applied to a function/closure/method,
373+
/// or to an impl block or module.
373374
fn check_coverage(&self, attr: &Attribute, span: Span, target: Target) -> bool {
374375
match target {
375-
// #[coverage(..)] on function is fine
376376
Target::Fn
377377
| Target::Closure
378-
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true,
378+
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent)
379+
| Target::Impl
380+
| Target::Mod => true,
381+
379382
_ => {
380383
self.dcx().emit_err(errors::CoverageNotFnOrClosure {
381384
attr_span: attr.span,

‎tests/coverage/attr/impl.cov-map

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Function name: <impl::MyStruct>::off_on (unused)
2+
Raw bytes (9): 0x[01, 01, 00, 01, 00, 0e, 05, 00, 13]
3+
Number of files: 1
4+
- file 0 => global file 1
5+
Number of expressions: 0
6+
Number of file 0 mappings: 1
7+
- Code(Zero) at (prev + 14, 5) to (start + 0, 19)
8+
9+
Function name: <impl::MyStruct>::on_inherit (unused)
10+
Raw bytes (9): 0x[01, 01, 00, 01, 00, 16, 05, 00, 17]
11+
Number of files: 1
12+
- file 0 => global file 1
13+
Number of expressions: 0
14+
Number of file 0 mappings: 1
15+
- Code(Zero) at (prev + 22, 5) to (start + 0, 23)
16+
17+
Function name: <impl::MyStruct>::on_on (unused)
18+
Raw bytes (9): 0x[01, 01, 00, 01, 00, 19, 05, 00, 12]
19+
Number of files: 1
20+
- file 0 => global file 1
21+
Number of expressions: 0
22+
Number of file 0 mappings: 1
23+
- Code(Zero) at (prev + 25, 5) to (start + 0, 18)
24+

‎tests/coverage/attr/impl.coverage

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
LL| |#![feature(coverage_attribute)]
2+
LL| |//@ edition: 2021
3+
LL| |
4+
LL| |// Checks that `#[coverage(..)]` can be applied to impl and impl-trait blocks,
5+
LL| |// and is inherited by any enclosed functions.
6+
LL| |
7+
LL| |struct MyStruct;
8+
LL| |
9+
LL| |#[coverage(off)]
10+
LL| |impl MyStruct {
11+
LL| | fn off_inherit() {}
12+
LL| |
13+
LL| | #[coverage(on)]
14+
LL| 0| fn off_on() {}
15+
LL| |
16+
LL| | #[coverage(off)]
17+
LL| | fn off_off() {}
18+
LL| |}
19+
LL| |
20+
LL| |#[coverage(on)]
21+
LL| |impl MyStruct {
22+
LL| 0| fn on_inherit() {}
23+
LL| |
24+
LL| | #[coverage(on)]
25+
LL| 0| fn on_on() {}
26+
LL| |
27+
LL| | #[coverage(off)]
28+
LL| | fn on_off() {}
29+
LL| |}
30+
LL| |
31+
LL| |trait MyTrait {
32+
LL| | fn method();
33+
LL| |}
34+
LL| |
35+
LL| |#[coverage(off)]
36+
LL| |impl MyTrait for MyStruct {
37+
LL| | fn method() {}
38+
LL| |}
39+
LL| |
40+
LL| |#[coverage(off)]
41+
LL| |fn main() {}
42+

‎tests/coverage/attr/impl.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#![feature(coverage_attribute)]
2+
//@ edition: 2021
3+
4+
// Checks that `#[coverage(..)]` can be applied to impl and impl-trait blocks,
5+
// and is inherited by any enclosed functions.
6+
7+
struct MyStruct;
8+
9+
#[coverage(off)]
10+
impl MyStruct {
11+
fn off_inherit() {}
12+
13+
#[coverage(on)]
14+
fn off_on() {}
15+
16+
#[coverage(off)]
17+
fn off_off() {}
18+
}
19+
20+
#[coverage(on)]
21+
impl MyStruct {
22+
fn on_inherit() {}
23+
24+
#[coverage(on)]
25+
fn on_on() {}
26+
27+
#[coverage(off)]
28+
fn on_off() {}
29+
}
30+
31+
trait MyTrait {
32+
fn method();
33+
}
34+
35+
#[coverage(off)]
36+
impl MyTrait for MyStruct {
37+
fn method() {}
38+
}
39+
40+
#[coverage(off)]
41+
fn main() {}

‎tests/coverage/attr/module.cov-map

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Function name: module::off::on (unused)
2+
Raw bytes (9): 0x[01, 01, 00, 01, 00, 0c, 05, 00, 0f]
3+
Number of files: 1
4+
- file 0 => global file 1
5+
Number of expressions: 0
6+
Number of file 0 mappings: 1
7+
- Code(Zero) at (prev + 12, 5) to (start + 0, 15)
8+
9+
Function name: module::on::inherit (unused)
10+
Raw bytes (9): 0x[01, 01, 00, 01, 00, 14, 05, 00, 14]
11+
Number of files: 1
12+
- file 0 => global file 1
13+
Number of expressions: 0
14+
Number of file 0 mappings: 1
15+
- Code(Zero) at (prev + 20, 5) to (start + 0, 20)
16+
17+
Function name: module::on::on (unused)
18+
Raw bytes (9): 0x[01, 01, 00, 01, 00, 17, 05, 00, 0f]
19+
Number of files: 1
20+
- file 0 => global file 1
21+
Number of expressions: 0
22+
Number of file 0 mappings: 1
23+
- Code(Zero) at (prev + 23, 5) to (start + 0, 15)
24+

‎tests/coverage/attr/module.coverage

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
LL| |#![feature(coverage_attribute)]
2+
LL| |//@ edition: 2021
3+
LL| |
4+
LL| |// Checks that `#[coverage(..)]` can be applied to modules, and is inherited
5+
LL| |// by any enclosed functions.
6+
LL| |
7+
LL| |#[coverage(off)]
8+
LL| |mod off {
9+
LL| | fn inherit() {}
10+
LL| |
11+
LL| | #[coverage(on)]
12+
LL| 0| fn on() {}
13+
LL| |
14+
LL| | #[coverage(off)]
15+
LL| | fn off() {}
16+
LL| |}
17+
LL| |
18+
LL| |#[coverage(on)]
19+
LL| |mod on {
20+
LL| 0| fn inherit() {}
21+
LL| |
22+
LL| | #[coverage(on)]
23+
LL| 0| fn on() {}
24+
LL| |
25+
LL| | #[coverage(off)]
26+
LL| | fn off() {}
27+
LL| |}
28+
LL| |
29+
LL| |#[coverage(off)]
30+
LL| |mod nested_a {
31+
LL| | mod nested_b {
32+
LL| | fn inner() {}
33+
LL| | }
34+
LL| |}
35+
LL| |
36+
LL| |#[coverage(off)]
37+
LL| |fn main() {}
38+

‎tests/coverage/attr/module.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#![feature(coverage_attribute)]
2+
//@ edition: 2021
3+
4+
// Checks that `#[coverage(..)]` can be applied to modules, and is inherited
5+
// by any enclosed functions.
6+
7+
#[coverage(off)]
8+
mod off {
9+
fn inherit() {}
10+
11+
#[coverage(on)]
12+
fn on() {}
13+
14+
#[coverage(off)]
15+
fn off() {}
16+
}
17+
18+
#[coverage(on)]
19+
mod on {
20+
fn inherit() {}
21+
22+
#[coverage(on)]
23+
fn on() {}
24+
25+
#[coverage(off)]
26+
fn off() {}
27+
}
28+
29+
#[coverage(off)]
30+
mod nested_a {
31+
mod nested_b {
32+
fn inner() {}
33+
}
34+
}
35+
36+
#[coverage(off)]
37+
fn main() {}

‎tests/coverage/attr/nested.cov-map

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,3 @@
1-
Function name: <<<nested::MyOuter as nested::MyTrait>::trait_method::MyMiddle as nested::MyTrait>::trait_method::MyInner as nested::MyTrait>::trait_method (unused)
2-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 39, 15, 02, 16]
3-
Number of files: 1
4-
- file 0 => global file 1
5-
Number of expressions: 0
6-
Number of file 0 mappings: 1
7-
- Code(Zero) at (prev + 57, 21) to (start + 2, 22)
8-
9-
Function name: <<<nested::MyOuter>::outer_method::MyMiddle>::middle_method::MyInner>::inner_method (unused)
10-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 23, 15, 02, 16]
11-
Number of files: 1
12-
- file 0 => global file 1
13-
Number of expressions: 0
14-
Number of file 0 mappings: 1
15-
- Code(Zero) at (prev + 35, 21) to (start + 2, 22)
16-
17-
Function name: <<nested::MyOuter as nested::MyTrait>::trait_method::MyMiddle as nested::MyTrait>::trait_method (unused)
18-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 36, 0d, 08, 0e]
19-
Number of files: 1
20-
- file 0 => global file 1
21-
Number of expressions: 0
22-
Number of file 0 mappings: 1
23-
- Code(Zero) at (prev + 54, 13) to (start + 8, 14)
24-
25-
Function name: <<nested::MyOuter>::outer_method::MyMiddle>::middle_method (unused)
26-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 20, 0d, 08, 0e]
27-
Number of files: 1
28-
- file 0 => global file 1
29-
Number of expressions: 0
30-
Number of file 0 mappings: 1
31-
- Code(Zero) at (prev + 32, 13) to (start + 8, 14)
32-
331
Function name: nested::closure_expr
342
Raw bytes (14): 0x[01, 01, 00, 02, 01, 44, 01, 01, 0f, 01, 0b, 05, 01, 02]
353
Number of files: 1
@@ -39,23 +7,6 @@ Number of file 0 mappings: 2
397
- Code(Counter(0)) at (prev + 68, 1) to (start + 1, 15)
408
- Code(Counter(0)) at (prev + 11, 5) to (start + 1, 2)
419

42-
Function name: nested::closure_expr::{closure#0}::{closure#0} (unused)
43-
Raw bytes (14): 0x[01, 01, 00, 02, 00, 47, 1a, 01, 17, 00, 04, 0d, 01, 0a]
44-
Number of files: 1
45-
- file 0 => global file 1
46-
Number of expressions: 0
47-
Number of file 0 mappings: 2
48-
- Code(Zero) at (prev + 71, 26) to (start + 1, 23)
49-
- Code(Zero) at (prev + 4, 13) to (start + 1, 10)
50-
51-
Function name: nested::closure_expr::{closure#0}::{closure#0}::{closure#0} (unused)
52-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 48, 1d, 02, 0e]
53-
Number of files: 1
54-
- file 0 => global file 1
55-
Number of expressions: 0
56-
Number of file 0 mappings: 1
57-
- Code(Zero) at (prev + 72, 29) to (start + 2, 14)
58-
5910
Function name: nested::closure_tail
6011
Raw bytes (14): 0x[01, 01, 00, 02, 01, 53, 01, 01, 0f, 01, 11, 05, 01, 02]
6112
Number of files: 1
@@ -65,36 +16,3 @@ Number of file 0 mappings: 2
6516
- Code(Counter(0)) at (prev + 83, 1) to (start + 1, 15)
6617
- Code(Counter(0)) at (prev + 17, 5) to (start + 1, 2)
6718

68-
Function name: nested::closure_tail::{closure#0}::{closure#0} (unused)
69-
Raw bytes (14): 0x[01, 01, 00, 02, 00, 58, 14, 01, 1f, 00, 06, 15, 01, 12]
70-
Number of files: 1
71-
- file 0 => global file 1
72-
Number of expressions: 0
73-
Number of file 0 mappings: 2
74-
- Code(Zero) at (prev + 88, 20) to (start + 1, 31)
75-
- Code(Zero) at (prev + 6, 21) to (start + 1, 18)
76-
77-
Function name: nested::closure_tail::{closure#0}::{closure#0}::{closure#0} (unused)
78-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 5a, 1c, 02, 1a]
79-
Number of files: 1
80-
- file 0 => global file 1
81-
Number of expressions: 0
82-
Number of file 0 mappings: 1
83-
- Code(Zero) at (prev + 90, 28) to (start + 2, 26)
84-
85-
Function name: nested::outer_fn::middle_fn (unused)
86-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 11, 05, 05, 06]
87-
Number of files: 1
88-
- file 0 => global file 1
89-
Number of expressions: 0
90-
Number of file 0 mappings: 1
91-
- Code(Zero) at (prev + 17, 5) to (start + 5, 6)
92-
93-
Function name: nested::outer_fn::middle_fn::inner_fn (unused)
94-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 12, 09, 02, 0a]
95-
Number of files: 1
96-
- file 0 => global file 1
97-
Number of expressions: 0
98-
Number of file 0 mappings: 1
99-
- Code(Zero) at (prev + 18, 9) to (start + 2, 10)
100-

‎tests/coverage/attr/nested.coverage

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
LL| |
1515
LL| |#[coverage(off)]
1616
LL| |fn outer_fn() {
17-
LL| 0| fn middle_fn() {
18-
LL| 0| fn inner_fn() {
19-
LL| 0| do_stuff();
20-
LL| 0| }
21-
LL| 0| do_stuff();
22-
LL| 0| }
17+
LL| | fn middle_fn() {
18+
LL| | fn inner_fn() {
19+
LL| | do_stuff();
20+
LL| | }
21+
LL| | do_stuff();
22+
LL| | }
2323
LL| | do_stuff();
2424
LL| |}
2525
LL| |
@@ -29,15 +29,15 @@
2929
LL| | fn outer_method(&self) {
3030
LL| | struct MyMiddle;
3131
LL| | impl MyMiddle {
32-
LL| 0| fn middle_method(&self) {
33-
LL| 0| struct MyInner;
34-
LL| 0| impl MyInner {
35-
LL| 0| fn inner_method(&self) {
36-
LL| 0| do_stuff();
37-
LL| 0| }
38-
LL| 0| }
39-
LL| 0| do_stuff();
40-
LL| 0| }
32+
LL| | fn middle_method(&self) {
33+
LL| | struct MyInner;
34+
LL| | impl MyInner {
35+
LL| | fn inner_method(&self) {
36+
LL| | do_stuff();
37+
LL| | }
38+
LL| | }
39+
LL| | do_stuff();
40+
LL| | }
4141
LL| | }
4242
LL| | do_stuff();
4343
LL| | }
@@ -51,15 +51,15 @@
5151
LL| | fn trait_method(&self) {
5252
LL| | struct MyMiddle;
5353
LL| | impl MyTrait for MyMiddle {
54-
LL| 0| fn trait_method(&self) {
55-
LL| 0| struct MyInner;
56-
LL| 0| impl MyTrait for MyInner {
57-
LL| 0| fn trait_method(&self) {
58-
LL| 0| do_stuff();
59-
LL| 0| }
60-
LL| 0| }
61-
LL| 0| do_stuff();
62-
LL| 0| }
54+
LL| | fn trait_method(&self) {
55+
LL| | struct MyInner;
56+
LL| | impl MyTrait for MyInner {
57+
LL| | fn trait_method(&self) {
58+
LL| | do_stuff();
59+
LL| | }
60+
LL| | }
61+
LL| | do_stuff();
62+
LL| | }
6363
LL| | }
6464
LL| | do_stuff();
6565
LL| | }
@@ -68,12 +68,12 @@
6868
LL| 1|fn closure_expr() {
6969
LL| 1| let _outer = #[coverage(off)]
7070
LL| | || {
71-
LL| 0| let _middle = || {
72-
LL| 0| let _inner = || {
73-
LL| 0| do_stuff();
74-
LL| 0| };
75-
LL| 0| do_stuff();
76-
LL| 0| };
71+
LL| | let _middle = || {
72+
LL| | let _inner = || {
73+
LL| | do_stuff();
74+
LL| | };
75+
LL| | do_stuff();
76+
LL| | };
7777
LL| | do_stuff();
7878
LL| | };
7979
LL| 1| do_stuff();
@@ -85,14 +85,14 @@
8585
LL| | #[coverage(off)]
8686
LL| | || {
8787
LL| | let _middle = {
88-
LL| 0| || {
89-
LL| 0| let _inner = {
90-
LL| 0| || {
91-
LL| 0| do_stuff();
92-
LL| 0| }
88+
LL| | || {
89+
LL| | let _inner = {
90+
LL| | || {
91+
LL| | do_stuff();
92+
LL| | }
9393
LL| | };
94-
LL| 0| do_stuff();
95-
LL| 0| }
94+
LL| | do_stuff();
95+
LL| | }
9696
LL| | };
9797
LL| | do_stuff();
9898
LL| | }

‎tests/coverage/attr/off-on-sandwich.cov-map

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ Number of expressions: 0
66
Number of file 0 mappings: 1
77
- Code(Counter(0)) at (prev + 20, 5) to (start + 7, 6)
88

9-
Function name: off_on_sandwich::sparse_a::sparse_b
10-
Raw bytes (9): 0x[01, 01, 00, 01, 01, 22, 05, 10, 06]
11-
Number of files: 1
12-
- file 0 => global file 1
13-
Number of expressions: 0
14-
Number of file 0 mappings: 1
15-
- Code(Counter(0)) at (prev + 34, 5) to (start + 16, 6)
16-
179
Function name: off_on_sandwich::sparse_a::sparse_b::sparse_c
1810
Raw bytes (9): 0x[01, 01, 00, 01, 01, 26, 09, 0b, 0a]
1911
Number of files: 1

‎tests/coverage/attr/off-on-sandwich.coverage

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
LL| |fn sparse_a() {
3232
LL| | sparse_b();
3333
LL| | sparse_b();
34-
LL| 2| fn sparse_b() {
35-
LL| 2| sparse_c();
36-
LL| 2| sparse_c();
37-
LL| 2| #[coverage(on)]
34+
LL| | fn sparse_b() {
35+
LL| | sparse_c();
36+
LL| | sparse_c();
37+
LL| | #[coverage(on)]
3838
LL| 4| fn sparse_c() {
3939
LL| 4| sparse_d();
4040
LL| 4| sparse_d();
@@ -47,7 +47,7 @@
4747
LL| 8| }
4848
LL| 8| }
4949
LL| 4| }
50-
LL| 2| }
50+
LL| | }
5151
LL| |}
5252
LL| |
5353
LL| |#[coverage(off)]

‎tests/coverage/no_cov_crate.cov-map

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,3 @@ Number of file 0 mappings: 4
5959
= (c0 - c1)
6060
- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 10)
6161

62-
Function name: no_cov_crate::nested_fns::outer_not_covered::inner
63-
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 26, 09, 01, 17, 05, 01, 18, 02, 0e, 02, 02, 14, 02, 0e, 01, 03, 09, 00, 0a]
64-
Number of files: 1
65-
- file 0 => global file 1
66-
Number of expressions: 1
67-
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
68-
Number of file 0 mappings: 4
69-
- Code(Counter(0)) at (prev + 38, 9) to (start + 1, 23)
70-
- Code(Counter(1)) at (prev + 1, 24) to (start + 2, 14)
71-
- Code(Expression(0, Sub)) at (prev + 2, 20) to (start + 2, 14)
72-
= (c0 - c1)
73-
- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 10)
74-

‎tests/coverage/no_cov_crate.coverage

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
LL| |mod nested_fns {
3636
LL| | #[coverage(off)]
3737
LL| | pub fn outer_not_covered(is_true: bool) {
38-
LL| 1| fn inner(is_true: bool) {
39-
LL| 1| if is_true {
40-
LL| 1| println!("called and covered");
41-
LL| 1| } else {
42-
LL| 0| println!("absolutely not covered");
43-
LL| 0| }
44-
LL| 1| }
38+
LL| | fn inner(is_true: bool) {
39+
LL| | if is_true {
40+
LL| | println!("called and covered");
41+
LL| | } else {
42+
LL| | println!("absolutely not covered");
43+
LL| | }
44+
LL| | }
4545
LL| | println!("called but not covered");
4646
LL| | inner(is_true);
4747
LL| | }

‎tests/ui/coverage-attr/name-value.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010

1111
#[coverage = "off"]
1212
//~^ ERROR malformed `coverage` attribute input
13-
//~| ERROR attribute should be applied to a function definition or closure
1413
mod my_mod {}
1514

1615
mod my_mod_inner {
1716
#![coverage = "off"]
1817
//~^ ERROR malformed `coverage` attribute input
19-
//~| ERROR attribute should be applied to a function definition or closure
2018
}
2119

2220
#[coverage = "off"]
@@ -26,7 +24,6 @@ struct MyStruct;
2624

2725
#[coverage = "off"]
2826
//~^ ERROR malformed `coverage` attribute input
29-
//~| ERROR attribute should be applied to a function definition or closure
3027
impl MyStruct {
3128
#[coverage = "off"]
3229
//~^ ERROR malformed `coverage` attribute input
@@ -51,7 +48,6 @@ trait MyTrait {
5148

5249
#[coverage = "off"]
5350
//~^ ERROR malformed `coverage` attribute input
54-
//~| ERROR attribute should be applied to a function definition or closure
5551
impl MyTrait for MyStruct {
5652
#[coverage = "off"]
5753
//~^ ERROR malformed `coverage` attribute input

‎tests/ui/coverage-attr/name-value.stderr

Lines changed: 19 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LL | #[coverage(on)]
1212
|
1313

1414
error: malformed `coverage` attribute input
15-
--> $DIR/name-value.rs:17:5
15+
--> $DIR/name-value.rs:16:5
1616
|
1717
LL | #![coverage = "off"]
1818
| ^^^^^^^^^^^^^^^^^^^^
@@ -25,7 +25,7 @@ LL | #![coverage(on)]
2525
|
2626

2727
error: malformed `coverage` attribute input
28-
--> $DIR/name-value.rs:22:1
28+
--> $DIR/name-value.rs:20:1
2929
|
3030
LL | #[coverage = "off"]
3131
| ^^^^^^^^^^^^^^^^^^^
@@ -38,7 +38,7 @@ LL | #[coverage(on)]
3838
|
3939

4040
error: malformed `coverage` attribute input
41-
--> $DIR/name-value.rs:31:5
41+
--> $DIR/name-value.rs:28:5
4242
|
4343
LL | #[coverage = "off"]
4444
| ^^^^^^^^^^^^^^^^^^^
@@ -51,7 +51,7 @@ LL | #[coverage(on)]
5151
|
5252

5353
error: malformed `coverage` attribute input
54-
--> $DIR/name-value.rs:27:1
54+
--> $DIR/name-value.rs:25:1
5555
|
5656
LL | #[coverage = "off"]
5757
| ^^^^^^^^^^^^^^^^^^^
@@ -64,7 +64,7 @@ LL | #[coverage(on)]
6464
|
6565

6666
error: malformed `coverage` attribute input
67-
--> $DIR/name-value.rs:41:5
67+
--> $DIR/name-value.rs:38:5
6868
|
6969
LL | #[coverage = "off"]
7070
| ^^^^^^^^^^^^^^^^^^^
@@ -77,7 +77,7 @@ LL | #[coverage(on)]
7777
|
7878

7979
error: malformed `coverage` attribute input
80-
--> $DIR/name-value.rs:46:5
80+
--> $DIR/name-value.rs:43:5
8181
|
8282
LL | #[coverage = "off"]
8383
| ^^^^^^^^^^^^^^^^^^^
@@ -90,7 +90,7 @@ LL | #[coverage(on)]
9090
|
9191

9292
error: malformed `coverage` attribute input
93-
--> $DIR/name-value.rs:37:1
93+
--> $DIR/name-value.rs:34:1
9494
|
9595
LL | #[coverage = "off"]
9696
| ^^^^^^^^^^^^^^^^^^^
@@ -103,7 +103,7 @@ LL | #[coverage(on)]
103103
|
104104

105105
error: malformed `coverage` attribute input
106-
--> $DIR/name-value.rs:56:5
106+
--> $DIR/name-value.rs:52:5
107107
|
108108
LL | #[coverage = "off"]
109109
| ^^^^^^^^^^^^^^^^^^^
@@ -116,7 +116,7 @@ LL | #[coverage(on)]
116116
|
117117

118118
error: malformed `coverage` attribute input
119-
--> $DIR/name-value.rs:61:5
119+
--> $DIR/name-value.rs:57:5
120120
|
121121
LL | #[coverage = "off"]
122122
| ^^^^^^^^^^^^^^^^^^^
@@ -129,7 +129,7 @@ LL | #[coverage(on)]
129129
|
130130

131131
error: malformed `coverage` attribute input
132-
--> $DIR/name-value.rs:52:1
132+
--> $DIR/name-value.rs:49:1
133133
|
134134
LL | #[coverage = "off"]
135135
| ^^^^^^^^^^^^^^^^^^^
@@ -142,7 +142,7 @@ LL | #[coverage(on)]
142142
|
143143

144144
error: malformed `coverage` attribute input
145-
--> $DIR/name-value.rs:67:1
145+
--> $DIR/name-value.rs:63:1
146146
|
147147
LL | #[coverage = "off"]
148148
| ^^^^^^^^^^^^^^^^^^^
@@ -155,27 +155,7 @@ LL | #[coverage(on)]
155155
|
156156

157157
error[E0788]: attribute should be applied to a function definition or closure
158-
--> $DIR/name-value.rs:11:1
159-
|
160-
LL | #[coverage = "off"]
161-
| ^^^^^^^^^^^^^^^^^^^
162-
...
163-
LL | mod my_mod {}
164-
| ------------- not a function or closure
165-
166-
error[E0788]: attribute should be applied to a function definition or closure
167-
--> $DIR/name-value.rs:17:5
168-
|
169-
LL | / mod my_mod_inner {
170-
LL | | #![coverage = "off"]
171-
| | ^^^^^^^^^^^^^^^^^^^^
172-
LL | |
173-
LL | |
174-
LL | | }
175-
| |_- not a function or closure
176-
177-
error[E0788]: attribute should be applied to a function definition or closure
178-
--> $DIR/name-value.rs:22:1
158+
--> $DIR/name-value.rs:20:1
179159
|
180160
LL | #[coverage = "off"]
181161
| ^^^^^^^^^^^^^^^^^^^
@@ -184,21 +164,7 @@ LL | struct MyStruct;
184164
| ---------------- not a function or closure
185165

186166
error[E0788]: attribute should be applied to a function definition or closure
187-
--> $DIR/name-value.rs:27:1
188-
|
189-
LL | #[coverage = "off"]
190-
| ^^^^^^^^^^^^^^^^^^^
191-
...
192-
LL | / impl MyStruct {
193-
LL | | #[coverage = "off"]
194-
LL | |
195-
LL | |
196-
LL | | const X: u32 = 7;
197-
LL | | }
198-
| |_- not a function or closure
199-
200-
error[E0788]: attribute should be applied to a function definition or closure
201-
--> $DIR/name-value.rs:37:1
167+
--> $DIR/name-value.rs:34:1
202168
|
203169
LL | #[coverage = "off"]
204170
| ^^^^^^^^^^^^^^^^^^^
@@ -213,22 +179,7 @@ LL | | }
213179
| |_- not a function or closure
214180

215181
error[E0788]: attribute should be applied to a function definition or closure
216-
--> $DIR/name-value.rs:52:1
217-
|
218-
LL | #[coverage = "off"]
219-
| ^^^^^^^^^^^^^^^^^^^
220-
...
221-
LL | / impl MyTrait for MyStruct {
222-
LL | | #[coverage = "off"]
223-
LL | |
224-
LL | |
225-
... |
226-
LL | | type T = ();
227-
LL | | }
228-
| |_- not a function or closure
229-
230-
error[E0788]: attribute should be applied to a function definition or closure
231-
--> $DIR/name-value.rs:41:5
182+
--> $DIR/name-value.rs:38:5
232183
|
233184
LL | #[coverage = "off"]
234185
| ^^^^^^^^^^^^^^^^^^^
@@ -237,7 +188,7 @@ LL | const X: u32;
237188
| ------------- not a function or closure
238189

239190
error[E0788]: attribute should be applied to a function definition or closure
240-
--> $DIR/name-value.rs:46:5
191+
--> $DIR/name-value.rs:43:5
241192
|
242193
LL | #[coverage = "off"]
243194
| ^^^^^^^^^^^^^^^^^^^
@@ -246,7 +197,7 @@ LL | type T;
246197
| ------- not a function or closure
247198

248199
error[E0788]: attribute should be applied to a function definition or closure
249-
--> $DIR/name-value.rs:31:5
200+
--> $DIR/name-value.rs:28:5
250201
|
251202
LL | #[coverage = "off"]
252203
| ^^^^^^^^^^^^^^^^^^^
@@ -255,7 +206,7 @@ LL | const X: u32 = 7;
255206
| ----------------- not a function or closure
256207

257208
error[E0788]: attribute should be applied to a function definition or closure
258-
--> $DIR/name-value.rs:56:5
209+
--> $DIR/name-value.rs:52:5
259210
|
260211
LL | #[coverage = "off"]
261212
| ^^^^^^^^^^^^^^^^^^^
@@ -264,14 +215,14 @@ LL | const X: u32 = 8;
264215
| ----------------- not a function or closure
265216

266217
error[E0788]: attribute should be applied to a function definition or closure
267-
--> $DIR/name-value.rs:61:5
218+
--> $DIR/name-value.rs:57:5
268219
|
269220
LL | #[coverage = "off"]
270221
| ^^^^^^^^^^^^^^^^^^^
271222
...
272223
LL | type T = ();
273224
| ------------ not a function or closure
274225

275-
error: aborting due to 23 previous errors
226+
error: aborting due to 19 previous errors
276227

277228
For more information about this error, try `rustc --explain E0788`.

‎tests/ui/coverage-attr/no-coverage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![feature(coverage_attribute)]
33
#![feature(impl_trait_in_assoc_type)]
44
#![warn(unused_attributes)]
5-
#![coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
5+
#![coverage(off)]
66

77
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
88
trait Trait {
@@ -15,7 +15,7 @@ trait Trait {
1515
type U;
1616
}
1717

18-
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
18+
#[coverage(off)]
1919
impl Trait for () {
2020
const X: u32 = 0;
2121

‎tests/ui/coverage-attr/no-coverage.stderr

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,6 @@ LL | | type U;
1111
LL | | }
1212
| |_- not a function or closure
1313

14-
error[E0788]: attribute should be applied to a function definition or closure
15-
--> $DIR/no-coverage.rs:18:1
16-
|
17-
LL | #[coverage(off)]
18-
| ^^^^^^^^^^^^^^^^
19-
LL | / impl Trait for () {
20-
LL | | const X: u32 = 0;
21-
LL | |
22-
LL | | #[coverage(off)]
23-
... |
24-
LL | | type U = impl Trait;
25-
LL | | }
26-
| |_- not a function or closure
27-
2814
error[E0788]: attribute should be applied to a function definition or closure
2915
--> $DIR/no-coverage.rs:39:5
3016
|
@@ -97,12 +83,6 @@ LL | #[coverage(off)]
9783
LL | type T;
9884
| ------- not a function or closure
9985

100-
error[E0788]: attribute should be applied to a function definition or closure
101-
--> $DIR/no-coverage.rs:5:1
102-
|
103-
LL | #![coverage(off)]
104-
| ^^^^^^^^^^^^^^^^^ not a function or closure
105-
10686
error: unconstrained opaque type
10787
--> $DIR/no-coverage.rs:26:14
10888
|
@@ -111,6 +91,6 @@ LL | type U = impl Trait;
11191
|
11292
= note: `U` must be used in combination with a concrete type within the same impl
11393

114-
error: aborting due to 13 previous errors
94+
error: aborting due to 11 previous errors
11595

11696
For more information about this error, try `rustc --explain E0788`.

‎tests/ui/coverage-attr/word-only.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010

1111
#[coverage]
1212
//~^ ERROR malformed `coverage` attribute input
13-
//~| ERROR attribute should be applied to a function definition or closure
1413
mod my_mod {}
1514

1615
mod my_mod_inner {
1716
#![coverage]
1817
//~^ ERROR malformed `coverage` attribute input
19-
//~| ERROR attribute should be applied to a function definition or closure
2018
}
2119

2220
#[coverage]
@@ -26,7 +24,6 @@ struct MyStruct;
2624

2725
#[coverage]
2826
//~^ ERROR malformed `coverage` attribute input
29-
//~| ERROR attribute should be applied to a function definition or closure
3027
impl MyStruct {
3128
#[coverage]
3229
//~^ ERROR malformed `coverage` attribute input
@@ -51,7 +48,6 @@ trait MyTrait {
5148

5249
#[coverage]
5350
//~^ ERROR malformed `coverage` attribute input
54-
//~| ERROR attribute should be applied to a function definition or closure
5551
impl MyTrait for MyStruct {
5652
#[coverage]
5753
//~^ ERROR malformed `coverage` attribute input

‎tests/ui/coverage-attr/word-only.stderr

Lines changed: 19 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LL | #[coverage(on)]
1212
|
1313

1414
error: malformed `coverage` attribute input
15-
--> $DIR/word-only.rs:17:5
15+
--> $DIR/word-only.rs:16:5
1616
|
1717
LL | #![coverage]
1818
| ^^^^^^^^^^^^
@@ -25,7 +25,7 @@ LL | #![coverage(on)]
2525
|
2626

2727
error: malformed `coverage` attribute input
28-
--> $DIR/word-only.rs:22:1
28+
--> $DIR/word-only.rs:20:1
2929
|
3030
LL | #[coverage]
3131
| ^^^^^^^^^^^
@@ -38,7 +38,7 @@ LL | #[coverage(on)]
3838
|
3939

4040
error: malformed `coverage` attribute input
41-
--> $DIR/word-only.rs:31:5
41+
--> $DIR/word-only.rs:28:5
4242
|
4343
LL | #[coverage]
4444
| ^^^^^^^^^^^
@@ -51,7 +51,7 @@ LL | #[coverage(on)]
5151
|
5252

5353
error: malformed `coverage` attribute input
54-
--> $DIR/word-only.rs:27:1
54+
--> $DIR/word-only.rs:25:1
5555
|
5656
LL | #[coverage]
5757
| ^^^^^^^^^^^
@@ -64,7 +64,7 @@ LL | #[coverage(on)]
6464
|
6565

6666
error: malformed `coverage` attribute input
67-
--> $DIR/word-only.rs:41:5
67+
--> $DIR/word-only.rs:38:5
6868
|
6969
LL | #[coverage]
7070
| ^^^^^^^^^^^
@@ -77,7 +77,7 @@ LL | #[coverage(on)]
7777
|
7878

7979
error: malformed `coverage` attribute input
80-
--> $DIR/word-only.rs:46:5
80+
--> $DIR/word-only.rs:43:5
8181
|
8282
LL | #[coverage]
8383
| ^^^^^^^^^^^
@@ -90,7 +90,7 @@ LL | #[coverage(on)]
9090
|
9191

9292
error: malformed `coverage` attribute input
93-
--> $DIR/word-only.rs:37:1
93+
--> $DIR/word-only.rs:34:1
9494
|
9595
LL | #[coverage]
9696
| ^^^^^^^^^^^
@@ -103,7 +103,7 @@ LL | #[coverage(on)]
103103
|
104104

105105
error: malformed `coverage` attribute input
106-
--> $DIR/word-only.rs:56:5
106+
--> $DIR/word-only.rs:52:5
107107
|
108108
LL | #[coverage]
109109
| ^^^^^^^^^^^
@@ -116,7 +116,7 @@ LL | #[coverage(on)]
116116
|
117117

118118
error: malformed `coverage` attribute input
119-
--> $DIR/word-only.rs:61:5
119+
--> $DIR/word-only.rs:57:5
120120
|
121121
LL | #[coverage]
122122
| ^^^^^^^^^^^
@@ -129,7 +129,7 @@ LL | #[coverage(on)]
129129
|
130130

131131
error: malformed `coverage` attribute input
132-
--> $DIR/word-only.rs:52:1
132+
--> $DIR/word-only.rs:49:1
133133
|
134134
LL | #[coverage]
135135
| ^^^^^^^^^^^
@@ -142,7 +142,7 @@ LL | #[coverage(on)]
142142
|
143143

144144
error: malformed `coverage` attribute input
145-
--> $DIR/word-only.rs:67:1
145+
--> $DIR/word-only.rs:63:1
146146
|
147147
LL | #[coverage]
148148
| ^^^^^^^^^^^
@@ -155,27 +155,7 @@ LL | #[coverage(on)]
155155
|
156156

157157
error[E0788]: attribute should be applied to a function definition or closure
158-
--> $DIR/word-only.rs:11:1
159-
|
160-
LL | #[coverage]
161-
| ^^^^^^^^^^^
162-
...
163-
LL | mod my_mod {}
164-
| ------------- not a function or closure
165-
166-
error[E0788]: attribute should be applied to a function definition or closure
167-
--> $DIR/word-only.rs:17:5
168-
|
169-
LL | / mod my_mod_inner {
170-
LL | | #![coverage]
171-
| | ^^^^^^^^^^^^
172-
LL | |
173-
LL | |
174-
LL | | }
175-
| |_- not a function or closure
176-
177-
error[E0788]: attribute should be applied to a function definition or closure
178-
--> $DIR/word-only.rs:22:1
158+
--> $DIR/word-only.rs:20:1
179159
|
180160
LL | #[coverage]
181161
| ^^^^^^^^^^^
@@ -184,21 +164,7 @@ LL | struct MyStruct;
184164
| ---------------- not a function or closure
185165

186166
error[E0788]: attribute should be applied to a function definition or closure
187-
--> $DIR/word-only.rs:27:1
188-
|
189-
LL | #[coverage]
190-
| ^^^^^^^^^^^
191-
...
192-
LL | / impl MyStruct {
193-
LL | | #[coverage]
194-
LL | |
195-
LL | |
196-
LL | | const X: u32 = 7;
197-
LL | | }
198-
| |_- not a function or closure
199-
200-
error[E0788]: attribute should be applied to a function definition or closure
201-
--> $DIR/word-only.rs:37:1
167+
--> $DIR/word-only.rs:34:1
202168
|
203169
LL | #[coverage]
204170
| ^^^^^^^^^^^
@@ -213,22 +179,7 @@ LL | | }
213179
| |_- not a function or closure
214180

215181
error[E0788]: attribute should be applied to a function definition or closure
216-
--> $DIR/word-only.rs:52:1
217-
|
218-
LL | #[coverage]
219-
| ^^^^^^^^^^^
220-
...
221-
LL | / impl MyTrait for MyStruct {
222-
LL | | #[coverage]
223-
LL | |
224-
LL | |
225-
... |
226-
LL | | type T = ();
227-
LL | | }
228-
| |_- not a function or closure
229-
230-
error[E0788]: attribute should be applied to a function definition or closure
231-
--> $DIR/word-only.rs:41:5
182+
--> $DIR/word-only.rs:38:5
232183
|
233184
LL | #[coverage]
234185
| ^^^^^^^^^^^
@@ -237,7 +188,7 @@ LL | const X: u32;
237188
| ------------- not a function or closure
238189

239190
error[E0788]: attribute should be applied to a function definition or closure
240-
--> $DIR/word-only.rs:46:5
191+
--> $DIR/word-only.rs:43:5
241192
|
242193
LL | #[coverage]
243194
| ^^^^^^^^^^^
@@ -246,7 +197,7 @@ LL | type T;
246197
| ------- not a function or closure
247198

248199
error[E0788]: attribute should be applied to a function definition or closure
249-
--> $DIR/word-only.rs:31:5
200+
--> $DIR/word-only.rs:28:5
250201
|
251202
LL | #[coverage]
252203
| ^^^^^^^^^^^
@@ -255,7 +206,7 @@ LL | const X: u32 = 7;
255206
| ----------------- not a function or closure
256207

257208
error[E0788]: attribute should be applied to a function definition or closure
258-
--> $DIR/word-only.rs:56:5
209+
--> $DIR/word-only.rs:52:5
259210
|
260211
LL | #[coverage]
261212
| ^^^^^^^^^^^
@@ -264,14 +215,14 @@ LL | const X: u32 = 8;
264215
| ----------------- not a function or closure
265216

266217
error[E0788]: attribute should be applied to a function definition or closure
267-
--> $DIR/word-only.rs:61:5
218+
--> $DIR/word-only.rs:57:5
268219
|
269220
LL | #[coverage]
270221
| ^^^^^^^^^^^
271222
...
272223
LL | type T = ();
273224
| ------------ not a function or closure
274225

275-
error: aborting due to 23 previous errors
226+
error: aborting due to 19 previous errors
276227

277228
For more information about this error, try `rustc --explain E0788`.

0 commit comments

Comments
 (0)
Please sign in to comment.