1
Fork 0

Explicitly mention Option in ? error message.

Save users the time/effort of having to lookup what types implement
the `Try` trait.
This commit is contained in:
Corey Farwell 2018-03-28 11:25:52 +02:00
parent e58df0d8c5
commit 1f143bc46f
3 changed files with 3 additions and 3 deletions

View file

@ -20,7 +20,7 @@
any(from_method="from_error", from_method="from_ok"),
from_desugaring="?"),
message="the `?` operator can only be used in a \
function that returns `Result` \
function that returns `Result` or `Option` \
(or another type that implements `{Try}`)",
label="cannot use the `?` operator in a function that returns `{Self}`"),
on(all(from_method="into_result", from_desugaring="?"),

View file

@ -6,7 +6,7 @@ LL | x?; //~ the trait bound
|
= note: required by `std::convert::From::from`
error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`)
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> $DIR/try-on-option.rs:23:5
|
LL | x?; //~ the `?` operator

View file

@ -1,4 +1,4 @@
error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`)
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
--> $DIR/try-operator-on-main.rs:19:5
|
LL | std::fs::File::open("foo")?; //~ ERROR the `?` operator can only