-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-result-optionArea: Result and Option combinatorsArea: Result and Option combinatorsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
If T
in Result<T, _>
is not fmt::Debug
, the following will fail to compile. The compiler rightfully blames fmt::Debug
not being implemented for Result<Foo, ()>
.
struct Foo;
Result::<Foo, _>::Err(()).expect_err("Foo!");
However, users may get stuck if they can't - for whatever reason - add fmt::Debug
. A simple workaround is
Result::<Foo, _>::Err(()).err().expect("Foo!");
which has a somewhat degraded error message in the panic case, yet does what it's being asked for. Maybe the compiler could suggest that?
Metadata
Metadata
Assignees
Labels
A-result-optionArea: Result and Option combinatorsArea: Result and Option combinatorsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.