]> git.proxmox.com Git - rustc.git/blob - src/test/run-make/coverage-reports/expected_show_coverage.closure_macro_async.txt
New upstream version 1.64.0+dfsg1
[rustc.git] / src / test / run-make / coverage-reports / expected_show_coverage.closure_macro_async.txt
1 1| |// compile-flags: --edition=2018
2 2| |#![feature(no_coverage)]
3 3| |
4 4| |macro_rules! bail {
5 5| | ($msg:literal $(,)?) => {
6 6| | if $msg.len() > 0 {
7 7| | println!("no msg");
8 8| | } else {
9 9| | println!($msg);
10 10| | }
11 11| | return Err(String::from($msg));
12 12| | };
13 13| |}
14 14| |
15 15| |macro_rules! on_error {
16 16| | ($value:expr, $error_message:expr) => {
17 17| | $value.or_else(|e| { // FIXME(85000): no coverage in closure macros
18 18| | let message = format!($error_message, e);
19 19| | if message.len() > 0 {
20 20| | println!("{}", message);
21 21| | Ok(String::from("ok"))
22 22| | } else {
23 23| | bail!("error");
24 24| | }
25 25| | })
26 26| | };
27 27| |}
28 28| |
29 29| 1|fn load_configuration_files() -> Result<String, String> {
30 30| 1| Ok(String::from("config"))
31 31| 1|}
32 32| |
33 33| 1|pub async fn test() -> Result<(), String> {
34 34| 1| println!("Starting service");
35 35| 1| let config = on_error!(load_configuration_files(), "Error loading configs: {}")?;
36 ^0
37 36| |
38 37| 1| let startup_delay_duration = String::from("arg");
39 38| 1| let _ = (config, startup_delay_duration);
40 39| 1| Ok(())
41 40| 1|}
42 41| |
43 42| |#[no_coverage]
44 43| |fn main() {
45 44| | executor::block_on(test());
46 45| |}
47 46| |
48 47| |mod executor {
49 48| | use core::{
50 49| | future::Future,
51 50| | pin::Pin,
52 51| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
53 52| | };
54 53| |
55 54| | #[no_coverage]
56 55| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
57 56| | let mut future = unsafe { Pin::new_unchecked(&mut future) };
58 57| | use std::hint::unreachable_unchecked;
59 58| | static VTABLE: RawWakerVTable = RawWakerVTable::new(
60 59| |
61 60| | #[no_coverage]
62 61| | |_| unsafe { unreachable_unchecked() }, // clone
63 62| |
64 63| | #[no_coverage]
65 64| | |_| unsafe { unreachable_unchecked() }, // wake
66 65| |
67 66| | #[no_coverage]
68 67| | |_| unsafe { unreachable_unchecked() }, // wake_by_ref
69 68| |
70 69| | #[no_coverage]
71 70| | |_| (),
72 71| | );
73 72| | let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
74 73| | let mut context = Context::from_waker(&waker);
75 74| |
76 75| | loop {
77 76| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
78 77| | break val;
79 78| | }
80 79| | }
81 80| | }
82 81| |}
83