Review proc macro API 1.2 - #50473
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cc #38356
Summary of applied changes:
Term->Ident,TokenTree::Term->TokenTree::Ident,Op->Punct,TokenTree::Op->TokenTree::Punct,Op::op->Punct::as_char.Ident::as_str, useDisplayimpl forIdentinstead.Ident::new_rawfor creating a raw identifier (I'm not surenew_xit's a very idiomatic name though).Punct::newnow ensures that the inputcharis a valid punctuation character in Rust.Ident::newensures that the inputstris a valid identifier in Rust.Punct('\'', Spacing::Joint)andIdent("lifetime_name_without_quote")similarly to multi-character operators.A bit of motivation for renaming (although it was already stated in the review comments):
Identis the single most appropriate name for this thing, especially if we are doing input validation on construction.TokenTree::Identeffectively wrapstoken::Identorast::Ident + is_raw, its meaning is "identifier" and it's already namedidentin declarative macros.Punct, the motivation is thatOpis actively misleading. The thing doesn't mean an operator, it's neither a subset of operators (there is non-operator punctuation in the language), nor superset (operators can be multicharacter while this thing is always a single character). So I named itPunct(first proposed in the original RFC, then by @SimonSapin) , together with input validation it's now a subset of ASCII punctuation character category (u8::is_ascii_punctuation).