@@ -122,7 +122,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
122
122
self . check_diagnostic_on_unimplemented ( attr. span , hir_id, target)
123
123
}
124
124
[ sym:: inline] => self . check_inline ( hir_id, attr, span, target) ,
125
- [ sym:: coverage] => self . check_coverage ( hir_id , attr, span, target) ,
125
+ [ sym:: coverage] => self . check_coverage ( attr, span, target) ,
126
126
[ sym:: non_exhaustive] => self . check_non_exhaustive ( hir_id, attr, span, target) ,
127
127
[ sym:: marker] => self . check_marker ( hir_id, attr, span, target) ,
128
128
[ sym:: target_feature] => {
@@ -369,47 +369,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
369
369
}
370
370
}
371
371
372
- /// Checks if a `#[coverage]` is applied directly to a function
373
- fn check_coverage ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) -> bool {
372
+ /// Checks that `#[coverage(..) ]` is applied to a function or closure.
373
+ fn check_coverage ( & self , attr : & Attribute , span : Span , target : Target ) -> bool {
374
374
match target {
375
- // #[coverage] on function is fine
375
+ // #[coverage(..) ] on function is fine
376
376
Target :: Fn
377
377
| Target :: Closure
378
378
| Target :: Method ( MethodKind :: Trait { body : true } | MethodKind :: Inherent ) => true ,
379
-
380
- // function prototypes can't be covered
381
- Target :: Method ( MethodKind :: Trait { body : false } ) | Target :: ForeignFn => {
382
- self . tcx . emit_node_span_lint (
383
- UNUSED_ATTRIBUTES ,
384
- hir_id,
385
- attr. span ,
386
- errors:: IgnoredCoverageFnProto ,
387
- ) ;
388
- true
389
- }
390
-
391
- Target :: Mod | Target :: ForeignMod | Target :: Impl | Target :: Trait => {
392
- self . tcx . emit_node_span_lint (
393
- UNUSED_ATTRIBUTES ,
394
- hir_id,
395
- attr. span ,
396
- errors:: IgnoredCoveragePropagate ,
397
- ) ;
398
- true
399
- }
400
-
401
- Target :: Expression | Target :: Statement | Target :: Arm => {
402
- self . tcx . emit_node_span_lint (
403
- UNUSED_ATTRIBUTES ,
404
- hir_id,
405
- attr. span ,
406
- errors:: IgnoredCoverageFnDefn ,
407
- ) ;
408
- true
409
- }
410
-
411
379
_ => {
412
- self . dcx ( ) . emit_err ( errors:: IgnoredCoverageNotCoverable {
380
+ self . dcx ( ) . emit_err ( errors:: CoverageNotFnOrClosure {
413
381
attr_span : attr. span ,
414
382
defn_span : span,
415
383
} ) ;
0 commit comments