File tree 2 files changed +51
-0
lines changed
2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2018 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( catch_expr) ]
12
+
13
+ fn foo ( ) -> Option < ( ) > { Some ( ( ) ) }
14
+
15
+ fn main ( ) {
16
+ let _: Option < f32 > = do catch {
17
+ foo( ) ?;
18
+ 42
19
+ //~^ ERROR type mismatch
20
+ } ;
21
+
22
+ let _: Option < i32 > = do catch {
23
+ //~^ ERROR type mismatch
24
+ foo( ) ?;
25
+ } ;
26
+ }
Original file line number Diff line number Diff line change
1
+ error[E0271]: type mismatch resolving `<std::option::Option<f32> as std::ops::Try>::Ok == {integer}`
2
+ --> $DIR/catch-block-type-error.rs:18:9
3
+ |
4
+ LL | 42
5
+ | ^^ expected f32, found integral variable
6
+ |
7
+ = note: expected type `f32`
8
+ found type `{integer}`
9
+
10
+ error[E0271]: type mismatch resolving `<std::option::Option<i32> as std::ops::Try>::Ok == ()`
11
+ --> $DIR/catch-block-type-error.rs:22:35
12
+ |
13
+ LL | let _: Option<i32> = do catch {
14
+ | ___________________________________^
15
+ LL | | //~^ ERROR type mismatch
16
+ LL | | foo()?;
17
+ LL | | };
18
+ | |_____^ expected i32, found ()
19
+ |
20
+ = note: expected type `i32`
21
+ found type `()`
22
+
23
+ error: aborting due to 2 previous errors
24
+
25
+ For more information about this error, try `rustc --explain E0271`.
You can’t perform that action at this time.
0 commit comments