Skip to content

ref in or-pattern less powerful than match ergonomics #105778

@lcnr

Description

@lcnr
// error
fn bind_by_ref(x: Option<u32>, y: Option<&u32>) {
    match (x, y) {
        (Some(ref x), _) | (_, Some(x)) => {}
        _ => {}
    }
}

// ok
fn match_ergonomics(x: Option<u32>, y: Option<&u32>) {
    match (&x, y) {
        (Some(x), _) | (_, Some(x)) => {}
        _ => {}
    }
}

ideally bind_by_ref also compiles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-patternsRelating to patterns and pattern matching

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions