Update to the next version of proc-macro2#426
Conversation
|
This is very much a WIP and not a final state, I'm about to be tied up in meetings for a few hours though and wanted to post progress. If anyone would like to take over and/or pile on, feel free! |
|
Ok the whole crate is now building, tests have yet to be updated |
Depends on dtolnay/quote#73 Depends on dtolnay/proc-macro2#90 Depends on a new nightly
src/synom.rs
Outdated
|
|
||
| impl Synom for proc_macro2::Ident { | ||
| fn parse(input: Cursor) -> PResult<Self> { | ||
| input.term().ok_or_else(|| ParseError::new("not an ident")) |
There was a problem hiding this comment.
I would like this to preserve the behavior of 0.13's impl Synom for Ident. Separately we will need some way to do https://docs.rs/syn/0.13/syn/struct.Ident.html#method.parse_any.
There was a problem hiding this comment.
Turns out this was required! Otherwise expressions were parsed very weirdly
src/synom.rs
Outdated
| } | ||
|
|
||
| fn description() -> Option<&'static str> { | ||
| Some("arbitrary token stream") |
There was a problem hiding this comment.
This should be Some("identifier").
|
Ok that might be everything, let's see what CI says... |
|
Ok it looks like the last failure is 1.15.1 but that's just because it doesn't understand |
codegen/src/main.rs
Outdated
| // parse them, so we ignore them here. | ||
| for name in IGNORED_MODS { | ||
| if item.ident == name { | ||
| if item.ident.to_string() == *name { |
There was a problem hiding this comment.
I opened dtolnay/proc-macro2#92 to avoid these changes.
src/lifetime.rs
Outdated
| fn to_tokens(&self, tokens: &mut Tokens) { | ||
| self.term.to_tokens(tokens); | ||
| fn to_tokens(&self, tokens: &mut TokenStream) { | ||
| tokens.append(Punct::new('\'', Spacing::Joint)); |
There was a problem hiding this comment.
This token needs to be stored in the Lifetime struct so that we preserve its Span correctly.
| /// give_away(ident_string); | ||
| /// | ||
| /// fn give_away(s: String) { /* ... */ } | ||
| /// ``` |
There was a problem hiding this comment.
There is valuable explanation and examples being removed here. Compare:
- https://docs.rs/syn/0.13/syn/struct.Ident.html vs
- https://docs.rs/proc-macro2/0.4.1/proc_macro2/struct.Ident.html
Any thoughts on how to provide Syn-specific Ident documentation?
There was a problem hiding this comment.
Hm I wonder if we could just wholesale move the documentation to proc_macro2::Ident?
There was a problem hiding this comment.
Sounds good, I moved this to proc-macro2 in dtolnay/proc-macro2@8b71dac.
| /// Parses any identifier | ||
| /// | ||
| /// This is useful when parsing a DSL which allows Rust keywords as identifiers. | ||
| pub fn parse_any(input: Cursor) -> PResult<Self> { |
There was a problem hiding this comment.
We need to keep some way of doing this. This was added recently in #424.
There was a problem hiding this comment.
Perhaps a new macro parser in synom, like any_ident!()?
| # [ cfg ( any ( feature = "full" , feature = "derive" ) ) ] | ||
| fn fold_generics(&mut self, i: Generics) -> Generics { fold_generics(self, i) } | ||
|
|
||
| fn fold_ident(&mut self, i: Ident) -> Ident { fold_ident(self, i) } |
There was a problem hiding this comment.
I would like to keep fold_ident.
There was a problem hiding this comment.
Oops didn't even realize that went away
|
I can't comment on it directly but please remove the tests/rust submodule added in this PR. IIRC we used to have it but it slows down Cargo git dependencies on Syn. |
|
What's holding this back? |
|
I think we are mostly waiting for @Eijebong to wrap up work on servo/servo#20497 so that the timing can be maximally bad. After that, docs need updating, we need some design work around how to handle what used to be |
|
Serde update: serde-rs/serde#1273 |
Depends on dtolnay/quote#73Depends on dtolnay/proc-macro2#90Depends on a new nightly