Skip to content

Resolve error in pattern match of struct in a different module #3845

@burg

Description

@burg

If a struct is defined elsewhere, it won't get resolved in a pattern match. @pcwalton

Testcase

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 }
}

Error

test.rs:2:16: 2:32 error: `buildings::Tower` does not name a structure
test.rs:2     let sears = buildings::Tower { height: 1451 };
                          ^~~~~~~~~~~~~~~~
test.rs:5:8: 5:26 error: `buildings::Tower` does not name a structure
test.rs:5         ::buildings::Tower { height: h } => { h }
                  ^~~~~~~~~~~~~~~~~~
test.rs:5:37: 5:38 error: unresolved name: h
test.rs:5         ::buildings::Tower { height: h } => { h }
                                               ^
test.rs:5:46: 5:47 error: unresolved name: h
test.rs:5         ::buildings::Tower { height: h } => { h }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions