File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright 2017 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+ #![ feature( try_trait) ]
12+
13+ fn main ( ) { }
14+
15+ fn foo ( ) -> Result < u32 , ( ) > {
16+ let x: Option < u32 > = None ;
17+ x?;
18+ Ok ( 22 )
19+ }
20+
21+ fn bar ( ) -> u32 {
22+ let x: Option < u32 > = None ;
23+ x?;
24+ 22
25+ }
Original file line number Diff line number Diff line change 1+ error[E0277]: the trait bound `(): std::convert::From<std::option::NoneError>` is not satisfied
2+ --> $DIR/try-on-option.rs:17:5
3+ |
4+ 17 | x?;
5+ | ^^ the trait `std::convert::From<std::option::NoneError>` is not implemented for `()`
6+ |
7+ = note: required by `std::convert::From::from`
8+
9+ error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`)
10+ --> $DIR/try-on-option.rs:23:5
11+ |
12+ 23 | x?;
13+ | --
14+ | |
15+ | cannot use the `?` operator in a function that returns `u32`
16+ | in this macro invocation
17+ |
18+ = help: the trait `std::ops::Try` is not implemented for `u32`
19+ = note: required by `std::ops::Try::from_error`
20+
21+ error: aborting due to 2 previous errors
22+
You can’t perform that action at this time.
0 commit comments