Skip to content

Pattern matching regression 1.45.0 -> 1.45.1 (+nightly) #74954

Closed
@jsgf

Description

@jsgf

I tried this code:

fn main() {
    if let Some([b'@', filename @ ..]) = Some(b"@abc123") {
        println!("filename {:?}", filename);
    }
}

I expected this to compile and print

filename [97, 98, 99, 49, 50, 51]

which it does with 1.45.0

Instead, it failed to compile on both 1.45.1 and nightly:

error[E0425]: cannot find value `filename` in this scope
 --> src/main.rs:3:35
  |
3 |         println!("filename {:?}", filename);
  |                                   ^^^^^^^^ not found in this scope

error: aborting due to previous error

Playground link

Meta

rustc --version --verbose:

rustc 1.45.1 (c367798cf 2020-07-26)
binary: rustc
commit-hash: c367798cfd3817ca6ae908ce675d1d99242af148
commit-date: 2020-07-26
host: x86_64-unknown-linux-gnu
release: 1.45.1
LLVM version: 10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-slice-patternsArea: Slice patterns, https://github.com/rust-lang/rust/issues/23121C-bugCategory: This is a bug.P-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions