]> git.lizzy.rs Git - rust.git/blob - src/test/ui/try-trait/try-operator-on-main.rs
Rollup merge of #101534 - rust-lang:notriddle/rustdoc-flex-direction, r=GuillaumeGomez
[rust.git] / src / test / ui / try-trait / try-operator-on-main.rs
1 #![feature(try_trait_v2)]
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 be applied to
11     //~^ ERROR the `?` operator can only be used in a function that
12
13     // an unrelated use of `Try`
14     try_trait_generic::<()>(); //~ ERROR the trait bound
15 }
16
17 fn try_trait_generic<T: Try>() -> T {
18     // and a non-`Try` object on a `Try` fn.
19     ()?; //~ ERROR the `?` operator can only be applied to values that implement `Try`
20
21     loop {}
22 }