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

Incomplete/confusing error when match arm is a static constant #15393

Closed
o11c opened this issue Jul 4, 2014 · 1 comment
Closed

Incomplete/confusing error when match arm is a static constant #15393

o11c opened this issue Jul 4, 2014 · 1 comment

Comments

@o11c
Copy link

o11c commented Jul 4, 2014

The following code gives an error pointing to the static FOO line, but not pointing to the FOO => line, so it's not obvious that the problem is really the match. I originally encountered this from (a form of) the bitflags! macro, which was doubly confusing.

pub struct Flags
{
    bits: uint,
}

static FOO: Flags = Flags{bits: 0x01};
static BAR: Flags = Flags{bits: 0x02};

// caller is guaranteed to only set one bit here.
pub fn frob(f: Flags)
{
    match f
    {
        FOO => {}
        BAR => {}
        _ => {}
    }
}
@huonw
Copy link
Member

huonw commented Jul 4, 2014

cc #6533, #13626, #13731, #14576.

bors added a commit that referenced this issue Jul 19, 2014
This is accomplished by rewriting static expressions into equivalent patterns.
This way, patterns referencing static variables can both participate
in exhaustiveness analysis as well as be compiled down into the appropriate
branch of the decision trees that match expressions are codegened to.

Fixes #6533.
Fixes #13626.
Fixes #13731.
Fixes #14576.
Fixes #15393.
@bors bors closed this as completed in fba1194 Jul 19, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 7, 2023
SCIP: Qualify parameters by the containing function

SCIP requires symbols to be unique, but multiple functions may have a parameter with the same name. Qualify parameters according to the containing function.
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

Successfully merging a pull request may close this issue.

2 participants