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