Skip to content

Commit 6365080

Browse files
committed
Auto merge of #23085 - goffrie:interpolating-quote, r=huonw
This changes the `ToTokens` implementations for expressions, statements, etc. with almost-trivial ones that produce `Interpolated(*Nt(...))` pseudo-tokens. In this way, quasiquote now works the same way as macros do: already-parsed AST fragments are used as-is, not reparsed. The `ToSource` trait is removed. Quasiquote no longer involves pretty-printing at all, which removes the need for the `encode_with_hygiene` hack. All associated machinery is removed. New `Nonterminal`s are added: NtArm, NtImplItem, and NtTraitItem. These are just for quasiquote, not macros. `ToTokens` is no longer implemented for `Arg` (although this could be added again) and `Generics` (which I don't think makes sense). This breaks any compiler extensions that relied on the ability of `ToTokens` to turn AST fragments back into inspectable token trees. For this reason, this closes #16987. As such, this is a [breaking-change]. Fixes #16472. Fixes #15962. Fixes #17397. Fixes #16617.
2 parents b0043db + 24ef905 commit 6365080

File tree

15 files changed

+257
-725
lines changed

15 files changed

+257
-725
lines changed

src/libsyntax/ast.rs

-6
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ impl Ident {
8989
pub fn as_str<'a>(&'a self) -> &'a str {
9090
self.name.as_str()
9191
}
92-
93-
pub fn encode_with_hygiene(&self) -> String {
94-
format!("\x00name_{},ctxt_{}\x00",
95-
self.name.usize(),
96-
self.ctxt)
97-
}
9892
}
9993

10094
impl fmt::Debug for Ident {

0 commit comments

Comments
 (0)