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

Better error on attempt to rebind identifier for static constant. #9683

Conversation

pnkfelix
Copy link
Member

@pnkfelix pnkfelix commented Oct 2, 2013

r? anyone.

Fix #7526.

}

fn main() {
let b = 4; //~ERROR only irrefutable patterns allowed here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this basically testing what the behavior already was? It'd be nice to have the 'static constant' message also asserted here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I did fix the message to say "irrefutable" instead of "refutable", so technically, this test would flag the previous behavior as wrong. :)

I can throw in the static constant bit, I guess. I don't know what rhyme or reason is typically followed when deciding how much of the error message to include. (I've been idly trying to figure out if I could actually point the user at the span of the relevant import or definition of the static constant, to make things crystal clear...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good point, sorry I missed that! I think that the ability is being added soon as well to have //~ ERROR long message [...] other contents with the discriminant pull request, so you'd be able to omit the middle stuff.

A NOTE would be nice, but probably not necessary, especially if you mention that it's already a static constant.

@alexcrichton
Copy link
Member

needs a rebase :(

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 this pull request may close these issues.

Statics shadow local variables causing "refutable pattern error", and non-obvious bugs.
2 participants