-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Some parser cleanups #127233
Some parser cleanups #127233
Commits on Jul 2, 2024
-
It can contain an owned value instead of a reference.
Configuration menu - View commit details
-
Copy full SHA for 1680b79 - Browse repository at this point
Copy the full SHA 1680b79View commit details -
Configuration menu - View commit details
-
Copy full SHA for d6c0b81 - Browse repository at this point
Copy the full SHA d6c0b81View commit details -
Change
AttrTokenStream::to_tokenstream
toto_token_trees
.I.e. change the return type from `TokenStream` to `Vec<TokenTree>`. Most of the callsites require a `TokenStream`, but the recursive call used to create `target_tokens` requires a `Vec<TokenTree>`. It's easy to convert a `Vec<TokenTree>` to a `TokenStream` (just call `TokenStream::new`) but it's harder to convert a `TokenStream` to a `Vec<TokenTree>` (either iterate/clone/collect, or use `Lrc::into_inner` if appropriate). So this commit changes the return value to simplify that `target_tokens` call site.
Configuration menu - View commit details
-
Copy full SHA for f852568 - Browse repository at this point
Copy the full SHA f852568View commit details -
Rename
TokenStream::new
argument.`tts` is a better name than `streams` for a `Vec<TokenTree>`.
Configuration menu - View commit details
-
Copy full SHA for 0cfd247 - Browse repository at this point
Copy the full SHA 0cfd247View commit details -
Just
push
inAttrTokenStream::to_token_trees
.Currently it uses a mixture of functional style (`flat_map`) and imperative style (`push`), which is a bit hard to read. This commit converts it to fully imperative, which is more concise and avoids the need for `smallvec`.
Configuration menu - View commit details
-
Copy full SHA for 7416c20 - Browse repository at this point
Copy the full SHA 7416c20View commit details -
Configuration menu - View commit details
-
Copy full SHA for 36c30a9 - Browse repository at this point
Copy the full SHA 36c30a9View commit details -
Flip an if/else in
AttrTokenStream::to_attr_token_stream
.To put the simple case first.
Configuration menu - View commit details
-
Copy full SHA for 2342770 - Browse repository at this point
Copy the full SHA 2342770View commit details -
Move things around in
collect_tokens_trailing_token
.So that the `capturing` state is adjusted immediately before and after the call to `f`.
Configuration menu - View commit details
-
Copy full SHA for 8b5a7eb - Browse repository at this point
Copy the full SHA 8b5a7ebView commit details -
Move more things around in
collect_tokens_trailing_token
.To make things a little clearer, and to avoid some `mut` variables.
Configuration menu - View commit details
-
Copy full SHA for f5b2896 - Browse repository at this point
Copy the full SHA f5b2896View commit details -
Shrink parser positions from
usize
tou32
.The number of source code bytes can't exceed a `u32`'s range, so a token position also can't. This reduces the size of `Parser` and `LazyAttrTokenStreamImpl` by eight bytes each.
Configuration menu - View commit details
-
Copy full SHA for 3d750e2 - Browse repository at this point
Copy the full SHA 3d750e2View commit details -
And update the comment. Clearly the return type of this function was changed at some point in the past, but its name and comment weren't updated to match.
Configuration menu - View commit details
-
Copy full SHA for 6f60156 - Browse repository at this point
Copy the full SHA 6f60156View commit details -
Configuration menu - View commit details
-
Copy full SHA for edeebe6 - Browse repository at this point
Copy the full SHA edeebe6View commit details