@@ -126,7 +126,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
126126 self . check_diagnostic_on_unimplemented ( attr. span , hir_id, target)
127127 }
128128 [ sym:: inline] => self . check_inline ( hir_id, attr, span, target) ,
129- [ sym:: coverage] => self . check_coverage ( hir_id , attr, span, target) ,
129+ [ sym:: coverage] => self . check_coverage ( attr, span, target) ,
130130 [ sym:: non_exhaustive] => self . check_non_exhaustive ( hir_id, attr, span, target) ,
131131 [ sym:: marker] => self . check_marker ( hir_id, attr, span, target) ,
132132 [ sym:: target_feature] => {
@@ -388,47 +388,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
388388 }
389389 }
390390
391- /// Checks if a `#[coverage]` is applied directly to a function
392- fn check_coverage ( & self , hir_id : HirId , attr : & Attribute , span : Span , target : Target ) -> bool {
391+ /// Checks that `#[coverage(..) ]` is applied to a function or closure.
392+ fn check_coverage ( & self , attr : & Attribute , span : Span , target : Target ) -> bool {
393393 match target {
394- // #[coverage] on function is fine
394+ // #[coverage(..) ] on function is fine
395395 Target :: Fn
396396 | Target :: Closure
397397 | Target :: Method ( MethodKind :: Trait { body : true } | MethodKind :: Inherent ) => true ,
398-
399- // function prototypes can't be covered
400- Target :: Method ( MethodKind :: Trait { body : false } ) | Target :: ForeignFn => {
401- self . tcx . emit_node_span_lint (
402- UNUSED_ATTRIBUTES ,
403- hir_id,
404- attr. span ,
405- errors:: IgnoredCoverageFnProto ,
406- ) ;
407- true
408- }
409-
410- Target :: Mod | Target :: ForeignMod | Target :: Impl | Target :: Trait => {
411- self . tcx . emit_node_span_lint (
412- UNUSED_ATTRIBUTES ,
413- hir_id,
414- attr. span ,
415- errors:: IgnoredCoveragePropagate ,
416- ) ;
417- true
418- }
419-
420- Target :: Expression | Target :: Statement | Target :: Arm => {
421- self . tcx . emit_node_span_lint (
422- UNUSED_ATTRIBUTES ,
423- hir_id,
424- attr. span ,
425- errors:: IgnoredCoverageFnDefn ,
426- ) ;
427- true
428- }
429-
430398 _ => {
431- self . dcx ( ) . emit_err ( errors:: IgnoredCoverageNotCoverable {
399+ self . dcx ( ) . emit_err ( errors:: CoverageNotFnOrClosure {
432400 attr_span : attr. span ,
433401 defn_span : span,
434402 } ) ;
0 commit comments