-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Start removing Nonterminal
#114647
Start removing Nonterminal
#114647
Commits on Aug 22, 2023
-
Don't match invisible delimiters in can_begin_expr.
This has no effect right now because invisible delimiters aren't produced by `TokenCursor`, but it will make more sense once invisible delimiter sources are introduced.
Configuration menu - View commit details
-
Copy full SHA for e5035df - Browse repository at this point
Copy the full SHA e5035dfView commit details -
Introduce
InvisibleSource
on invisible delimiters.It's not used meaningfully yet, but will be needed to get rid of interpolated tokens.
Configuration menu - View commit details
-
Copy full SHA for eb03a6d - Browse repository at this point
Copy the full SHA eb03a6dView commit details -
Add invisible open delimiters to
TokenDescription
.Invisible delimiters pretty-print as empty strings, and changing that can break some proc macros. But error messages saying "expected identifer, found ``" are bad. So this commit adds support for invisible open delimiters in `TokenDescription` so they print as "invisible open delimiter" in error messages, instead of "``". It's not used meaningfully yet, but will be needed to get rid of interpolated tokens.
Configuration menu - View commit details
-
Copy full SHA for ad7c621 - Browse repository at this point
Copy the full SHA ad7c621View commit details -
Tweak
expand_incomplete_parse
warning.By using `token_descr`, as is done for many other errors, we can get slightly better descriptions in error messages, e.g. "macro expansion ignores token `let` and any following" becomes "macro expansion ignores keyword `let` and any tokens following". This will be more important once invisible delimiters start being mentioned in error messages.
Configuration menu - View commit details
-
Copy full SHA for e927137 - Browse repository at this point
Copy the full SHA e927137View commit details -
This will make things nicer as more variants are added to `ParseNtResult`.
Configuration menu - View commit details
-
Copy full SHA for fcce5dd - Browse repository at this point
Copy the full SHA fcce5ddView commit details -
Introduce
InvisibleSource::MetaVar
.Token sequences delimited with these invisible delimiters will eventually replace `Token::Interpolated` for declarative macro expansions. There are no uses yet, but this commit does modify `nonterminal_may_begin_with` so that every `Interpolated` test is now mirrored with a `InvisibleSource::MetaVar` test. This means that `Nt*` cases can now be removed from that function one at a time without any other changes required.
Configuration menu - View commit details
-
Copy full SHA for 68d7597 - Browse repository at this point
Copy the full SHA 68d7597View commit details -
We now use invisible delimiters for expanded `vis` fragments, instead of `Token::Interpolated`. This slightly changes some pretty-printed output in tests, but not in any significant way.
Configuration menu - View commit details
-
Copy full SHA for 8da7e52 - Browse repository at this point
Copy the full SHA 8da7e52View commit details -
Notes about tests: - tests/ui/parser/macro/trait-object-macro-matcher.rs: the syntax error is duplicated, because it occurs now when parsing the decl macro input, and also when parsing the expanded decl macro. But this won't show up for normal users due to error de-duplication. - The output of stringify! is uglier, due to `print_tts` producing uglier output than AST pretty-printing.
Configuration menu - View commit details
-
Copy full SHA for 7d9f7cb - Browse repository at this point
Copy the full SHA 7d9f7cbView commit details -
Configuration menu - View commit details
-
Copy full SHA for cab935c - Browse repository at this point
Copy the full SHA cab935cView commit details -
This requires adding `stream_pretty_printing_compatibility_hack`, which will replace `nt_pretty_printing_compatibility_hack` once `NtStmt` is removed. Notable test changes: - `tests/ui/macros/nonterminal-matching.rs` now passes. Removal of `Token::Interpolated` will remove the "captured metavariables except for `:tt`, `:ident` and `:lifetime` cannot be compared to other tokens" restriction. - `tests/ui/proc-macro/expand-to-derive.rs`: the diff looks large but the only difference is the insertion of a single invisible-delimited group. I hope this doesn't cause any new `ProceduralMasquerade`-type problems.
Configuration menu - View commit details
-
Copy full SHA for 1a07e0c - Browse repository at this point
Copy the full SHA 1a07e0cView commit details -
This means `nt_pretty_printing_compatibility_hack` can also be removed. The handling of statements in `transcribe` is slightly different to other nonterminal kinds, due to the lack of `from_ast` implementation for empty statements.
Configuration menu - View commit details
-
Copy full SHA for 06ff446 - Browse repository at this point
Copy the full SHA 06ff446View commit details -
Note: there was an existing code path involving `Interpolated` in `MetaItem::from_tokens` that was dead. This commit transfers that to the new form, but puts an `unreachable!` call inside it.
Configuration menu - View commit details
-
Copy full SHA for b6e6ee0 - Browse repository at this point
Copy the full SHA b6e6ee0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 467c76e - Browse repository at this point
Copy the full SHA 467c76eView commit details -
Configuration menu - View commit details
-
Copy full SHA for ad011f2 - Browse repository at this point
Copy the full SHA ad011f2View commit details -
[xt] move from_token Getting a test failure here: ``` Building tool error_index_generator (stage1 -> stage2, x86_64-unknown-linux-gnu) Compiling cfg-if v1.0.0 ... Compiling mdbook v0.4.31 error: internal compiler error: the following error was constructed but not emitted error: unexpected token: keyword `self` --> /home/njn/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mdbook-0.4.31/src/book/summary.rs:275:31 | 275 | bail!(self.parse_error("Suffix chapters cannot be followed by a list")); | ^^^^ thread 'rustc' panicked at compiler/rustc_errors/src/diagnostic_builder.rs:775:21: error was constructed but not emitted ```
Configuration menu - View commit details
-
Copy full SHA for 26c0de1 - Browse repository at this point
Copy the full SHA 26c0de1View commit details -
Remove NtIdent/NtLifetime/Nonterminal/Token::Interpolated.
Remnants of `Token::Interpolated` still exist in the form of the new `token::IdentMv` and `token::LifetimeMv` tokens. I did them like that because there's a lot of code that assumes an interpolated ident/lifetime fits in a single token, and changing all that code to work with invisible delimiters would have been a pain. (Maybe it could be done in a follow-up.) Fully kills off the "captured metavariables except for `:tt`, `:ident` and `:lifetime` cannot be compared to other tokens" restriction.
Configuration menu - View commit details
-
Copy full SHA for 2c24f50 - Browse repository at this point
Copy the full SHA 2c24f50View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8fc2809 - Browse repository at this point
Copy the full SHA 8fc2809View commit details -
Configuration menu - View commit details
-
Copy full SHA for 848d2d2 - Browse repository at this point
Copy the full SHA 848d2d2View commit details