@@ -530,17 +530,25 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
530530 . iter ( )
531531 . enumerate ( )
532532 . filter_map ( move |( index, statement) | {
533- filtered_statement_span ( statement, self . body_span ) . map (
534- |( span, expn_span) | {
535- CoverageSpan :: for_statement (
536- statement, span, expn_span, bcb, bb, index,
537- )
538- } ,
539- )
533+ filtered_statement_span ( statement) . map ( |span| {
534+ CoverageSpan :: for_statement (
535+ statement,
536+ function_source_span ( span, self . body_span ) ,
537+ span,
538+ bcb,
539+ bb,
540+ index,
541+ )
542+ } )
540543 } )
541- . chain ( filtered_terminator_span ( data. terminator ( ) , self . body_span ) . map (
542- |( span, expn_span) | CoverageSpan :: for_terminator ( span, expn_span, bcb, bb) ,
543- ) )
544+ . chain ( filtered_terminator_span ( data. terminator ( ) ) . map ( |span| {
545+ CoverageSpan :: for_terminator (
546+ function_source_span ( span, self . body_span ) ,
547+ span,
548+ bcb,
549+ bb,
550+ )
551+ } ) )
544552 } )
545553 . collect ( )
546554 }
@@ -795,13 +803,9 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
795803 }
796804}
797805
798- /// See `function_source_span()` for a description of the two returned spans.
799- /// If the MIR `Statement` is not contributive to computing coverage spans,
800- /// returns `None`.
801- pub ( super ) fn filtered_statement_span (
802- statement : & ' a Statement < ' tcx > ,
803- body_span : Span ,
804- ) -> Option < ( Span , Span ) > {
806+ /// If the MIR `Statement` has a span contributive to computing coverage spans,
807+ /// return it; otherwise return `None`.
808+ pub ( super ) fn filtered_statement_span ( statement : & ' a Statement < ' tcx > ) -> Option < Span > {
805809 match statement. kind {
806810 // These statements have spans that are often outside the scope of the executed source code
807811 // for their parent `BasicBlock`.
@@ -838,18 +842,14 @@ pub(super) fn filtered_statement_span(
838842 | StatementKind :: LlvmInlineAsm ( _)
839843 | StatementKind :: Retag ( _, _)
840844 | StatementKind :: AscribeUserType ( _, _) => {
841- Some ( function_source_span ( statement. source_info . span , body_span ) )
845+ Some ( statement. source_info . span )
842846 }
843847 }
844848}
845849
846- /// See `function_source_span()` for a description of the two returned spans.
847- /// If the MIR `Terminator` is not contributive to computing coverage spans,
848- /// returns `None`.
849- pub ( super ) fn filtered_terminator_span (
850- terminator : & ' a Terminator < ' tcx > ,
851- body_span : Span ,
852- ) -> Option < ( Span , Span ) > {
850+ /// If the MIR `Terminator` has a span contributive to computing coverage spans,
851+ /// return it; otherwise return `None`.
852+ pub ( super ) fn filtered_terminator_span ( terminator : & ' a Terminator < ' tcx > ) -> Option < Span > {
853853 match terminator. kind {
854854 // These terminators have spans that don't positively contribute to computing a reasonable
855855 // span of actually executed source code. (For example, SwitchInt terminators extracted from
@@ -873,7 +873,7 @@ pub(super) fn filtered_terminator_span(
873873 span = span. with_lo ( constant. span . lo ( ) ) ;
874874 }
875875 }
876- Some ( function_source_span ( span, body_span ) )
876+ Some ( span)
877877 }
878878
879879 // Retain spans from all other terminators
@@ -884,28 +884,20 @@ pub(super) fn filtered_terminator_span(
884884 | TerminatorKind :: GeneratorDrop
885885 | TerminatorKind :: FalseUnwind { .. }
886886 | TerminatorKind :: InlineAsm { .. } => {
887- Some ( function_source_span ( terminator. source_info . span , body_span ) )
887+ Some ( terminator. source_info . span )
888888 }
889889 }
890890}
891891
892- /// Returns two spans from the given span (the span associated with a
893- /// `Statement` or `Terminator`):
894- ///
895- /// 1. An extrapolated span (pre-expansion[^1]) corresponding to a range within
896- /// the function's body source. This span is guaranteed to be contained
897- /// within, or equal to, the `body_span`. If the extrapolated span is not
898- /// contained within the `body_span`, the `body_span` is returned.
899- /// 2. The actual `span` value from the `Statement`, before expansion.
900- ///
901- /// Only the first span is used when computing coverage code regions. The second
902- /// span is useful if additional expansion data is needed (such as to look up
903- /// the macro name for a composed span within that macro).)
892+ /// Returns an extrapolated span (pre-expansion[^1]) corresponding to a range
893+ /// within the function's body source. This span is guaranteed to be contained
894+ /// within, or equal to, the `body_span`. If the extrapolated span is not
895+ /// contained within the `body_span`, the `body_span` is returned.
904896///
905- /// [^1]Expansions result from Rust syntax including macros, syntactic
906- /// sugar, etc.).
897+ /// [^1]Expansions result from Rust syntax including macros, syntactic sugar,
898+ /// etc.).
907899#[ inline]
908- fn function_source_span ( span : Span , body_span : Span ) -> ( Span , Span ) {
900+ pub ( super ) fn function_source_span ( span : Span , body_span : Span ) -> Span {
909901 let original_span = original_sp ( span, body_span) . with_ctxt ( body_span. ctxt ( ) ) ;
910- ( if body_span. contains ( original_span) { original_span } else { body_span } , span )
902+ if body_span. contains ( original_span) { original_span } else { body_span }
911903}
0 commit comments