|
18 | 18 | 18| |// the println!() and `let` assignment lines in the coverage code region(s), as it does in the |
19 | 19 | 19| |// non-async function above, unless the `println!()` is inside a covered block. |
20 | 20 | 20| 1|async fn async_func() { |
21 | | - 21| | println!("async_func was covered"); |
22 | | - 22| | let b = true; |
| 21 | + 21| 1| println!("async_func was covered"); |
| 22 | + 22| 1| let b = true; |
23 | 23 | 23| 1| if b { |
24 | 24 | 24| 1| println!("async_func println in block"); |
25 | 25 | 25| 1| } |
|
30 | 30 | 29| |// showing coverage, so the entire async closure _appears_ uncovered; but this is not exactly true. |
31 | 31 | 30| |// It's only certain kinds of lines and/or their context that results in missing coverage. |
32 | 32 | 31| 1|async fn async_func_just_println() { |
33 | | - 32| | println!("async_func_just_println was covered"); |
34 | | - 33| |} |
| 33 | + 32| 1| println!("async_func_just_println was covered"); |
| 34 | + 33| 1|} |
35 | 35 | 34| | |
36 | 36 | 35| 1|fn main() { |
37 | 37 | 36| 1| println!("codecovsample::main"); |
|
40 | 40 | 39| 1| |
41 | 41 | 40| 1| executor::block_on(async_func()); |
42 | 42 | 41| 1| executor::block_on(async_func_just_println()); |
43 | | - 42| 1| |
44 | | - 43| 1| // let mut future = Box::pin(async_func()); |
45 | | - 44| 1| // executor::block_on(future.as_mut()); |
46 | | - 45| 1| |
47 | | - 46| 1| // let mut future = Box::pin(async_func()); |
48 | | - 47| 1| // executor::block_on(future.as_mut()); |
49 | | - 48| 1| |
50 | | - 49| 1| // let mut future = Box::pin(async_func_just_println()); |
51 | | - 50| 1| // executor::block_on(future.as_mut()); |
52 | | - 51| 1|} |
53 | | - 52| | |
54 | | - 53| |mod executor { |
55 | | - 54| | use core::{ |
56 | | - 55| | future::Future, |
57 | | - 56| | pin::Pin, |
58 | | - 57| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, |
59 | | - 58| | }; |
60 | | - 59| | |
61 | | - 60| 2| pub fn block_on<F: Future>(mut future: F) -> F::Output { |
62 | | - 61| 2| let mut future = unsafe { Pin::new_unchecked(&mut future) }; |
63 | | - 62| 2| use std::hint::unreachable_unchecked; |
64 | | - 63| 2| static VTABLE: RawWakerVTable = RawWakerVTable::new( |
65 | | - 64| 2| |_| unsafe { unreachable_unchecked() }, // clone |
| 43 | + 42| 1|} |
| 44 | + 43| | |
| 45 | + 44| |mod executor { |
| 46 | + 45| | use core::{ |
| 47 | + 46| | future::Future, |
| 48 | + 47| | pin::Pin, |
| 49 | + 48| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, |
| 50 | + 49| | }; |
| 51 | + 50| | |
| 52 | + 51| 2| pub fn block_on<F: Future>(mut future: F) -> F::Output { |
| 53 | + 52| 2| let mut future = unsafe { Pin::new_unchecked(&mut future) }; |
| 54 | + 53| 2| use std::hint::unreachable_unchecked; |
| 55 | + 54| 2| static VTABLE: RawWakerVTable = RawWakerVTable::new( |
| 56 | + 55| 2| |_| unsafe { unreachable_unchecked() }, // clone |
66 | 57 | ^0 |
67 | | - 65| 2| |_| unsafe { unreachable_unchecked() }, // wake |
| 58 | + 56| 2| |_| unsafe { unreachable_unchecked() }, // wake |
68 | 59 | ^0 |
69 | | - 66| 2| |_| unsafe { unreachable_unchecked() }, // wake_by_ref |
| 60 | + 57| 2| |_| unsafe { unreachable_unchecked() }, // wake_by_ref |
70 | 61 | ^0 |
71 | | - 67| 2| |_| (), |
72 | | - 68| 2| ); |
73 | | - 69| 2| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; |
74 | | - 70| 2| let mut context = Context::from_waker(&waker); |
75 | | - 71| | |
76 | | - 72| | loop { |
77 | | - 73| 2| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { |
78 | | - 74| 2| break val; |
79 | | - 75| 0| } |
80 | | - 76| | } |
81 | | - 77| 2| } |
| 62 | + 58| 2| |_| (), |
| 63 | + 59| 2| ); |
| 64 | + 60| 2| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; |
| 65 | + 61| 2| let mut context = Context::from_waker(&waker); |
| 66 | + 62| | |
| 67 | + 63| | loop { |
| 68 | + 64| 2| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { |
| 69 | + 65| 2| break val; |
| 70 | + 66| 0| } |
| 71 | + 67| | } |
| 72 | + 68| 2| } |
82 | 73 | ------------------ |
83 | 74 | | async2::executor::block_on::<core::future::from_generator::GenFuture<async2::async_func::{closure#0}>>: |
84 | | - | 60| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output { |
85 | | - | 61| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; |
86 | | - | 62| 1| use std::hint::unreachable_unchecked; |
87 | | - | 63| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( |
88 | | - | 64| 1| |_| unsafe { unreachable_unchecked() }, // clone |
89 | | - | 65| 1| |_| unsafe { unreachable_unchecked() }, // wake |
90 | | - | 66| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref |
91 | | - | 67| 1| |_| (), |
92 | | - | 68| 1| ); |
93 | | - | 69| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; |
94 | | - | 70| 1| let mut context = Context::from_waker(&waker); |
95 | | - | 71| | |
96 | | - | 72| | loop { |
97 | | - | 73| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { |
98 | | - | 74| 1| break val; |
99 | | - | 75| 0| } |
100 | | - | 76| | } |
101 | | - | 77| 1| } |
| 75 | + | 51| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output { |
| 76 | + | 52| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; |
| 77 | + | 53| 1| use std::hint::unreachable_unchecked; |
| 78 | + | 54| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( |
| 79 | + | 55| 1| |_| unsafe { unreachable_unchecked() }, // clone |
| 80 | + | 56| 1| |_| unsafe { unreachable_unchecked() }, // wake |
| 81 | + | 57| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref |
| 82 | + | 58| 1| |_| (), |
| 83 | + | 59| 1| ); |
| 84 | + | 60| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; |
| 85 | + | 61| 1| let mut context = Context::from_waker(&waker); |
| 86 | + | 62| | |
| 87 | + | 63| | loop { |
| 88 | + | 64| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { |
| 89 | + | 65| 1| break val; |
| 90 | + | 66| 0| } |
| 91 | + | 67| | } |
| 92 | + | 68| 1| } |
102 | 93 | ------------------ |
103 | 94 | | async2::executor::block_on::<core::future::from_generator::GenFuture<async2::async_func_just_println::{closure#0}>>: |
104 | | - | 60| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output { |
105 | | - | 61| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; |
106 | | - | 62| 1| use std::hint::unreachable_unchecked; |
107 | | - | 63| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( |
108 | | - | 64| 1| |_| unsafe { unreachable_unchecked() }, // clone |
109 | | - | 65| 1| |_| unsafe { unreachable_unchecked() }, // wake |
110 | | - | 66| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref |
111 | | - | 67| 1| |_| (), |
112 | | - | 68| 1| ); |
113 | | - | 69| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; |
114 | | - | 70| 1| let mut context = Context::from_waker(&waker); |
115 | | - | 71| | |
116 | | - | 72| | loop { |
117 | | - | 73| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { |
118 | | - | 74| 1| break val; |
119 | | - | 75| 0| } |
120 | | - | 76| | } |
121 | | - | 77| 1| } |
| 95 | + | 51| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output { |
| 96 | + | 52| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) }; |
| 97 | + | 53| 1| use std::hint::unreachable_unchecked; |
| 98 | + | 54| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new( |
| 99 | + | 55| 1| |_| unsafe { unreachable_unchecked() }, // clone |
| 100 | + | 56| 1| |_| unsafe { unreachable_unchecked() }, // wake |
| 101 | + | 57| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref |
| 102 | + | 58| 1| |_| (), |
| 103 | + | 59| 1| ); |
| 104 | + | 60| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; |
| 105 | + | 61| 1| let mut context = Context::from_waker(&waker); |
| 106 | + | 62| | |
| 107 | + | 63| | loop { |
| 108 | + | 64| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) { |
| 109 | + | 65| 1| break val; |
| 110 | + | 66| 0| } |
| 111 | + | 67| | } |
| 112 | + | 68| 1| } |
122 | 113 | ------------------ |
123 | | - 78| |} |
| 114 | + 69| |} |
124 | 115 |
|
0 commit comments