Skip to content

"Unreachable pattern" error should be "unresolved name" #13995

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

Closed
depp opened this issue May 6, 2014 · 1 comment
Closed

"Unreachable pattern" error should be "unresolved name" #13995

depp opened this issue May 6, 2014 · 1 comment

Comments

@depp
Copy link

depp commented May 6, 2014

If an enum's variants are not imported, then matching on them will give an "unreachable pattern" error instead of "unresolved name". Example:

#[crate_type = "rlib"]
use A::E;

mod A {
    pub enum E { V1, V2 }
}

fn test(e: E) -> int {
    match e {
        V1 => 1,
        V2 => 2,
    }
}
@alexcrichton
Copy link
Member

Closing, this is reported correctly. The name V1 is not in scope for the match statement, so it is counting as a variable binding, so the V2 branch is no longer reachable.

For a better error message, this is a dupe of #10304

bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 28, 2025
…-lang#13998)

A multipart suggestion will be used whenever the method call can be
replaced by another one with the first argument removed. It helps place
the new method call in context, especially when it is part of a larger
expression.

This fixes rust-lang#13995 by applying a suggestion made by @y21.

r? @y21

changelog: [`unnecessary_map_or`]: better representation of suggestions
by placing them in context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants