]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-operator-on-main.rs
Auto merge of #60072 - RalfJung:linked-list, r=shepmaster
[rust.git] / src / test / ui / try-operator-on-main.rs
1 // ignore-cloudabi no std::fs support
2
3 #![feature(try_trait)]
4
5 use std::ops::Try;
6
7 fn main() {
8     // error for a `Try` type on a non-`Try` fn
9     std::fs::File::open("foo")?; //~ ERROR the `?` operator can only
10
11     // a non-`Try` type on a non-`Try` fn
12     ()?; //~ ERROR the `?` operator can only
13
14     // an unrelated use of `Try`
15     try_trait_generic::<()>(); //~ ERROR the trait bound
16 }
17
18
19
20 fn try_trait_generic<T: Try>() -> T {
21     // and a non-`Try` object on a `Try` fn.
22     ()?; //~ ERROR the `?` operator can only
23
24     loop {}
25 }