about summary refs log tree commit diff
path: root/src/libsyntax/parse/classify.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-12 17:44:06 +0000
committerbors <bors@rust-lang.org>2019-05-12 17:44:06 +0000
commit1764b29725df66183059f406c8c65edf642bbd43 (patch)
tree3a4dca92cceba00645c5a8f29c9f4d36b06cd61c /src/libsyntax/parse/classify.rs
parent0df1e57991e34825697b1659732c0716e7508519 (diff)
parent83ed781c017632d48746553bdb2bf3d1633d5ca4 (diff)
downloadrust-1764b29725df66183059f406c8c65edf642bbd43.tar.gz
rust-1764b29725df66183059f406c8c65edf642bbd43.zip
Auto merge of #60679 - petrochenkov:lit2, r=matklad
Keep original literal tokens in AST

The original literal tokens (`token::Lit`) are kept in AST until lowering to HIR.

The tokens are kept together with their lowered "semantic" representation (`ast::LitKind`), so the size of `ast::Lit` is increased (this also increases the size of meta-item structs used for processing built-in attributes).
However, the size of `ast::Expr` stays the same.

The intent is to remove the "semantic" representation from AST eventually and keep literals as tokens until lowering to HIR (at least), and I'm going to work on that, but it would be good to land this sooner to unblock progress on the [lexer refactoring](https://github.com/rust-lang/rust/pull/59706).

Fixes a part of https://github.com/rust-lang/rust/issues/43081 (literal tokens that are passed to proc macros are always precise, including hexadecimal numbers, strings with their original escaping, etc)
Fixes a part of https://github.com/rust-lang/rust/issues/60495 (everything except for proc macro API doesn't need escaping anymore)
This also allows to eliminate a certain hack from the lexer (https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/pretty-printing.20comments/near/165005357).

cc @matklad
Diffstat (limited to 'src/libsyntax/parse/classify.rs')
-rw-r--r--src/libsyntax/parse/classify.rs13
1 files changed, 0 insertions, 13 deletions
diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs
index b4103440e35..dfd6f451c28 100644
--- a/src/libsyntax/parse/classify.rs
+++ b/src/libsyntax/parse/classify.rs
@@ -25,16 +25,3 @@ pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
         _ => true,
     }
 }
-
-/// this statement requires a semicolon after it.
-/// note that in one case (`stmt_semi`), we've already
-/// seen the semicolon, and thus don't need another.
-pub fn stmt_ends_with_semi(stmt: &ast::StmtKind) -> bool {
-    match *stmt {
-        ast::StmtKind::Local(_) => true,
-        ast::StmtKind::Expr(ref e) => expr_requires_semi_to_be_stmt(e),
-        ast::StmtKind::Item(_) |
-        ast::StmtKind::Semi(..) |
-        ast::StmtKind::Mac(..) => false,
-    }
-}