Skip to content

diagnostics: suggest Result instead of Option if inner arguments would match #79900

Open
@matthiaskrgr

Description

@matthiaskrgr
pub struct Error {}

pub fn want_result() -> Option<(), Error> {
     unimplemented!()
}

rust fails to compile this:

error[E0107]: wrong number of type arguments: expected 1, found 2
 --> src/lib.rs:3:36
  |
3 | pub fn want_result() -> Option<(), Error> {
  |                                    ^^^^^ unexpected type argument

error: aborting due to previous error

Since <x,y> matches the Result signature, it would be super neat if rustc could suggest something like Did you mean to use Result<(), Error> instead of Option<(), Error> here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-result-optionArea: Result and Option combinatorsP-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions