@@ -319,29 +319,16 @@ impl<'a> CoverageSpansGenerator<'a> {
319
319
}
320
320
}
321
321
322
- let prev = self . take_prev ( ) ;
323
- debug ! ( " AT END, adding last prev={prev:?}" ) ;
324
-
325
322
// Drain any remaining dups into the output.
326
323
for dup in self . pending_dups . drain ( ..) {
327
324
debug ! ( " ...adding at least one pending dup={:?}" , dup) ;
328
325
self . refined_spans . push ( dup) ;
329
326
}
330
327
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:?}" ) ;
345
332
self . refined_spans . push ( prev) ;
346
333
}
347
334
@@ -398,38 +385,36 @@ impl<'a> CoverageSpansGenerator<'a> {
398
385
self . refined_spans . push ( macro_name_cov) ;
399
386
}
400
387
388
+ #[ track_caller]
401
389
fn curr ( & self ) -> & CoverageSpan {
402
- self . some_curr
403
- . as_ref ( )
404
- . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr" ) )
390
+ self . some_curr . as_ref ( ) . unwrap_or_else ( || bug ! ( "some_curr is None (curr)" ) )
405
391
}
406
392
393
+ #[ track_caller]
407
394
fn curr_mut ( & mut self ) -> & mut CoverageSpan {
408
- self . some_curr
409
- . as_mut ( )
410
- . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr" ) )
395
+ self . some_curr . as_mut ( ) . unwrap_or_else ( || bug ! ( "some_curr is None (curr_mut)" ) )
411
396
}
412
397
413
398
/// If called, then the next call to `next_coverage_span()` will *not* update `prev` with the
414
399
/// `curr` coverage span.
400
+ #[ track_caller]
415
401
fn take_curr ( & mut self ) -> CoverageSpan {
416
- self . some_curr . take ( ) . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_curr " ) )
402
+ self . some_curr . take ( ) . unwrap_or_else ( || bug ! ( "some_curr is None (take_curr) " ) )
417
403
}
418
404
405
+ #[ track_caller]
419
406
fn prev ( & self ) -> & CoverageSpan {
420
- self . some_prev
421
- . as_ref ( )
422
- . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_prev" ) )
407
+ self . some_prev . as_ref ( ) . unwrap_or_else ( || bug ! ( "some_prev is None (prev)" ) )
423
408
}
424
409
410
+ #[ track_caller]
425
411
fn prev_mut ( & mut self ) -> & mut CoverageSpan {
426
- self . some_prev
427
- . as_mut ( )
428
- . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_prev" ) )
412
+ self . some_prev . as_mut ( ) . unwrap_or_else ( || bug ! ( "some_prev is None (prev_mut)" ) )
429
413
}
430
414
415
+ #[ track_caller]
431
416
fn take_prev ( & mut self ) -> CoverageSpan {
432
- self . some_prev . take ( ) . unwrap_or_else ( || bug ! ( "invalid attempt to unwrap a None some_prev " ) )
417
+ self . some_prev . take ( ) . unwrap_or_else ( || bug ! ( "some_prev is None (take_prev) " ) )
433
418
}
434
419
435
420
/// If there are `pending_dups` but `prev` is not a matching dup (`prev.span` doesn't match the
0 commit comments