Skip to content

Commit

Permalink
Explicitly mention Option in ? error message.
Browse files Browse the repository at this point in the history
Save users the time/effort of having to lookup what types implement
the `Try` trait.
  • Loading branch information
frewsxcv committed Mar 28, 2018
1 parent e58df0d commit 1f143bc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libcore/ops/try.rs
Expand Up @@ -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="?"),
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/suggestions/try-on-option.stderr
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/suggestions/try-operator-on-main.stderr
@@ -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
Expand Down

0 comments on commit 1f143bc

Please sign in to comment.