diff options
| author | nathanwhit <nathan.whitaker01@gmail.com> | 2019-07-25 11:51:05 -0400 |
|---|---|---|
| committer | nathanwhit <nathan.whitaker01@gmail.com> | 2019-08-12 10:14:07 -0400 |
| commit | 71415ef9bd697a49db34742172aacb792ce8d116 (patch) | |
| tree | 28e3f48268a710a98049eb6c8bd7c81c9d325787 /src/libsyntax/parse/parser | |
| parent | c01be67ea40266d6a4c3289654a07ddd7ce2a172 (diff) | |
| download | rust-71415ef9bd697a49db34742172aacb792ce8d116.tar.gz rust-71415ef9bd697a49db34742172aacb792ce8d116.zip | |
Parse excess semicolons as empty stmts for linting
Diffstat (limited to 'src/libsyntax/parse/parser')
| -rw-r--r-- | src/libsyntax/parse/parser/stmt.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser/stmt.rs b/src/libsyntax/parse/parser/stmt.rs index f182edcbff4..750d8fbbddc 100644 --- a/src/libsyntax/parse/parser/stmt.rs +++ b/src/libsyntax/parse/parser/stmt.rs @@ -167,7 +167,22 @@ impl<'a> Parser<'a> { if self.token == token::Semi { unused_attrs(&attrs, self); self.bump(); - return Ok(None); + let mut last_semi = lo; + while self.token == token::Semi { + last_semi = self.token.span; + self.bump(); + } + // We are encoding a string of semicolons as an + // an empty tuple that spans the excess semicolons + // to preserve this info until the lint stage + return Ok(Some(Stmt { + id: ast::DUMMY_NODE_ID, + span: lo.to(last_semi), + node: StmtKind::Semi(self.mk_expr(lo.to(last_semi), + ExprKind::Tup(Vec::new()), + ThinVec::new() + )), + })); } if self.token == token::CloseDelim(token::Brace) { |
