diff options
| author | bors <bors@rust-lang.org> | 2019-12-21 11:05:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-21 11:05:03 +0000 |
| commit | c64eecf4d0907095928fb36fd3a1dd5fb2d9ff06 (patch) | |
| tree | 073a8038727414aed13f54622fce43ca63990ca6 /src/libsyntax_ext | |
| parent | 9ff30a7810c586819a78188c173a7b74adbb9730 (diff) | |
| parent | 621661f8a63f2118f3add5c3d686d9a2b6f62e5e (diff) | |
| download | rust-c64eecf4d0907095928fb36fd3a1dd5fb2d9ff06.tar.gz rust-c64eecf4d0907095928fb36fd3a1dd5fb2d9ff06.zip | |
Auto merge of #66994 - Centril:stmt-polish, r=estebank
refactor expr & stmt parsing + improve recovery
Summary of important changes (best read commit-by-commit, ignoring whitespace changes):
- `AttrVec` is introduces as an alias for `ThinVec<Attribute>`
- `parse_expr_bottom` and `parse_stmt` are thoroughly refactored.
- Extract diagnostics logic for `vec![...]` in a pattern context.
- Recovery is added for `do catch { ... }`
- Recovery is added for `'label: non_block_expr`
- Recovery is added for `var $local`, `auto $local`, and `mut $local`. Fixes #65257.
- Recovery is added for `e1 and e2` and `e1 or e2`.
- ~~`macro_legacy_warnings` is turned into an error (has been a warning for 3 years!)~~
- Fixes #63396 by forward-porting #64105 which now works thanks to added recovery.
- `ui-fulldeps/ast_stmt_expr_attr.rs` is turned into UI and pretty tests.
- Recovery is fixed for `#[attr] if expr {}`
r? @estebank
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/asm.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax_ext/concat_idents.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/debug.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/mod.rs | 5 |
4 files changed, 5 insertions, 11 deletions
diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index bd345a9a7da..5ec24b7a7ac 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -3,7 +3,6 @@ use State::*; use errors::{DiagnosticBuilder, PResult}; -use rustc_data_structures::thin_vec::ThinVec; use rustc_parse::parser::Parser; use syntax_expand::base::*; use syntax_pos::Span; @@ -63,7 +62,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt<'_>, id: ast::DUMMY_NODE_ID, kind: ast::ExprKind::InlineAsm(P(inline_asm)), span: cx.with_def_site_ctxt(sp), - attrs: ThinVec::new(), + attrs: ast::AttrVec::new(), })) } diff --git a/src/libsyntax_ext/concat_idents.rs b/src/libsyntax_ext/concat_idents.rs index 8a1bc56cf1c..7d8bc8b87bc 100644 --- a/src/libsyntax_ext/concat_idents.rs +++ b/src/libsyntax_ext/concat_idents.rs @@ -1,5 +1,3 @@ -use rustc_data_structures::thin_vec::ThinVec; - use syntax::ast; use syntax_expand::base::{self, *}; use syntax::token::{self, Token}; @@ -49,7 +47,7 @@ pub fn expand_concat_idents<'cx>(cx: &'cx mut ExtCtxt<'_>, id: ast::DUMMY_NODE_ID, kind: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)), span: self.ident.span, - attrs: ThinVec::new(), + attrs: ast::AttrVec::new(), })) } diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 35298211e4d..132ce76e1bb 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -2,8 +2,6 @@ use crate::deriving::path_std; use crate::deriving::generic::*; use crate::deriving::generic::ty::*; -use rustc_data_structures::thin_vec::ThinVec; - use syntax::ast::{self, Ident}; use syntax::ast::{Expr, MetaItem}; use syntax_expand::base::{Annotatable, ExtCtxt}; @@ -127,7 +125,7 @@ fn stmt_let_undescore(cx: &mut ExtCtxt<'_>, sp: Span, expr: P<ast::Expr>) -> ast init: Some(expr), id: ast::DUMMY_NODE_ID, span: sp, - attrs: ThinVec::new(), + attrs: ast::AttrVec::new(), }); ast::Stmt { id: ast::DUMMY_NODE_ID, diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index b7707bfb8e5..5158a5b3da2 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -181,7 +181,6 @@ use std::cell::RefCell; use std::iter; use std::vec; -use rustc_data_structures::thin_vec::ThinVec; use syntax::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind}; use syntax::ast::{VariantData, GenericParamKind, GenericArg}; use syntax::attr; @@ -919,7 +918,7 @@ impl<'a> MethodDef<'a> { let args = { let self_args = explicit_self.map(|explicit_self| { let ident = Ident::with_dummy_span(kw::SelfLower).with_span_pos(trait_.span); - ast::Param::from_self(ThinVec::default(), explicit_self, ident) + ast::Param::from_self(ast::AttrVec::default(), explicit_self, ident) }); let nonself_args = arg_types.into_iter() .map(|(name, ty)| cx.param(trait_.span, name, ty)); @@ -1608,7 +1607,7 @@ impl<'a> TraitDef<'a> { ast::FieldPat { ident: ident.unwrap(), is_shorthand: false, - attrs: ThinVec::new(), + attrs: ast::AttrVec::new(), id: ast::DUMMY_NODE_ID, span: pat.span.with_ctxt(self.span.ctxt()), pat, |
