Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
burg opened this issue Oct 23, 2012 · 2 comments
Closed

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

burg opened this issue Oct 23, 2012 · 2 comments
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) A-linkage Area: linking into static, shared libraries and binaries
Milestone

Comments

@burg
Copy link

burg commented Oct 23, 2012

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 }
                                   ^
@catamorphism
Copy link
Contributor

This appears to work now. Adding the test case.

@catamorphism
Copy link
Contributor

Test case added in 8a687dd -- thanks!

RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 30, 2024
Disable tree traversal optimization that is wrong due to lazy nodes.

See rust-lang#3846 for more information.

For now, the optimization is disabled in a very "hotfix" way, while we think about potential fixes. Nonetheless, this fixes rust-lang#3846
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) A-linkage Area: linking into static, shared libraries and binaries
Projects
None yet
Development

No branches or pull requests

2 participants