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 message on invalid fragment specifiers in macros #21158

Merged
merged 1 commit into from Jan 28, 2015

Conversation

alkor
Copy link
Contributor

@alkor alkor commented Jan 14, 2015

Closes #21131
Issue #21131 is already fixed in PR #21429.

I just edited error messages to match terminology from the macros guide ("fragment specifiers")

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nick29581 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@@ -453,7 +453,7 @@ fn is_in_follow(cx: &ExtCtxt, tok: &Token, frag: &str) -> bool {
// harmless
true
},
_ => cx.bug(format!("unrecognized builtin nonterminal {}",
frag).as_slice()),
_ => cx.span_fatal(sp, format!("unrecognized builtin nonterminal {}",
Copy link
Member

Choose a reason for hiding this comment

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

the {} should be enclosed in ```s

Copy link
Member

Choose a reason for hiding this comment

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

bleugh, I was trying to format backticks/graves there

@nrc
Copy link
Member

nrc commented Jan 14, 2015

r=me with the nit about backticks fixed, if you want to add a helpful message, that would be great, but its not necessary to fix this bug.

Thanks for the PR!

_ => {
// invalid fragment specifier. Just pass it along, it will be
// caught in macro_parser::parse_nt()
true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure about silently accepting invalid specifiers here.
Alternative is calling span_help() and span_fatal(), but I didn't want to duplicate error messages from parse_nt.

Copy link
Member

Choose a reason for hiding this comment

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

@cmr - do you think this is OK? It seems OK to me, but also a little bit bad.

Copy link
Member

Choose a reason for hiding this comment

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

This seems reasonable to me, should add in a comment in parse_nt that this bit of code depends on it rejecting invalid fragment specifiers.

@alexcrichton
Copy link
Member

re-r? @nick29581

Also, print help on valid fragment specifiers.
@alkor alkor changed the title Print error instead of ICE on illegal macro_rules Better error message on invalid fragment specifiers in macros Jan 23, 2015
@alkor
Copy link
Contributor Author

alkor commented Jan 23, 2015

@nick29581 Issue #21131 is already fixed in master. So after rebase this PR only modifies error messages to match terminology from the macros guide.

@nrc
Copy link
Member

nrc commented Jan 27, 2015

@bors r+ 8a22454

bors added a commit that referenced this pull request Jan 28, 2015
@bors
Copy link
Contributor

bors commented Jan 28, 2015

⌛ Testing commit 8a22454 with merge 06410ef...

@bors bors merged commit 8a22454 into rust-lang:master Jan 28, 2015
@alkor alkor deleted the issue-21131 branch January 28, 2015 17:04
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.

ICE on illegal macro_rules!
6 participants