Skip to content

Match expressions should sometimes have type ! #3231

Closed
@powerboat9

Description

@powerboat9

Summary

Match expressions with no arms should give a value of type !

Reproducer

I tried this code:

pub enum X {}

pub fn foo(x: X) {
    let _a: i32 = match x {};
}

pub fn main() {}

Does the code make use of any (1.49) nightly feature ?

  • Nightly

Godbolt link

link

Actual behavior

<source>:4:5: error: mismatched types, expected 'i32' but got '()' [E0308]
    4 |     let _a: i32 = match x {};
      |     ^~~     ~~~   ~~~~~

Expected behavior

No error

GCC Version

GCCRS master on godbolt

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions