Skip to content

Struct literals are forbidden in MatchExpressions (feature(if_let_guard)) #93817

Closed

Description

Bug Report

🕗 Version & Regression Information

nightly

🧪 Features

  • if_let_guard

💻 Code

Playground Link

#![feature(if_let_guard)]

struct Bar {}
struct Foo { a: u32 }

fn main() {
    match 0 {
        _ if let _ = Bar {} => {}
        _ if let _ = Foo { a: 0 } => {}
        _ => {}
    }
}

🙁 Actual behavior

  _ if let _ = Bar {} => {}
//                 ^ error: expected one of `!`, `.`, `::`, `=>`, `?`, or an operator
  _ if let _ = Foo { a: 0 } => {}
//             ^^^^^^^^^^^^ error: struct literals are not allowed here
//                           help: surround the struct literal with parentheses

🙂 Expected behavior

No error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-if_let_guard`#![feature(if_let_guard)]`T-langRelevant to the language 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