-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Allow lifetimes in macros #41927
Allow lifetimes in macros #41927
Conversation
Started rebasing @sgrif's PR rust-lang#33135 off of current master. (Well, actually merging it into a new branch based off current master.) The following files still need to be fixed or at least reviewed: - `src/libsyntax/ext/tt/macro_parser.rs`: calls `Parser::parse_lifetime`, which doesn't exist anymore - `src/libsyntax/parse/parser.rs`: @sgrif added an error message to `Parser::parse_lifetime`. Code has since been refactored, so I just took it out for now. - `src/libsyntax/ext/tt/transcribe.rs`: This code has been refactored bigtime. Not sure whether @sgrif's changes here are still necessary. Took it out for this commit.
made `parser::Parser::expect_lifetime` public, so it can be called from `macro_parser::parse_nt`
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (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. Due to 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 the contribution instructions for more information. |
All three tests failed, "expected one of BTW, could you add some tests to show that the patch handles labels? #![allow(unreachable_code)]
macro_rules! x {
($a:lifetime) => {
$a: loop {
break $a;
panic!("failed");
}
}
}
macro_rules! br {
($a:lifetime) => {
break $a;
}
}
macro_rules! br2 {
($b:lifetime) => {
'b: loop {
break $b; // this $b should refer to the outer loop.
}
}
}
fn main() {
x!('a);
'c: loop {
br!('c);
panic!("failed");
}
'b: loop {
br2!('b);
panic!("failed");
}
} |
Thanks @kennytm, and sure, I'll add those tests. What is the quickest way to run tests for libsyntax? Anything with |
Do you include LLVM build and similar in "forever"? It only needs to be done once. |
☔ The latest upstream changes (presumably #42049) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm too busy with school right now, and I still don't really understand the code in this PR so I'm going to give up. Someone else will have to take over for this to get implemented. |
This is a resurrection of PR #33135.
@sgrif can you take a look at the following diffs from #33135, and see if those changes are still necessary?
Still to do: