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:
commit
d06abdbfd8
3 changed files with 3 additions and 3 deletions
|
@ -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="?"),
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue