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