@@ -122,7 +122,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
122122 self . check_diagnostic_on_unimplemented ( attr. span , hir_id, target)
123123 }
124124 [ 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) ,
126126 [ sym:: non_exhaustive] => self . check_non_exhaustive ( hir_id, attr, span, target) ,
127127 [ sym:: marker] => self . check_marker ( hir_id, attr, span, target) ,
128128 [ sym:: target_feature] => {
@@ -369,47 +369,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
369369 }
370370 }
371371
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 {
374374 match target {
375- // #[coverage] on function is fine
375+ // #[coverage(..) ] on function is fine
376376 Target :: Fn
377377 | Target :: Closure
378378 | 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-
411379 _ => {
412- self . dcx ( ) . emit_err ( errors:: IgnoredCoverageNotCoverable {
380+ self . dcx ( ) . emit_err ( errors:: CoverageNotFnOrClosure {
413381 attr_span : attr. span ,
414382 defn_span : span,
415383 } ) ;
0 commit comments