@@ -319,29 +319,16 @@ impl<'a> CoverageSpansGenerator<'a> {
319319 }
320320 }
321321
322- let prev = self . take_prev ( ) ;
323- debug ! ( " AT END, adding last prev={prev:?}" ) ;
324-
325322 // Drain any remaining dups into the output.
326323 for dup in self . pending_dups . drain ( ..) {
327324 debug ! ( " ...adding at least one pending dup={:?}" , dup) ;
328325 self . refined_spans . push ( dup) ;
329326 }
330327
331- // Async functions wrap a closure that implements the body to be executed. The enclosing
332- // function is called and returns an `impl Future` without initially executing any of the
333- // body. To avoid showing the return from the enclosing function as a "covered" return from
334- // the closure, the enclosing function's `TerminatorKind::Return`s `CoverageSpan` is
335- // excluded. The closure's `Return` is the only one that will be counted. This provides
336- // adequate coverage, and more intuitive counts. (Avoids double-counting the closing brace
337- // of the function body.)
338- let body_ends_with_closure = if let Some ( last_covspan) = self . refined_spans . last ( ) {
339- last_covspan. is_closure && last_covspan. span . hi ( ) == self . body_span . hi ( )
340- } else {
341- false
342- } ;
343-
344- if !body_ends_with_closure {
328+ // There is usually a final span remaining in `prev` after the loop ends,
329+ // so add it to the output as well.
330+ if let Some ( prev) = self . some_prev . take ( ) {
331+ debug ! ( " AT END, adding last prev={prev:?}" ) ;
345332 self . refined_spans . push ( prev) ;
346333 }
347334
0 commit comments