]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-poll.rs
Rollup merge of #53317 - estebank:abolish-ice, r=oli-obk
[rust.git] / src / test / ui / try-poll.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-pass
12
13 #![allow(dead_code, unused)]
14 #![feature(futures_api)]
15
16 use std::task::Poll;
17
18 struct K;
19 struct E;
20
21 fn as_result() -> Result<(), E> {
22     // From Result
23     let K = Ok::<K, E>(K)?;
24
25     // From Poll<Result>
26     let _: Poll<K> = Poll::Ready::<Result<K, E>>(Ok(K))?;
27
28     // From Poll<Option<Result>>
29     let _: Poll<Option<K>> = Poll::Ready::<Option<Result<K, E>>>(None)?;
30
31     Ok(())
32 }
33
34 fn as_poll_result() -> Poll<Result<(), E>> {
35     // From Result
36     let K = Ok::<K, E>(K)?;
37
38     // From Poll<Result>
39     let _: Poll<K> = Poll::Ready::<Result<K, E>>(Ok(K))?;
40
41     // From Poll<Option<Result>>
42     let _: Poll<Option<K>> = Poll::Ready::<Option<Result<K, E>>>(None)?;
43
44     Poll::Ready(Ok(()))
45 }
46
47 fn as_poll_option_result() -> Poll<Option<Result<(), E>>> {
48     // From Result
49     let K = Ok::<K, E>(K)?;
50
51     // From Poll<Result>
52     let _: Poll<K> = Poll::Ready::<Result<K, E>>(Ok(K))?;
53
54     // From Poll<Option<Result>>
55     let _: Poll<Option<K>> = Poll::Ready::<Option<Result<K, E>>>(None)?;
56
57     Poll::Ready(Some(Ok(())))
58 }
59
60 fn main() {
61 }