Skip to content

Parse error when pattern matching a struct from different module #3847

Closed
@burg

Description

@burg

Adding a leading :: to buildings::Tower will avoid parse errors, though this error has been seen for cross-crate struct uses as well. Is there a reason for this? At the least, the error message should make more sense.

Test case

fn main() {
    let sears = buildings::Tower { height: 1451 };
    let h: uint = match sears {
        buildings::Tower { height: h } => { h }
    }

    io::println(h.to_str());
}

mod buildings {
    struct Tower { height: uint }
}

Output

[burg@host-7-150 Desktop]# rustc test.rs
test.rs:4:25: 4:26 error: expected `=>` but found `{`
test.rs:4         buildings::Tower { height: h } => { h }
                                   ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)A-linkageArea: linking into static, shared libraries and binaries

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions