1
Fork 0

Rollup merge of #49446 - frewsxcv:frewsxcv-mention-optiono, r=GuillaumeGomez

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:
kennytm 2018-03-30 01:31:13 +02:00 committed by GitHub
commit d06abdbfd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View file

@ -20,7 +20,7 @@
any(from_method="from_error", from_method="from_ok"), any(from_method="from_error", from_method="from_ok"),
from_desugaring="?"), from_desugaring="?"),
message="the `?` operator can only be used in a \ 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}`)", (or another type that implements `{Try}`)",
label="cannot use the `?` operator in a function that returns `{Self}`"), label="cannot use the `?` operator in a function that returns `{Self}`"),
on(all(from_method="into_result", from_desugaring="?"), 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` = 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 --> $DIR/try-on-option.rs:23:5
| |
LL | x?; //~ the `?` operator 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 --> $DIR/try-operator-on-main.rs:19:5
| |
LL | std::fs::File::open("foo")?; //~ ERROR the `?` operator can only LL | std::fs::File::open("foo")?; //~ ERROR the `?` operator can only