Skip to content

? desugaring leaks into error messages when Ok is forgotten on final expr #51632

Closed
@nikomatsakis

Description

@nikomatsakis

Given this example:

fn foo() -> Result<(), ()> {
   bar()? 
}

fn bar() -> Result<(), ()> {
}

fn main() { }

I get this error (playground):

error[E0308]: match arms have incompatible types
 --> src/main.rs:2:4
  |
2 |    bar()? 
  |    ^^^^^^
  |    |
  |    expected enum `std::result::Result`, found ()
  |    match arm with an incompatible type
  |
  = note: expected type `std::result::Result<(), ()>`
             found type `()`

It seems like it should not be talking about match =)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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