Skip to content

Compiler should be able to compile EnumVariant(foo) == function_returning_enum() without PartialEq #57782

Open
@In-line

Description

@In-line

Given this pseudocode

let result: bool = Ok(something) == some_function_returning_result();

It should be transformed to this pseudocode

let result: bool = match some_function_returning_result() {
    Ok(something) => true,
    _ => false,
};

Currently I get this error.

error[E0277]: can't compare `errors::Error` with `errors::Error`
   --> src/rustup/toolchain.rs:349:35
    |
349 |                     Ok(something) == some_function_returning_result()
    |                                   ^^ no implementation for `errors::Error == errors::Error`
    |
    = help: the trait `std::cmp::PartialEq` is not implemented for `errors::Error`
    = note: required because of the requirements on the impl of `std::cmp::PartialEq` for `std::result::Result<std::string::String, errors::Error>`

It would be nice syntax sugar to have not only for Result, but for any generic enum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamneeds-rfcThis change is large or controversial enough that it should have an RFC accepted before doing it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions