]> git.proxmox.com Git - rustc.git/blame - src/test/ui/try-operator-on-main.rs
New upstream version 1.40.0+dfsg1
[rustc.git] / src / test / ui / try-operator-on-main.rs
CommitLineData
2c00a5a8
XL
1// ignore-cloudabi no std::fs support
2
ea8adc8c
XL
3#![feature(try_trait)]
4
5use std::ops::Try;
6
7453a54e 7fn main() {
ea8adc8c 8 // error for a `Try` type on a non-`Try` fn
ff7c6d11 9 std::fs::File::open("foo")?; //~ ERROR the `?` operator can only
ea8adc8c
XL
10
11 // a non-`Try` type on a non-`Try` fn
ff7c6d11 12 ()?; //~ ERROR the `?` operator can only
ea8adc8c
XL
13
14 // an unrelated use of `Try`
ff7c6d11 15 try_trait_generic::<()>(); //~ ERROR the trait bound
ea8adc8c
XL
16}
17
18
19
20fn try_trait_generic<T: Try>() -> T {
21 // and a non-`Try` object on a `Try` fn.
e1599b0c 22 ()?; //~ ERROR the `?` operator can only be applied to values that implement `std::ops::Try`
ea8adc8c
XL
23
24 loop {}
223e47cc 25}