mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
Instead of trying to heuristically recover source-code spans from MIR soup, we can now take advantage of the `CoverageKind::Point` statements injected for specific HIR expressions. This is a transitional implementation that lets us remove the old MIR-soup code, but still relies heavily on the existing span-refinement heuristics, and does not take advantage of the full possibilities of HIR-aware coverage instrumentation. In order to avoid annoying never-executed spans in code that contains assertions, a heuristic has been added that ignores any expression within the arguments of a macro-expanded function call that returns `!`. Some coverage tests now require `//@ min-llvm-version: 23`, due to changes in how LLVM sorts the coverage mapping entries.
42 lines
1.5 KiB
Plaintext
42 lines
1.5 KiB
Plaintext
LL| |//@ min-llvm-version: 23
|
|
LL| |#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
|
|
LL| |#![allow(unused_assignments)]
|
|
LL| |
|
|
LL| |use std::ops::{Coroutine, CoroutineState};
|
|
LL| |use std::pin::Pin;
|
|
LL| |
|
|
LL| 1|fn main() {
|
|
LL| | let mut coroutine = #[coroutine]
|
|
LL| 1| || {
|
|
LL| 1| yield 1;
|
|
LL| 1| return "foo";
|
|
LL| 1| };
|
|
LL| |
|
|
LL| 1| match Pin::new(&mut coroutine).resume(()) {
|
|
LL| 1| CoroutineState::Yielded(1) => {}
|
|
LL| 0| _ => panic!("unexpected value from resume"),
|
|
LL| | }
|
|
LL| 1| match Pin::new(&mut coroutine).resume(()) {
|
|
LL| 1| CoroutineState::Complete("foo") => {}
|
|
LL| 0| _ => panic!("unexpected value from resume"),
|
|
LL| | }
|
|
LL| |
|
|
LL| | let mut coroutine = #[coroutine]
|
|
LL| 1| || {
|
|
LL| 1| yield 1;
|
|
LL| 1| yield 2;
|
|
LL| 0| yield 3;
|
|
LL| 0| return "foo";
|
|
LL| 0| };
|
|
LL| |
|
|
LL| 1| match Pin::new(&mut coroutine).resume(()) {
|
|
LL| 1| CoroutineState::Yielded(1) => {}
|
|
LL| 0| _ => panic!("unexpected value from resume"),
|
|
LL| | }
|
|
LL| 1| match Pin::new(&mut coroutine).resume(()) {
|
|
LL| 1| CoroutineState::Yielded(2) => {}
|
|
LL| 0| _ => panic!("unexpected value from resume"),
|
|
LL| | }
|
|
LL| 1|}
|
|
|