]> git.lizzy.rs Git - rust.git/commit
Interpolate AST nodes in quasiquote.
authorGeoffry Song <goffrie@gmail.com>
Thu, 5 Mar 2015 20:06:49 +0000 (15:06 -0500)
committerGeoffry Song <goffrie@gmail.com>
Sun, 26 Apr 2015 01:42:10 +0000 (21:42 -0400)
commit2d9831dea598d8a45c69e8c799503e8a397aacc0
tree01b440d423b022b089549022f8a5b411514360aa
parentda623844a9b3f9164723bf7ef2c4744b539af13f
Interpolate AST nodes in quasiquote.

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.

A new `Nonterminal` is added, NtArm, which the parser now interpolates.
This is just for quasiquote, not macros (although it could be in the
future).

`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.
src/libsyntax/ast.rs
src/libsyntax/ext/quote.rs
src/libsyntax/fold.rs
src/libsyntax/parse/lexer/mod.rs
src/libsyntax/parse/mod.rs
src/libsyntax/parse/parser.rs
src/libsyntax/parse/token.rs
src/libsyntax/print/pprust.rs
src/test/run-pass-fulldeps/qquote.rs