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

Disallowed patterns in extern fn declarations. #12715

Merged
merged 1 commit into from
Mar 5, 2014

Conversation

dmski
Copy link
Contributor

@dmski dmski commented Mar 5, 2014

Fixes #10877

There was another PR which attempted to fix this in the parser (#11804) and which was closed due to inactivity.
This PR modifies typeck instead (as suggested in #11804), which indeed seems to be simpler than modifying the parser and allows for a better error message.

match (*i).pat.node {
ast::PatIdent(_, _, _) => (),
_ => ccx.tcx.sess.span_err((*i).pat.span,
"Patterns aren't allowed in foreign function declarations")
Copy link
Member

Choose a reason for hiding this comment

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

Errors in rust traditionally start with lower-case letters instead of upper-case letters.

I would also be fine with whitelisting the _ pattern as well, it seems reasonable enough to allow (and it seems you found a few existing cases of it below).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexcrichton corrected the message and whitelisted the _

bors added a commit that referenced this pull request Mar 5, 2014
Fixes #10877

There was another PR which attempted to fix this in the parser (#11804) and which was closed due to inactivity.
This PR modifies typeck instead (as suggested in #11804), which indeed seems to be simpler than modifying the parser and allows for a better error message.
@bors bors closed this Mar 5, 2014
@bors bors merged commit 53f3442 into rust-lang:master Mar 5, 2014
@dmski dmski deleted the no-extern-fn-pat branch March 5, 2014 22:03
@dmski dmski restored the no-extern-fn-pat branch March 5, 2014 22:03
@dmski dmski deleted the no-extern-fn-pat branch March 5, 2014 22:03
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.

Patterns in extern fns either ICE or aren't type-checked
3 participants