-
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
Introducing TokenStreams and TokenSlices for procedural macros #34575
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (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. |
@@ -42,6 +42,7 @@ extern crate libc; | |||
extern crate rustc_unicode; | |||
pub extern crate rustc_errors as errors; | |||
extern crate syntax_pos; | |||
extern crate core; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need this? What does core::iter give you that std::iter does not?
@@ -206,5 +210,1105 @@ impl TokenTree { | |||
true); | |||
macro_parser::parse(cx.parse_sess(), cx.cfg(), arg_rdr, mtch) | |||
} | |||
|
|||
/// Check if this TokenTree is equal to the other, regardless of span information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: comments should end with punctuation
match (self, other) { | ||
(&TokenTree::Token(_, ref tk), &TokenTree::Token(_, ref tk2)) => tk == tk2, | ||
(&TokenTree::Delimited(_, ref dl), &TokenTree::Delimited(_, ref dl2)) => { | ||
if (*dl).delim == (*dl2).delim { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could use &&
rather than if ... else { false }
|
||
/// Returns the token trees inside the delimiters. | ||
pub fn subtrees(&self) -> &[TokenTree] { | ||
&self.tts[..] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the [..]
necessary?
OK, two very minor comments to address, then could you squash the commits please? r+ with that. |
☔ The latest upstream changes (presumably #34652) made this pull request unmergeable. Please resolve the merge conflicts. |
f10f932
to
ec6a3d9
Compare
Took care of bors concern, too. |
…g unit tests and associated operations.
@bors: r+ |
📌 Commit 7547596 has been approved by |
Introducing TokenStreams and TokenSlices for procedural macros This pull request introduces TokenStreams and TokenSlices into the compiler in preparation for usage as part of RFC 1566 (procedural macros). r? @nrc
This pull request introduces TokenStreams and TokenSlices into the compiler in preparation for usage as part of RFC 1566 (procedural macros).
r? @nrc