mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
introduce 'type AttrVec'
This commit is contained in:
parent
3d5dbcb44a
commit
a0d20935cc
@ -53,7 +53,6 @@ use crate::util::nodemap::{DefIdMap, NodeMap};
|
|||||||
use errors::Applicability;
|
use errors::Applicability;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_index::vec::IndexVec;
|
use rustc_index::vec::IndexVec;
|
||||||
use rustc_data_structures::thin_vec::ThinVec;
|
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
@ -1205,7 +1204,7 @@ impl<'a> LoweringContext<'a> {
|
|||||||
id: ty.id,
|
id: ty.id,
|
||||||
kind: ExprKind::Path(qself.clone(), path.clone()),
|
kind: ExprKind::Path(qself.clone(), path.clone()),
|
||||||
span: ty.span,
|
span: ty.span,
|
||||||
attrs: ThinVec::new(),
|
attrs: AttrVec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ct = self.with_new_scopes(|this| {
|
let ct = self.with_new_scopes(|this| {
|
||||||
@ -2751,7 +2750,7 @@ impl<'a> LoweringContext<'a> {
|
|||||||
/// has no attributes and is not targeted by a `break`.
|
/// has no attributes and is not targeted by a `break`.
|
||||||
fn lower_block_expr(&mut self, b: &Block) -> hir::Expr {
|
fn lower_block_expr(&mut self, b: &Block) -> hir::Expr {
|
||||||
let block = self.lower_block(b, false);
|
let block = self.lower_block(b, false);
|
||||||
self.expr_block(block, ThinVec::new())
|
self.expr_block(block, AttrVec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
|
fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
|
||||||
@ -3102,7 +3101,7 @@ impl<'a> LoweringContext<'a> {
|
|||||||
|
|
||||||
fn stmt_let_pat(
|
fn stmt_let_pat(
|
||||||
&mut self,
|
&mut self,
|
||||||
attrs: ThinVec<Attribute>,
|
attrs: AttrVec,
|
||||||
span: Span,
|
span: Span,
|
||||||
init: Option<P<hir::Expr>>,
|
init: Option<P<hir::Expr>>,
|
||||||
pat: P<hir::Pat>,
|
pat: P<hir::Pat>,
|
||||||
|
@ -1318,8 +1318,7 @@ impl LoweringContext<'_> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
span: Span,
|
span: Span,
|
||||||
expr: P<hir::Expr>,
|
expr: P<hir::Expr>,
|
||||||
attrs: ThinVec<Attribute>
|
attrs: AttrVec) -> hir::Expr {
|
||||||
) -> hir::Expr {
|
|
||||||
self.expr(span, hir::ExprKind::DropTemps(expr), attrs)
|
self.expr(span, hir::ExprKind::DropTemps(expr), attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1333,7 +1332,7 @@ impl LoweringContext<'_> {
|
|||||||
self.expr(span, hir::ExprKind::Match(arg, arms, source), ThinVec::new())
|
self.expr(span, hir::ExprKind::Match(arg, arms, source), ThinVec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_break(&mut self, span: Span, attrs: ThinVec<Attribute>) -> P<hir::Expr> {
|
fn expr_break(&mut self, span: Span, attrs: AttrVec) -> P<hir::Expr> {
|
||||||
let expr_break = hir::ExprKind::Break(self.lower_loop_destination(None), None);
|
let expr_break = hir::ExprKind::Break(self.lower_loop_destination(None), None);
|
||||||
P(self.expr(span, expr_break, attrs))
|
P(self.expr(span, expr_break, attrs))
|
||||||
}
|
}
|
||||||
@ -1404,7 +1403,7 @@ impl LoweringContext<'_> {
|
|||||||
span: Span,
|
span: Span,
|
||||||
components: &[Symbol],
|
components: &[Symbol],
|
||||||
params: Option<P<hir::GenericArgs>>,
|
params: Option<P<hir::GenericArgs>>,
|
||||||
attrs: ThinVec<Attribute>,
|
attrs: AttrVec,
|
||||||
) -> hir::Expr {
|
) -> hir::Expr {
|
||||||
let path = self.std_path(span, components, params, true);
|
let path = self.std_path(span, components, params, true);
|
||||||
self.expr(
|
self.expr(
|
||||||
@ -1423,7 +1422,7 @@ impl LoweringContext<'_> {
|
|||||||
span: Span,
|
span: Span,
|
||||||
ident: Ident,
|
ident: Ident,
|
||||||
binding: hir::HirId,
|
binding: hir::HirId,
|
||||||
attrs: ThinVec<Attribute>,
|
attrs: AttrVec,
|
||||||
) -> hir::Expr {
|
) -> hir::Expr {
|
||||||
let expr_path = hir::ExprKind::Path(hir::QPath::Resolved(
|
let expr_path = hir::ExprKind::Path(hir::QPath::Resolved(
|
||||||
None,
|
None,
|
||||||
@ -1459,16 +1458,11 @@ impl LoweringContext<'_> {
|
|||||||
self.expr_block(P(blk), ThinVec::new())
|
self.expr_block(P(blk), ThinVec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn expr_block(&mut self, b: P<hir::Block>, attrs: ThinVec<Attribute>) -> hir::Expr {
|
pub(super) fn expr_block(&mut self, b: P<hir::Block>, attrs: AttrVec) -> hir::Expr {
|
||||||
self.expr(b.span, hir::ExprKind::Block(b, None), attrs)
|
self.expr(b.span, hir::ExprKind::Block(b, None), attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn expr(
|
pub(super) fn expr(&mut self, span: Span, kind: hir::ExprKind, attrs: AttrVec) -> hir::Expr {
|
||||||
&mut self,
|
|
||||||
span: Span,
|
|
||||||
kind: hir::ExprKind,
|
|
||||||
attrs: ThinVec<Attribute>
|
|
||||||
) -> hir::Expr {
|
|
||||||
hir::Expr { hir_id: self.next_id(), kind, span, attrs }
|
hir::Expr { hir_id: self.next_id(), kind, span, attrs }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ use crate::hir::def_id::DefId;
|
|||||||
use crate::hir::def::{Res, DefKind};
|
use crate::hir::def::{Res, DefKind};
|
||||||
use crate::util::nodemap::NodeMap;
|
use crate::util::nodemap::NodeMap;
|
||||||
|
|
||||||
use rustc_data_structures::thin_vec::ThinVec;
|
|
||||||
use rustc_target::spec::abi;
|
use rustc_target::spec::abi;
|
||||||
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
@ -899,7 +898,7 @@ impl LoweringContext<'_> {
|
|||||||
|
|
||||||
/// Construct `ExprKind::Err` for the given `span`.
|
/// Construct `ExprKind::Err` for the given `span`.
|
||||||
fn expr_err(&mut self, span: Span) -> hir::Expr {
|
fn expr_err(&mut self, span: Span) -> hir::Expr {
|
||||||
self.expr(span, hir::ExprKind::Err, ThinVec::new())
|
self.expr(span, hir::ExprKind::Err, AttrVec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem {
|
fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem {
|
||||||
@ -1182,7 +1181,7 @@ impl LoweringContext<'_> {
|
|||||||
//
|
//
|
||||||
// If this is the simple case, this parameter will end up being the same as the
|
// If this is the simple case, this parameter will end up being the same as the
|
||||||
// original parameter, but with a different pattern id.
|
// original parameter, but with a different pattern id.
|
||||||
let mut stmt_attrs = ThinVec::new();
|
let mut stmt_attrs = AttrVec::new();
|
||||||
stmt_attrs.extend(parameter.attrs.iter().cloned());
|
stmt_attrs.extend(parameter.attrs.iter().cloned());
|
||||||
let (new_parameter_pat, new_parameter_id) = this.pat_ident(desugared_span, ident);
|
let (new_parameter_pat, new_parameter_id) = this.pat_ident(desugared_span, ident);
|
||||||
let new_parameter = hir::Param {
|
let new_parameter = hir::Param {
|
||||||
@ -1226,7 +1225,7 @@ impl LoweringContext<'_> {
|
|||||||
desugared_span, ident, hir::BindingAnnotation::Mutable);
|
desugared_span, ident, hir::BindingAnnotation::Mutable);
|
||||||
let move_expr = this.expr_ident(desugared_span, ident, new_parameter_id);
|
let move_expr = this.expr_ident(desugared_span, ident, new_parameter_id);
|
||||||
let move_stmt = this.stmt_let_pat(
|
let move_stmt = this.stmt_let_pat(
|
||||||
ThinVec::new(),
|
AttrVec::new(),
|
||||||
desugared_span,
|
desugared_span,
|
||||||
Some(P(move_expr)),
|
Some(P(move_expr)),
|
||||||
move_pat,
|
move_pat,
|
||||||
@ -1271,7 +1270,7 @@ impl LoweringContext<'_> {
|
|||||||
let user_body = this.expr_drop_temps(
|
let user_body = this.expr_drop_temps(
|
||||||
desugared_span,
|
desugared_span,
|
||||||
P(user_body),
|
P(user_body),
|
||||||
ThinVec::new(),
|
AttrVec::new(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// As noted above, create the final block like
|
// As noted above, create the final block like
|
||||||
@ -1288,9 +1287,9 @@ impl LoweringContext<'_> {
|
|||||||
statements.into(),
|
statements.into(),
|
||||||
Some(P(user_body)),
|
Some(P(user_body)),
|
||||||
);
|
);
|
||||||
this.expr_block(P(body), ThinVec::new())
|
this.expr_block(P(body), AttrVec::new())
|
||||||
});
|
});
|
||||||
(HirVec::from(parameters), this.expr(body_span, async_expr, ThinVec::new()))
|
(HirVec::from(parameters), this.expr(body_span, async_expr, AttrVec::new()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ use errors::FatalError;
|
|||||||
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
|
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
|
||||||
use syntax::source_map::Spanned;
|
use syntax::source_map::Spanned;
|
||||||
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
|
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
|
||||||
use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
|
use syntax::ast::{AttrVec, Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
|
||||||
pub use syntax::ast::{Mutability, Constness, Unsafety, Movability, CaptureBy};
|
pub use syntax::ast::{Mutability, Constness, Unsafety, Movability, CaptureBy};
|
||||||
pub use syntax::ast::{IsAuto, ImplPolarity, BorrowKind};
|
pub use syntax::ast::{IsAuto, ImplPolarity, BorrowKind};
|
||||||
use syntax::attr::{InlineAttr, OptimizeAttr};
|
use syntax::attr::{InlineAttr, OptimizeAttr};
|
||||||
@ -29,7 +29,6 @@ use syntax::tokenstream::TokenStream;
|
|||||||
use syntax::util::parser::ExprPrecedence;
|
use syntax::util::parser::ExprPrecedence;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
|
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
|
||||||
use rustc_data_structures::thin_vec::ThinVec;
|
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use rustc_serialize::{self, Encoder, Encodable, Decoder, Decodable};
|
use rustc_serialize::{self, Encoder, Encodable, Decoder, Decodable};
|
||||||
use std::collections::{BTreeSet, BTreeMap};
|
use std::collections::{BTreeSet, BTreeMap};
|
||||||
@ -1274,7 +1273,7 @@ pub struct Local {
|
|||||||
pub init: Option<P<Expr>>,
|
pub init: Option<P<Expr>>,
|
||||||
pub hir_id: HirId,
|
pub hir_id: HirId,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub attrs: ThinVec<Attribute>,
|
pub attrs: AttrVec,
|
||||||
/// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop
|
/// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop
|
||||||
/// desugaring. Otherwise will be `Normal`.
|
/// desugaring. Otherwise will be `Normal`.
|
||||||
pub source: LocalSource,
|
pub source: LocalSource,
|
||||||
@ -1459,7 +1458,7 @@ pub struct AnonConst {
|
|||||||
pub struct Expr {
|
pub struct Expr {
|
||||||
pub hir_id: HirId,
|
pub hir_id: HirId,
|
||||||
pub kind: ExprKind,
|
pub kind: ExprKind,
|
||||||
pub attrs: ThinVec<Attribute>,
|
pub attrs: AttrVec,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ use rustc_data_structures::jobserver;
|
|||||||
use rustc_data_structures::sync::{Lock, Lrc};
|
use rustc_data_structures::sync::{Lock, Lrc};
|
||||||
use rustc_data_structures::stable_hasher::StableHasher;
|
use rustc_data_structures::stable_hasher::StableHasher;
|
||||||
use rustc_data_structures::fingerprint::Fingerprint;
|
use rustc_data_structures::fingerprint::Fingerprint;
|
||||||
use rustc_data_structures::thin_vec::ThinVec;
|
|
||||||
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
|
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
|
||||||
use rustc_errors::registry::Registry;
|
use rustc_errors::registry::Registry;
|
||||||
use rustc_metadata::dynamic_lib::DynamicLibrary;
|
use rustc_metadata::dynamic_lib::DynamicLibrary;
|
||||||
@ -24,7 +23,7 @@ use std::ops::DerefMut;
|
|||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::mut_visit::{*, MutVisitor, visit_clobber};
|
use syntax::mut_visit::{*, MutVisitor, visit_clobber};
|
||||||
use syntax::ast::BlockCheckMode;
|
use syntax::ast::{AttrVec, BlockCheckMode};
|
||||||
use syntax::util::lev_distance::find_best_match_for_name;
|
use syntax::util::lev_distance::find_best_match_for_name;
|
||||||
use syntax::source_map::{FileLoader, RealFileLoader, SourceMap};
|
use syntax::source_map::{FileLoader, RealFileLoader, SourceMap};
|
||||||
use syntax::symbol::{Symbol, sym};
|
use syntax::symbol::{Symbol, sym};
|
||||||
@ -741,7 +740,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
|
|||||||
id: resolver.next_node_id(),
|
id: resolver.next_node_id(),
|
||||||
kind: ast::ExprKind::Block(P(b), None),
|
kind: ast::ExprKind::Block(P(b), None),
|
||||||
span: syntax_pos::DUMMY_SP,
|
span: syntax_pos::DUMMY_SP,
|
||||||
attrs: ThinVec::new(),
|
attrs: AttrVec::new(),
|
||||||
});
|
});
|
||||||
|
|
||||||
ast::Stmt {
|
ast::Stmt {
|
||||||
@ -756,7 +755,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
|
|||||||
kind: ast::ExprKind::Loop(P(empty_block), None),
|
kind: ast::ExprKind::Loop(P(empty_block), None),
|
||||||
id: self.resolver.next_node_id(),
|
id: self.resolver.next_node_id(),
|
||||||
span: syntax_pos::DUMMY_SP,
|
span: syntax_pos::DUMMY_SP,
|
||||||
attrs: ThinVec::new(),
|
attrs: AttrVec::new(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let loop_stmt = ast::Stmt {
|
let loop_stmt = ast::Stmt {
|
||||||
|
@ -4,11 +4,10 @@ use rustc_data_structures::fx::FxHashSet;
|
|||||||
use rustc_errors::{self, PResult, Applicability, DiagnosticBuilder, Handler, pluralize};
|
use rustc_errors::{self, PResult, Applicability, DiagnosticBuilder, Handler, pluralize};
|
||||||
use rustc_error_codes::*;
|
use rustc_error_codes::*;
|
||||||
use syntax::ast::{self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item};
|
use syntax::ast::{self, Param, BinOpKind, BindingMode, BlockCheckMode, Expr, ExprKind, Ident, Item};
|
||||||
use syntax::ast::{ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind, Attribute};
|
use syntax::ast::{ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind, AttrVec};
|
||||||
use syntax::token::{self, TokenKind, token_can_begin_expr};
|
use syntax::token::{self, TokenKind, token_can_begin_expr};
|
||||||
use syntax::print::pprust;
|
use syntax::print::pprust;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::ThinVec;
|
|
||||||
use syntax::util::parser::AssocOp;
|
use syntax::util::parser::AssocOp;
|
||||||
use syntax::struct_span_err;
|
use syntax::struct_span_err;
|
||||||
use syntax_pos::symbol::kw;
|
use syntax_pos::symbol::kw;
|
||||||
@ -32,7 +31,7 @@ pub(super) fn dummy_arg(ident: Ident) -> Param {
|
|||||||
id: ast::DUMMY_NODE_ID
|
id: ast::DUMMY_NODE_ID
|
||||||
};
|
};
|
||||||
Param {
|
Param {
|
||||||
attrs: ThinVec::default(),
|
attrs: AttrVec::default(),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
pat,
|
pat,
|
||||||
span: ident.span,
|
span: ident.span,
|
||||||
@ -164,7 +163,7 @@ impl RecoverQPath for Expr {
|
|||||||
Self {
|
Self {
|
||||||
span: path.span,
|
span: path.span,
|
||||||
kind: ExprKind::Path(qself, path),
|
kind: ExprKind::Path(qself, path),
|
||||||
attrs: ThinVec::new(),
|
attrs: AttrVec::new(),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,7 +550,7 @@ impl<'a> Parser<'a> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let mk_err_expr = |this: &Self, span| {
|
let mk_err_expr = |this: &Self, span| {
|
||||||
Ok(Some(this.mk_expr(span, ExprKind::Err, ThinVec::new())))
|
Ok(Some(this.mk_expr(span, ExprKind::Err, AttrVec::new())))
|
||||||
};
|
};
|
||||||
|
|
||||||
match lhs.kind {
|
match lhs.kind {
|
||||||
@ -974,7 +973,7 @@ impl<'a> Parser<'a> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
lo: Span,
|
lo: Span,
|
||||||
await_sp: Span,
|
await_sp: Span,
|
||||||
attrs: ThinVec<Attribute>,
|
attrs: AttrVec,
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
let (hi, expr, is_question) = if self.token == token::Not {
|
let (hi, expr, is_question) = if self.token == token::Not {
|
||||||
// Handle `await!(<expr>)`.
|
// Handle `await!(<expr>)`.
|
||||||
@ -1005,7 +1004,7 @@ impl<'a> Parser<'a> {
|
|||||||
None,
|
None,
|
||||||
self.token.span,
|
self.token.span,
|
||||||
BlockCheckMode::Default,
|
BlockCheckMode::Default,
|
||||||
ThinVec::new(),
|
AttrVec::new(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
self.parse_expr()
|
self.parse_expr()
|
||||||
@ -1126,7 +1125,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.emit();
|
err.emit();
|
||||||
// Recover from parse error, callers expect the closing delim to be consumed.
|
// Recover from parse error, callers expect the closing delim to be consumed.
|
||||||
self.consume_block(delim, ConsumeClosingDelim::Yes);
|
self.consume_block(delim, ConsumeClosingDelim::Yes);
|
||||||
self.mk_expr(lo.to(self.prev_span), ExprKind::Err, ThinVec::new())
|
self.mk_expr(lo.to(self.prev_span), ExprKind::Err, AttrVec::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,10 @@ use super::pat::{GateOr, PARAM_EXPECTED};
|
|||||||
use super::diagnostics::Error;
|
use super::diagnostics::Error;
|
||||||
use crate::maybe_recover_from_interpolated_ty_qpath;
|
use crate::maybe_recover_from_interpolated_ty_qpath;
|
||||||
|
|
||||||
use rustc_data_structures::thin_vec::ThinVec;
|
|
||||||
use rustc_errors::{PResult, Applicability};
|
use rustc_errors::{PResult, Applicability};
|
||||||
use syntax::ast::{self, DUMMY_NODE_ID, Attribute, AttrStyle, Ident, CaptureBy, BlockCheckMode};
|
use syntax::ast::{self, DUMMY_NODE_ID, AttrVec, AttrStyle, Ident, CaptureBy, Field, Lit};
|
||||||
use syntax::ast::{Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm, Ty, TyKind};
|
use syntax::ast::{BlockCheckMode, Expr, ExprKind, RangeLimits, Label, Movability, IsAsync, Arm};
|
||||||
use syntax::ast::{FunctionRetTy, Param, FnDecl, BinOpKind, BinOp, UnOp, Mac, AnonConst, Field, Lit};
|
use syntax::ast::{Ty, TyKind, FunctionRetTy, Param, FnDecl, BinOpKind, BinOp, UnOp, Mac, AnonConst};
|
||||||
use syntax::token::{self, Token, TokenKind};
|
use syntax::token::{self, Token, TokenKind};
|
||||||
use syntax::print::pprust;
|
use syntax::print::pprust;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
@ -37,14 +36,14 @@ macro_rules! maybe_whole_expr {
|
|||||||
let path = path.clone();
|
let path = path.clone();
|
||||||
$p.bump();
|
$p.bump();
|
||||||
return Ok($p.mk_expr(
|
return Ok($p.mk_expr(
|
||||||
$p.token.span, ExprKind::Path(None, path), ThinVec::new()
|
$p.token.span, ExprKind::Path(None, path), AttrVec::new()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
token::NtBlock(block) => {
|
token::NtBlock(block) => {
|
||||||
let block = block.clone();
|
let block = block.clone();
|
||||||
$p.bump();
|
$p.bump();
|
||||||
return Ok($p.mk_expr(
|
return Ok($p.mk_expr(
|
||||||
$p.token.span, ExprKind::Block(block, None), ThinVec::new()
|
$p.token.span, ExprKind::Block(block, None), AttrVec::new()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
// N.B., `NtIdent(ident)` is normalized to `Ident` in `fn bump`.
|
// N.B., `NtIdent(ident)` is normalized to `Ident` in `fn bump`.
|
||||||
@ -57,16 +56,16 @@ macro_rules! maybe_whole_expr {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(super) enum LhsExpr {
|
pub(super) enum LhsExpr {
|
||||||
NotYetParsed,
|
NotYetParsed,
|
||||||
AttributesParsed(ThinVec<Attribute>),
|
AttributesParsed(AttrVec),
|
||||||
AlreadyParsed(P<Expr>),
|
AlreadyParsed(P<Expr>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Option<ThinVec<Attribute>>> for LhsExpr {
|
impl From<Option<AttrVec>> for LhsExpr {
|
||||||
/// Converts `Some(attrs)` into `LhsExpr::AttributesParsed(attrs)`
|
/// Converts `Some(attrs)` into `LhsExpr::AttributesParsed(attrs)`
|
||||||
/// and `None` into `LhsExpr::NotYetParsed`.
|
/// and `None` into `LhsExpr::NotYetParsed`.
|
||||||
///
|
///
|
||||||
/// This conversion does not allocate.
|
/// This conversion does not allocate.
|
||||||
fn from(o: Option<ThinVec<Attribute>>) -> Self {
|
fn from(o: Option<AttrVec>) -> Self {
|
||||||
if let Some(attrs) = o {
|
if let Some(attrs) = o {
|
||||||
LhsExpr::AttributesParsed(attrs)
|
LhsExpr::AttributesParsed(attrs)
|
||||||
} else {
|
} else {
|
||||||
@ -103,7 +102,7 @@ impl<'a> Parser<'a> {
|
|||||||
err.emit();
|
err.emit();
|
||||||
let sp = self.token.span;
|
let sp = self.token.span;
|
||||||
self.bump();
|
self.bump();
|
||||||
Ok(self.mk_expr(sp, ExprKind::Err, ThinVec::new()))
|
Ok(self.mk_expr(sp, ExprKind::Err, AttrVec::new()))
|
||||||
}
|
}
|
||||||
_ => Err(err),
|
_ => Err(err),
|
||||||
},
|
},
|
||||||
@ -122,7 +121,7 @@ impl<'a> Parser<'a> {
|
|||||||
pub(super) fn parse_expr_res(
|
pub(super) fn parse_expr_res(
|
||||||
&mut self,
|
&mut self,
|
||||||
r: Restrictions,
|
r: Restrictions,
|
||||||
already_parsed_attrs: Option<ThinVec<Attribute>>
|
already_parsed_attrs: Option<AttrVec>
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
self.with_res(r, |this| this.parse_assoc_expr(already_parsed_attrs))
|
self.with_res(r, |this| this.parse_assoc_expr(already_parsed_attrs))
|
||||||
}
|
}
|
||||||
@ -134,7 +133,7 @@ impl<'a> Parser<'a> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn parse_assoc_expr(
|
fn parse_assoc_expr(
|
||||||
&mut self,
|
&mut self,
|
||||||
already_parsed_attrs: Option<ThinVec<Attribute>>,
|
already_parsed_attrs: Option<AttrVec>,
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
self.parse_assoc_expr_with(0, already_parsed_attrs.into())
|
self.parse_assoc_expr_with(0, already_parsed_attrs.into())
|
||||||
}
|
}
|
||||||
@ -237,7 +236,7 @@ impl<'a> Parser<'a> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let r = self.mk_range(Some(lhs), rhs, limits)?;
|
let r = self.mk_range(Some(lhs), rhs, limits)?;
|
||||||
lhs = self.mk_expr(lhs_span.to(rhs_span), r, ThinVec::new());
|
lhs = self.mk_expr(lhs_span.to(rhs_span), r, AttrVec::new());
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,9 +270,9 @@ impl<'a> Parser<'a> {
|
|||||||
AssocOp::Greater | AssocOp::GreaterEqual => {
|
AssocOp::Greater | AssocOp::GreaterEqual => {
|
||||||
let ast_op = op.to_ast_binop().unwrap();
|
let ast_op = op.to_ast_binop().unwrap();
|
||||||
let binary = self.mk_binary(source_map::respan(cur_op_span, ast_op), lhs, rhs);
|
let binary = self.mk_binary(source_map::respan(cur_op_span, ast_op), lhs, rhs);
|
||||||
self.mk_expr(span, binary, ThinVec::new())
|
self.mk_expr(span, binary, AttrVec::new())
|
||||||
}
|
}
|
||||||
AssocOp::Assign => self.mk_expr(span, ExprKind::Assign(lhs, rhs), ThinVec::new()),
|
AssocOp::Assign => self.mk_expr(span, ExprKind::Assign(lhs, rhs), AttrVec::new()),
|
||||||
AssocOp::AssignOp(k) => {
|
AssocOp::AssignOp(k) => {
|
||||||
let aop = match k {
|
let aop = match k {
|
||||||
token::Plus => BinOpKind::Add,
|
token::Plus => BinOpKind::Add,
|
||||||
@ -288,7 +287,7 @@ impl<'a> Parser<'a> {
|
|||||||
token::Shr => BinOpKind::Shr,
|
token::Shr => BinOpKind::Shr,
|
||||||
};
|
};
|
||||||
let aopexpr = self.mk_assign_op(source_map::respan(cur_op_span, aop), lhs, rhs);
|
let aopexpr = self.mk_assign_op(source_map::respan(cur_op_span, aop), lhs, rhs);
|
||||||
self.mk_expr(span, aopexpr, ThinVec::new())
|
self.mk_expr(span, aopexpr, AttrVec::new())
|
||||||
}
|
}
|
||||||
AssocOp::As | AssocOp::Colon | AssocOp::DotDot | AssocOp::DotDotEq => {
|
AssocOp::As | AssocOp::Colon | AssocOp::DotDot | AssocOp::DotDotEq => {
|
||||||
self.bug("AssocOp should have been handled by special case")
|
self.bug("AssocOp should have been handled by special case")
|
||||||
@ -398,7 +397,7 @@ impl<'a> Parser<'a> {
|
|||||||
/// Parses prefix-forms of range notation: `..expr`, `..`, `..=expr`.
|
/// Parses prefix-forms of range notation: `..expr`, `..`, `..=expr`.
|
||||||
fn parse_prefix_range_expr(
|
fn parse_prefix_range_expr(
|
||||||
&mut self,
|
&mut self,
|
||||||
already_parsed_attrs: Option<ThinVec<Attribute>>
|
already_parsed_attrs: Option<AttrVec>
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
// Check for deprecated `...` syntax.
|
// Check for deprecated `...` syntax.
|
||||||
if self.token == token::DotDotDot {
|
if self.token == token::DotDotDot {
|
||||||
@ -435,10 +434,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parses a prefix-unary-operator expr.
|
/// Parses a prefix-unary-operator expr.
|
||||||
fn parse_prefix_expr(
|
fn parse_prefix_expr(&mut self, already_parsed_attrs: Option<AttrVec>) -> PResult<'a, P<Expr>> {
|
||||||
&mut self,
|
|
||||||
already_parsed_attrs: Option<ThinVec<Attribute>>
|
|
||||||
) -> PResult<'a, P<Expr>> {
|
|
||||||
let attrs = self.parse_or_use_outer_attributes(already_parsed_attrs)?;
|
let attrs = self.parse_or_use_outer_attributes(already_parsed_attrs)?;
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
// Note: when adding new unary operators, don't forget to adjust TokenKind::can_begin_expr()
|
// Note: when adding new unary operators, don't forget to adjust TokenKind::can_begin_expr()
|
||||||
@ -549,7 +545,7 @@ impl<'a> Parser<'a> {
|
|||||||
expr_kind: fn(P<Expr>, P<Ty>) -> ExprKind)
|
expr_kind: fn(P<Expr>, P<Ty>) -> ExprKind)
|
||||||
-> PResult<'a, P<Expr>> {
|
-> PResult<'a, P<Expr>> {
|
||||||
let mk_expr = |this: &mut Self, rhs: P<Ty>| {
|
let mk_expr = |this: &mut Self, rhs: P<Ty>| {
|
||||||
this.mk_expr(lhs_span.to(rhs.span), expr_kind(lhs, rhs), ThinVec::new())
|
this.mk_expr(lhs_span.to(rhs.span), expr_kind(lhs, rhs), AttrVec::new())
|
||||||
};
|
};
|
||||||
|
|
||||||
// Save the state of the parser before parsing type normally, in case there is a
|
// Save the state of the parser before parsing type normally, in case there is a
|
||||||
@ -650,7 +646,7 @@ impl<'a> Parser<'a> {
|
|||||||
/// Parses `a.b` or `a(13)` or `a[4]` or just `a`.
|
/// Parses `a.b` or `a(13)` or `a[4]` or just `a`.
|
||||||
fn parse_dot_or_call_expr(
|
fn parse_dot_or_call_expr(
|
||||||
&mut self,
|
&mut self,
|
||||||
already_parsed_attrs: Option<ThinVec<Attribute>>,
|
already_parsed_attrs: Option<AttrVec>,
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
let attrs = self.parse_or_use_outer_attributes(already_parsed_attrs)?;
|
let attrs = self.parse_or_use_outer_attributes(already_parsed_attrs)?;
|
||||||
|
|
||||||
@ -663,7 +659,7 @@ impl<'a> Parser<'a> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
e0: P<Expr>,
|
e0: P<Expr>,
|
||||||
lo: Span,
|
lo: Span,
|
||||||
mut attrs: ThinVec<Attribute>,
|
mut attrs: AttrVec,
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
// Stitch the list of outer attributes onto the return value.
|
// Stitch the list of outer attributes onto the return value.
|
||||||
// A little bit ugly, but the best way given the current code
|
// A little bit ugly, but the best way given the current code
|
||||||
@ -692,7 +688,7 @@ impl<'a> Parser<'a> {
|
|||||||
// expr?
|
// expr?
|
||||||
while self.eat(&token::Question) {
|
while self.eat(&token::Question) {
|
||||||
let hi = self.prev_span;
|
let hi = self.prev_span;
|
||||||
e = self.mk_expr(lo.to(hi), ExprKind::Try(e), ThinVec::new());
|
e = self.mk_expr(lo.to(hi), ExprKind::Try(e), AttrVec::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
// expr.f
|
// expr.f
|
||||||
@ -705,7 +701,7 @@ impl<'a> Parser<'a> {
|
|||||||
let span = self.token.span;
|
let span = self.token.span;
|
||||||
self.bump();
|
self.bump();
|
||||||
let field = ExprKind::Field(e, Ident::new(symbol, span));
|
let field = ExprKind::Field(e, Ident::new(symbol, span));
|
||||||
e = self.mk_expr(lo.to(span), field, ThinVec::new());
|
e = self.mk_expr(lo.to(span), field, AttrVec::new());
|
||||||
|
|
||||||
self.expect_no_suffix(span, "a tuple index", suffix);
|
self.expect_no_suffix(span, "a tuple index", suffix);
|
||||||
}
|
}
|
||||||
@ -754,7 +750,7 @@ impl<'a> Parser<'a> {
|
|||||||
let seq = self.parse_paren_expr_seq().map(|es| {
|
let seq = self.parse_paren_expr_seq().map(|es| {
|
||||||
let nd = self.mk_call(e, es);
|
let nd = self.mk_call(e, es);
|
||||||
let hi = self.prev_span;
|
let hi = self.prev_span;
|
||||||
self.mk_expr(lo.to(hi), nd, ThinVec::new())
|
self.mk_expr(lo.to(hi), nd, AttrVec::new())
|
||||||
});
|
});
|
||||||
e = self.recover_seq_parse_error(token::Paren, lo, seq);
|
e = self.recover_seq_parse_error(token::Paren, lo, seq);
|
||||||
}
|
}
|
||||||
@ -767,7 +763,7 @@ impl<'a> Parser<'a> {
|
|||||||
hi = self.token.span;
|
hi = self.token.span;
|
||||||
self.expect(&token::CloseDelim(token::Bracket))?;
|
self.expect(&token::CloseDelim(token::Bracket))?;
|
||||||
let index = self.mk_index(e, ix);
|
let index = self.mk_index(e, ix);
|
||||||
e = self.mk_expr(lo.to(hi), index, ThinVec::new())
|
e = self.mk_expr(lo.to(hi), index, AttrVec::new())
|
||||||
}
|
}
|
||||||
_ => return Ok(e)
|
_ => return Ok(e)
|
||||||
}
|
}
|
||||||
@ -791,7 +787,7 @@ impl<'a> Parser<'a> {
|
|||||||
args.insert(0, self_arg);
|
args.insert(0, self_arg);
|
||||||
|
|
||||||
let span = lo.to(self.prev_span);
|
let span = lo.to(self.prev_span);
|
||||||
self.mk_expr(span, ExprKind::MethodCall(segment, args), ThinVec::new())
|
self.mk_expr(span, ExprKind::MethodCall(segment, args), AttrVec::new())
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// Field access `expr.f`
|
// Field access `expr.f`
|
||||||
@ -801,7 +797,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let span = lo.to(self.prev_span);
|
let span = lo.to(self.prev_span);
|
||||||
self.mk_expr(span, ExprKind::Field(self_arg, segment.ident), ThinVec::new())
|
self.mk_expr(span, ExprKind::Field(self_arg, segment.ident), AttrVec::new())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -820,7 +816,7 @@ impl<'a> Parser<'a> {
|
|||||||
//
|
//
|
||||||
// Therefore, prevent sub-parser from parsing
|
// Therefore, prevent sub-parser from parsing
|
||||||
// attributes by giving them a empty "already-parsed" list.
|
// attributes by giving them a empty "already-parsed" list.
|
||||||
let attrs = ThinVec::new();
|
let attrs = AttrVec::new();
|
||||||
|
|
||||||
// Note: when adding new syntax here, don't forget to adjust `TokenKind::can_begin_expr()`.
|
// Note: when adding new syntax here, don't forget to adjust `TokenKind::can_begin_expr()`.
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
@ -909,7 +905,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_lit_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_lit_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
match self.parse_opt_lit() {
|
match self.parse_opt_lit() {
|
||||||
Some(literal) => {
|
Some(literal) => {
|
||||||
@ -920,7 +916,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_tuple_parens_expr(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_tuple_parens_expr(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
let parse_leading_attr_expr = |p: &mut Self| {
|
let parse_leading_attr_expr = |p: &mut Self| {
|
||||||
@ -947,10 +943,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.maybe_recover_from_bad_qpath(expr, true)
|
self.maybe_recover_from_bad_qpath(expr, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_array_or_repeat_expr(
|
fn parse_array_or_repeat_expr(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
&mut self,
|
|
||||||
mut attrs: ThinVec<Attribute>,
|
|
||||||
) -> PResult<'a, P<Expr>> {
|
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
self.bump(); // `[`
|
self.bump(); // `[`
|
||||||
|
|
||||||
@ -990,7 +983,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.maybe_recover_from_bad_qpath(expr, true)
|
self.maybe_recover_from_bad_qpath(expr, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_path_start_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_path_start_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
let path = self.parse_path(PathStyle::Expr)?;
|
let path = self.parse_path(PathStyle::Expr)?;
|
||||||
|
|
||||||
@ -1017,11 +1010,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.maybe_recover_from_bad_qpath(expr, true)
|
self.maybe_recover_from_bad_qpath(expr, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_labeled_expr(
|
fn parse_labeled_expr(&mut self, label: Label, attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
&mut self,
|
|
||||||
label: Label,
|
|
||||||
attrs: ThinVec<Attribute>,
|
|
||||||
) -> PResult<'a, P<Expr>> {
|
|
||||||
let lo = label.ident.span;
|
let lo = label.ident.span;
|
||||||
self.expect(&token::Colon)?;
|
self.expect(&token::Colon)?;
|
||||||
if self.eat_keyword(kw::While) {
|
if self.eat_keyword(kw::While) {
|
||||||
@ -1046,7 +1035,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Recover on the syntax `do catch { ... }` suggesting `try { ... }` instead.
|
/// Recover on the syntax `do catch { ... }` suggesting `try { ... }` instead.
|
||||||
fn recover_do_catch(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn recover_do_catch(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
|
|
||||||
self.bump(); // `do`
|
self.bump(); // `do`
|
||||||
@ -1076,7 +1065,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse `"return" expr?`.
|
/// Parse `"return" expr?`.
|
||||||
fn parse_return_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_return_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let lo = self.prev_span;
|
let lo = self.prev_span;
|
||||||
let kind = ExprKind::Ret(self.parse_expr_opt()?);
|
let kind = ExprKind::Ret(self.parse_expr_opt()?);
|
||||||
let expr = self.mk_expr(lo.to(self.prev_span), kind, attrs);
|
let expr = self.mk_expr(lo.to(self.prev_span), kind, attrs);
|
||||||
@ -1084,7 +1073,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse `"('label ":")? break expr?`.
|
/// Parse `"('label ":")? break expr?`.
|
||||||
fn parse_break_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_break_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let lo = self.prev_span;
|
let lo = self.prev_span;
|
||||||
let label = self.eat_label();
|
let label = self.eat_label();
|
||||||
let kind = if self.token != token::OpenDelim(token::Brace)
|
let kind = if self.token != token::OpenDelim(token::Brace)
|
||||||
@ -1099,7 +1088,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse `"yield" expr?`.
|
/// Parse `"yield" expr?`.
|
||||||
fn parse_yield_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_yield_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let lo = self.prev_span;
|
let lo = self.prev_span;
|
||||||
let kind = ExprKind::Yield(self.parse_expr_opt()?);
|
let kind = ExprKind::Yield(self.parse_expr_opt()?);
|
||||||
let span = lo.to(self.prev_span);
|
let span = lo.to(self.prev_span);
|
||||||
@ -1307,12 +1296,12 @@ impl<'a> Parser<'a> {
|
|||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
let literal = self.parse_lit()?;
|
let literal = self.parse_lit()?;
|
||||||
let hi = self.prev_span;
|
let hi = self.prev_span;
|
||||||
let expr = self.mk_expr(lo.to(hi), ExprKind::Lit(literal), ThinVec::new());
|
let expr = self.mk_expr(lo.to(hi), ExprKind::Lit(literal), AttrVec::new());
|
||||||
|
|
||||||
if minus_present {
|
if minus_present {
|
||||||
let minus_hi = self.prev_span;
|
let minus_hi = self.prev_span;
|
||||||
let unary = self.mk_unary(UnOp::Neg, expr);
|
let unary = self.mk_unary(UnOp::Neg, expr);
|
||||||
Ok(self.mk_expr(minus_lo.to(minus_hi), unary, ThinVec::new()))
|
Ok(self.mk_expr(minus_lo.to(minus_hi), unary, AttrVec::new()))
|
||||||
} else {
|
} else {
|
||||||
Ok(expr)
|
Ok(expr)
|
||||||
}
|
}
|
||||||
@ -1324,7 +1313,7 @@ impl<'a> Parser<'a> {
|
|||||||
opt_label: Option<Label>,
|
opt_label: Option<Label>,
|
||||||
lo: Span,
|
lo: Span,
|
||||||
blk_mode: BlockCheckMode,
|
blk_mode: BlockCheckMode,
|
||||||
outer_attrs: ThinVec<Attribute>,
|
outer_attrs: AttrVec,
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
if let Some(label) = opt_label {
|
if let Some(label) = opt_label {
|
||||||
self.sess.gated_spans.gate(sym::label_break_value, label.ident.span);
|
self.sess.gated_spans.gate(sym::label_break_value, label.ident.span);
|
||||||
@ -1340,7 +1329,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parses a closure expression (e.g., `move |args| expr`).
|
/// Parses a closure expression (e.g., `move |args| expr`).
|
||||||
fn parse_closure_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_closure_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
|
|
||||||
let movability = if self.eat_keyword(kw::Static) {
|
let movability = if self.eat_keyword(kw::Static) {
|
||||||
@ -1370,7 +1359,7 @@ impl<'a> Parser<'a> {
|
|||||||
_ => {
|
_ => {
|
||||||
// If an explicit return type is given, require a block to appear (RFC 968).
|
// If an explicit return type is given, require a block to appear (RFC 968).
|
||||||
let body_lo = self.token.span;
|
let body_lo = self.token.span;
|
||||||
self.parse_block_expr(None, body_lo, BlockCheckMode::Default, ThinVec::new())?
|
self.parse_block_expr(None, body_lo, BlockCheckMode::Default, AttrVec::new())?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1440,7 +1429,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parses an `if` expression (`if` token already eaten).
|
/// Parses an `if` expression (`if` token already eaten).
|
||||||
fn parse_if_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_if_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let lo = self.prev_span;
|
let lo = self.prev_span;
|
||||||
let cond = self.parse_cond_expr()?;
|
let cond = self.parse_cond_expr()?;
|
||||||
|
|
||||||
@ -1486,7 +1475,7 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
/// Parses a `let $pat = $expr` pseudo-expression.
|
/// Parses a `let $pat = $expr` pseudo-expression.
|
||||||
/// The `let` token has already been eaten.
|
/// The `let` token has already been eaten.
|
||||||
fn parse_let_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_let_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let lo = self.prev_span;
|
let lo = self.prev_span;
|
||||||
let pat = self.parse_top_pat(GateOr::No)?;
|
let pat = self.parse_top_pat(GateOr::No)?;
|
||||||
self.expect(&token::Eq)?;
|
self.expect(&token::Eq)?;
|
||||||
@ -1502,10 +1491,10 @@ impl<'a> Parser<'a> {
|
|||||||
/// Parses an `else { ... }` expression (`else` token already eaten).
|
/// Parses an `else { ... }` expression (`else` token already eaten).
|
||||||
fn parse_else_expr(&mut self) -> PResult<'a, P<Expr>> {
|
fn parse_else_expr(&mut self) -> PResult<'a, P<Expr>> {
|
||||||
if self.eat_keyword(kw::If) {
|
if self.eat_keyword(kw::If) {
|
||||||
return self.parse_if_expr(ThinVec::new());
|
return self.parse_if_expr(AttrVec::new());
|
||||||
} else {
|
} else {
|
||||||
let blk = self.parse_block()?;
|
let blk = self.parse_block()?;
|
||||||
return Ok(self.mk_expr(blk.span, ExprKind::Block(blk, None), ThinVec::new()));
|
return Ok(self.mk_expr(blk.span, ExprKind::Block(blk, None), AttrVec::new()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1514,7 +1503,7 @@ impl<'a> Parser<'a> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
opt_label: Option<Label>,
|
opt_label: Option<Label>,
|
||||||
span_lo: Span,
|
span_lo: Span,
|
||||||
mut attrs: ThinVec<Attribute>
|
mut attrs: AttrVec
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
// Parse: `for <src_pat> in <src_expr> <src_loop_block>`
|
// Parse: `for <src_pat> in <src_expr> <src_loop_block>`
|
||||||
|
|
||||||
@ -1556,7 +1545,7 @@ impl<'a> Parser<'a> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
opt_label: Option<Label>,
|
opt_label: Option<Label>,
|
||||||
span_lo: Span,
|
span_lo: Span,
|
||||||
mut attrs: ThinVec<Attribute>
|
mut attrs: AttrVec
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
let cond = self.parse_cond_expr()?;
|
let cond = self.parse_cond_expr()?;
|
||||||
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
|
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
|
||||||
@ -1570,7 +1559,7 @@ impl<'a> Parser<'a> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
opt_label: Option<Label>,
|
opt_label: Option<Label>,
|
||||||
span_lo: Span,
|
span_lo: Span,
|
||||||
mut attrs: ThinVec<Attribute>
|
mut attrs: AttrVec
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
|
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
|
||||||
attrs.extend(iattrs);
|
attrs.extend(iattrs);
|
||||||
@ -1589,7 +1578,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parses a `match ... { ... }` expression (`match` token already eaten).
|
/// Parses a `match ... { ... }` expression (`match` token already eaten).
|
||||||
fn parse_match_expr(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_match_expr(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let match_span = self.prev_span;
|
let match_span = self.prev_span;
|
||||||
let lo = self.prev_span;
|
let lo = self.prev_span;
|
||||||
let discriminant = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?;
|
let discriminant = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?;
|
||||||
@ -1701,11 +1690,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parses a `try {...}` expression (`try` token already eaten).
|
/// Parses a `try {...}` expression (`try` token already eaten).
|
||||||
fn parse_try_block(
|
fn parse_try_block(&mut self, span_lo: Span, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
&mut self,
|
|
||||||
span_lo: Span,
|
|
||||||
mut attrs: ThinVec<Attribute>
|
|
||||||
) -> PResult<'a, P<Expr>> {
|
|
||||||
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
|
let (iattrs, body) = self.parse_inner_attrs_and_block()?;
|
||||||
attrs.extend(iattrs);
|
attrs.extend(iattrs);
|
||||||
if self.eat_keyword(kw::Catch) {
|
if self.eat_keyword(kw::Catch) {
|
||||||
@ -1737,7 +1722,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parses an `async move? {...}` expression.
|
/// Parses an `async move? {...}` expression.
|
||||||
fn parse_async_block(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
|
fn parse_async_block(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
|
||||||
let span_lo = self.token.span;
|
let span_lo = self.token.span;
|
||||||
self.expect_keyword(kw::Async)?;
|
self.expect_keyword(kw::Async)?;
|
||||||
let capture_clause = self.parse_capture_clause();
|
let capture_clause = self.parse_capture_clause();
|
||||||
@ -1764,7 +1749,7 @@ impl<'a> Parser<'a> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
lo: Span,
|
lo: Span,
|
||||||
path: &ast::Path,
|
path: &ast::Path,
|
||||||
attrs: &ThinVec<Attribute>,
|
attrs: &AttrVec,
|
||||||
) -> Option<PResult<'a, P<Expr>>> {
|
) -> Option<PResult<'a, P<Expr>>> {
|
||||||
let struct_allowed = !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL);
|
let struct_allowed = !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL);
|
||||||
let certainly_not_a_block = || self.look_ahead(1, |t| t.is_ident()) && (
|
let certainly_not_a_block = || self.look_ahead(1, |t| t.is_ident()) && (
|
||||||
@ -1805,7 +1790,7 @@ impl<'a> Parser<'a> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
lo: Span,
|
lo: Span,
|
||||||
pth: ast::Path,
|
pth: ast::Path,
|
||||||
mut attrs: ThinVec<Attribute>
|
mut attrs: AttrVec
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
let struct_sp = lo.to(self.prev_span);
|
let struct_sp = lo.to(self.prev_span);
|
||||||
self.bump();
|
self.bump();
|
||||||
@ -1851,9 +1836,9 @@ impl<'a> Parser<'a> {
|
|||||||
recovery_field = Some(ast::Field {
|
recovery_field = Some(ast::Field {
|
||||||
ident: Ident::new(name, self.token.span),
|
ident: Ident::new(name, self.token.span),
|
||||||
span: self.token.span,
|
span: self.token.span,
|
||||||
expr: self.mk_expr(self.token.span, ExprKind::Err, ThinVec::new()),
|
expr: self.mk_expr(self.token.span, ExprKind::Err, AttrVec::new()),
|
||||||
is_shorthand: false,
|
is_shorthand: false,
|
||||||
attrs: ThinVec::new(),
|
attrs: AttrVec::new(),
|
||||||
id: DUMMY_NODE_ID,
|
id: DUMMY_NODE_ID,
|
||||||
is_placeholder: false,
|
is_placeholder: false,
|
||||||
});
|
});
|
||||||
@ -1932,7 +1917,7 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
// Mimic `x: x` for the `x` field shorthand.
|
// Mimic `x: x` for the `x` field shorthand.
|
||||||
let path = ast::Path::from_ident(fieldname);
|
let path = ast::Path::from_ident(fieldname);
|
||||||
let expr = self.mk_expr(fieldname.span, ExprKind::Path(None, path), ThinVec::new());
|
let expr = self.mk_expr(fieldname.span, ExprKind::Path(None, path), AttrVec::new());
|
||||||
(fieldname, expr, true)
|
(fieldname, expr, true)
|
||||||
};
|
};
|
||||||
Ok(ast::Field {
|
Ok(ast::Field {
|
||||||
@ -2009,16 +1994,16 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
fn mk_await_expr(&mut self, self_arg: P<Expr>, lo: Span) -> PResult<'a, P<Expr>> {
|
fn mk_await_expr(&mut self, self_arg: P<Expr>, lo: Span) -> PResult<'a, P<Expr>> {
|
||||||
let span = lo.to(self.prev_span);
|
let span = lo.to(self.prev_span);
|
||||||
let await_expr = self.mk_expr(span, ExprKind::Await(self_arg), ThinVec::new());
|
let await_expr = self.mk_expr(span, ExprKind::Await(self_arg), AttrVec::new());
|
||||||
self.recover_from_await_method_call();
|
self.recover_from_await_method_call();
|
||||||
Ok(await_expr)
|
Ok(await_expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: ThinVec<Attribute>) -> P<Expr> {
|
crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: AttrVec) -> P<Expr> {
|
||||||
P(Expr { kind, span, attrs, id: DUMMY_NODE_ID })
|
P(Expr { kind, span, attrs, id: DUMMY_NODE_ID })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn mk_expr_err(&self, span: Span) -> P<Expr> {
|
pub(super) fn mk_expr_err(&self, span: Span) -> P<Expr> {
|
||||||
self.mk_expr(span, ExprKind::Err, ThinVec::new())
|
self.mk_expr(span, ExprKind::Err, AttrVec::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,14 @@ use crate::maybe_whole;
|
|||||||
|
|
||||||
use rustc_errors::{PResult, Applicability, DiagnosticBuilder, StashKey};
|
use rustc_errors::{PResult, Applicability, DiagnosticBuilder, StashKey};
|
||||||
use rustc_error_codes::*;
|
use rustc_error_codes::*;
|
||||||
use syntax::ast::{self, DUMMY_NODE_ID, Ident, Attribute, AttrKind, AttrStyle, AnonConst, Item};
|
use syntax::ast::{self, DUMMY_NODE_ID, Ident, AttrVec, Attribute, AttrKind, AttrStyle, AnonConst};
|
||||||
use syntax::ast::{AssocItem, AssocItemKind, ItemKind, UseTree, UseTreeKind};
|
use syntax::ast::{AssocItem, AssocItemKind, Item, ItemKind, UseTree, UseTreeKind};
|
||||||
use syntax::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness, Extern, StrLit};
|
use syntax::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness, Extern, StrLit};
|
||||||
use syntax::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind};
|
use syntax::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind};
|
||||||
use syntax::ast::{Ty, TyKind, Generics, TraitRef, EnumDef, Variant, VariantData, StructField};
|
use syntax::ast::{Ty, TyKind, Generics, TraitRef, EnumDef, Variant, VariantData, StructField};
|
||||||
use syntax::ast::{Mac, MacArgs, MacDelimiter, Block, BindingMode, FnDecl, FnSig, SelfKind, Param};
|
use syntax::ast::{Mac, MacArgs, MacDelimiter, Block, BindingMode, FnDecl, FnSig, SelfKind, Param};
|
||||||
use syntax::print::pprust;
|
use syntax::print::pprust;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::ThinVec;
|
|
||||||
use syntax::token;
|
use syntax::token;
|
||||||
use syntax::tokenstream::{DelimSpan, TokenTree, TokenStream};
|
use syntax::tokenstream::{DelimSpan, TokenTree, TokenStream};
|
||||||
use syntax::struct_span_err;
|
use syntax::struct_span_err;
|
||||||
@ -2095,7 +2094,7 @@ impl<'a> Parser<'a> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let eself = source_map::respan(eself_lo.to(eself_hi), eself);
|
let eself = source_map::respan(eself_lo.to(eself_hi), eself);
|
||||||
Ok(Some(Param::from_self(ThinVec::default(), eself, eself_ident)))
|
Ok(Some(Param::from_self(AttrVec::default(), eself, eself_ident)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_named_param(&self) -> bool {
|
fn is_named_param(&self) -> bool {
|
||||||
|
@ -15,9 +15,8 @@ use crate::{Directory, DirectoryOwnership};
|
|||||||
use crate::lexer::UnmatchedBrace;
|
use crate::lexer::UnmatchedBrace;
|
||||||
|
|
||||||
use rustc_errors::{PResult, Applicability, DiagnosticBuilder, FatalError};
|
use rustc_errors::{PResult, Applicability, DiagnosticBuilder, FatalError};
|
||||||
use rustc_data_structures::thin_vec::ThinVec;
|
use syntax::ast::{self, DUMMY_NODE_ID, AttrVec, AttrStyle, CrateSugar, Extern, Ident, Unsafety};
|
||||||
use syntax::ast::{self, DUMMY_NODE_ID, AttrStyle, Attribute, CrateSugar, Extern, Ident, StrLit};
|
use syntax::ast::{StrLit, IsAsync, MacArgs, MacDelimiter, Mutability, Visibility, VisibilityKind};
|
||||||
use syntax::ast::{IsAsync, MacArgs, MacDelimiter, Mutability, Visibility, VisibilityKind, Unsafety};
|
|
||||||
use syntax::print::pprust;
|
use syntax::print::pprust;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::token::{self, Token, TokenKind, DelimToken};
|
use syntax::token::{self, Token, TokenKind, DelimToken};
|
||||||
@ -1054,8 +1053,8 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
fn parse_or_use_outer_attributes(
|
fn parse_or_use_outer_attributes(
|
||||||
&mut self,
|
&mut self,
|
||||||
already_parsed_attrs: Option<ThinVec<Attribute>>,
|
already_parsed_attrs: Option<AttrVec>,
|
||||||
) -> PResult<'a, ThinVec<Attribute>> {
|
) -> PResult<'a, AttrVec> {
|
||||||
if let Some(attrs) = already_parsed_attrs {
|
if let Some(attrs) = already_parsed_attrs {
|
||||||
Ok(attrs)
|
Ok(attrs)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
use super::{Parser, PathStyle};
|
use super::{Parser, PathStyle};
|
||||||
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
|
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
|
||||||
use rustc_errors::{PResult, Applicability, DiagnosticBuilder};
|
use rustc_errors::{PResult, Applicability, DiagnosticBuilder};
|
||||||
use syntax::ast::{self, Attribute, Pat, PatKind, FieldPat, RangeEnd, RangeSyntax, Mac};
|
use syntax::ast::{self, AttrVec, Attribute, Pat, PatKind, FieldPat, RangeEnd, RangeSyntax, Mac};
|
||||||
use syntax::ast::{BindingMode, Ident, Mutability, Path, QSelf, Expr, ExprKind};
|
use syntax::ast::{BindingMode, Ident, Mutability, Path, QSelf, Expr, ExprKind};
|
||||||
use syntax::mut_visit::{noop_visit_pat, noop_visit_mac, MutVisitor};
|
use syntax::mut_visit::{noop_visit_pat, noop_visit_mac, MutVisitor};
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::print::pprust;
|
use syntax::print::pprust;
|
||||||
use syntax::ThinVec;
|
|
||||||
use syntax::token;
|
use syntax::token;
|
||||||
use syntax_pos::source_map::{respan, Span, Spanned};
|
use syntax_pos::source_map::{respan, Span, Spanned};
|
||||||
use syntax_pos::symbol::{kw, sym};
|
use syntax_pos::symbol::{kw, sym};
|
||||||
@ -636,7 +635,7 @@ impl<'a> Parser<'a> {
|
|||||||
let op_span = self.token.span;
|
let op_span = self.token.span;
|
||||||
// Parse range
|
// Parse range
|
||||||
let span = lo.to(self.prev_span);
|
let span = lo.to(self.prev_span);
|
||||||
let begin = self.mk_expr(span, ExprKind::Path(qself, path), ThinVec::new());
|
let begin = self.mk_expr(span, ExprKind::Path(qself, path), AttrVec::new());
|
||||||
self.bump();
|
self.bump();
|
||||||
let end = self.parse_pat_range_end_opt(&begin, form)?;
|
let end = self.parse_pat_range_end_opt(&begin, form)?;
|
||||||
Ok(PatKind::Range(begin, end, respan(op_span, end_kind)))
|
Ok(PatKind::Range(begin, end, respan(op_span, end_kind)))
|
||||||
@ -693,7 +692,7 @@ impl<'a> Parser<'a> {
|
|||||||
let lo = self.prev_span;
|
let lo = self.prev_span;
|
||||||
let end = self.parse_pat_range_end()?;
|
let end = self.parse_pat_range_end()?;
|
||||||
let range_span = lo.to(end.span);
|
let range_span = lo.to(end.span);
|
||||||
let begin = self.mk_expr(range_span, ExprKind::Err, ThinVec::new());
|
let begin = self.mk_expr(range_span, ExprKind::Err, AttrVec::new());
|
||||||
|
|
||||||
self.diagnostic()
|
self.diagnostic()
|
||||||
.struct_span_err(range_span, &format!("`{}X` range patterns are not supported", form))
|
.struct_span_err(range_span, &format!("`{}X` range patterns are not supported", form))
|
||||||
@ -731,7 +730,7 @@ impl<'a> Parser<'a> {
|
|||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
|
||||||
Ok(self.mk_expr(range_span, ExprKind::Err, ThinVec::new()))
|
Ok(self.mk_expr(range_span, ExprKind::Err, AttrVec::new()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,7 +746,7 @@ impl<'a> Parser<'a> {
|
|||||||
(None, self.parse_path(PathStyle::Expr)?)
|
(None, self.parse_path(PathStyle::Expr)?)
|
||||||
};
|
};
|
||||||
let hi = self.prev_span;
|
let hi = self.prev_span;
|
||||||
Ok(self.mk_expr(lo.to(hi), ExprKind::Path(qself, path), ThinVec::new()))
|
Ok(self.mk_expr(lo.to(hi), ExprKind::Path(qself, path), AttrVec::new()))
|
||||||
} else {
|
} else {
|
||||||
self.parse_literal_maybe_minus()
|
self.parse_literal_maybe_minus()
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ use crate::maybe_whole;
|
|||||||
use rustc_errors::{PResult, Applicability, pluralize};
|
use rustc_errors::{PResult, Applicability, pluralize};
|
||||||
use syntax::ast::{self, QSelf, Path, PathSegment, Ident, ParenthesizedArgs, AngleBracketedArgs};
|
use syntax::ast::{self, QSelf, Path, PathSegment, Ident, ParenthesizedArgs, AngleBracketedArgs};
|
||||||
use syntax::ast::{AnonConst, GenericArg, AssocTyConstraint, AssocTyConstraintKind, BlockCheckMode};
|
use syntax::ast::{AnonConst, GenericArg, AssocTyConstraint, AssocTyConstraintKind, BlockCheckMode};
|
||||||
use syntax::ThinVec;
|
|
||||||
use syntax::token::{self, Token};
|
use syntax::token::{self, Token};
|
||||||
use syntax_pos::source_map::{Span, BytePos};
|
use syntax_pos::source_map::{Span, BytePos};
|
||||||
use syntax_pos::symbol::{kw, sym};
|
use syntax_pos::symbol::{kw, sym};
|
||||||
@ -400,7 +399,7 @@ impl<'a> Parser<'a> {
|
|||||||
// Parse const argument.
|
// Parse const argument.
|
||||||
let expr = if let token::OpenDelim(token::Brace) = self.token.kind {
|
let expr = if let token::OpenDelim(token::Brace) = self.token.kind {
|
||||||
self.parse_block_expr(
|
self.parse_block_expr(
|
||||||
None, self.token.span, BlockCheckMode::Default, ThinVec::new()
|
None, self.token.span, BlockCheckMode::Default, ast::AttrVec::new()
|
||||||
)?
|
)?
|
||||||
} else if self.token.is_ident() {
|
} else if self.token.is_ident() {
|
||||||
// FIXME(const_generics): to distinguish between idents for types and consts,
|
// FIXME(const_generics): to distinguish between idents for types and consts,
|
||||||
|
@ -7,11 +7,10 @@ use crate::maybe_whole;
|
|||||||
use crate::DirectoryOwnership;
|
use crate::DirectoryOwnership;
|
||||||
|
|
||||||
use rustc_errors::{PResult, Applicability};
|
use rustc_errors::{PResult, Applicability};
|
||||||
use syntax::ThinVec;
|
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast::{DUMMY_NODE_ID, Stmt, StmtKind, Local, Block, BlockCheckMode, Expr, ExprKind};
|
use syntax::ast::{DUMMY_NODE_ID, Stmt, StmtKind, Local, Block, BlockCheckMode, Expr, ExprKind};
|
||||||
use syntax::ast::{Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac};
|
use syntax::ast::{AttrVec, Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac};
|
||||||
use syntax::util::classify;
|
use syntax::util::classify;
|
||||||
use syntax::token;
|
use syntax::token;
|
||||||
use syntax_pos::source_map::{respan, Span};
|
use syntax_pos::source_map::{respan, Span};
|
||||||
@ -67,10 +66,10 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let expr = if self.check(&token::OpenDelim(token::Brace)) {
|
let expr = if self.check(&token::OpenDelim(token::Brace)) {
|
||||||
self.parse_struct_expr(lo, path, ThinVec::new())?
|
self.parse_struct_expr(lo, path, AttrVec::new())?
|
||||||
} else {
|
} else {
|
||||||
let hi = self.prev_span;
|
let hi = self.prev_span;
|
||||||
self.mk_expr(lo.to(hi), ExprKind::Path(None, path), ThinVec::new())
|
self.mk_expr(lo.to(hi), ExprKind::Path(None, path), AttrVec::new())
|
||||||
};
|
};
|
||||||
|
|
||||||
let expr = self.with_res(Restrictions::STMT_EXPR, |this| {
|
let expr = self.with_res(Restrictions::STMT_EXPR, |this| {
|
||||||
@ -104,7 +103,7 @@ impl<'a> Parser<'a> {
|
|||||||
let kind = StmtKind::Semi(self.mk_expr(
|
let kind = StmtKind::Semi(self.mk_expr(
|
||||||
lo.to(last_semi),
|
lo.to(last_semi),
|
||||||
ExprKind::Tup(Vec::new()),
|
ExprKind::Tup(Vec::new()),
|
||||||
ThinVec::new()
|
AttrVec::new()
|
||||||
));
|
));
|
||||||
return Ok(Some(self.mk_stmt(lo.to(last_semi), kind)));
|
return Ok(Some(self.mk_stmt(lo.to(last_semi), kind)));
|
||||||
}
|
}
|
||||||
@ -124,7 +123,7 @@ impl<'a> Parser<'a> {
|
|||||||
fn parse_stmt_mac(
|
fn parse_stmt_mac(
|
||||||
&mut self,
|
&mut self,
|
||||||
lo: Span,
|
lo: Span,
|
||||||
attrs: ThinVec<Attribute>,
|
attrs: AttrVec,
|
||||||
path: ast::Path,
|
path: ast::Path,
|
||||||
legacy_warnings: bool,
|
legacy_warnings: bool,
|
||||||
) -> PResult<'a, Option<Stmt>> {
|
) -> PResult<'a, Option<Stmt>> {
|
||||||
@ -169,7 +168,7 @@ impl<'a> Parser<'a> {
|
|||||||
StmtKind::Mac(P((mac, style, attrs)))
|
StmtKind::Mac(P((mac, style, attrs)))
|
||||||
} else {
|
} else {
|
||||||
// Since none of the above applied, this is an expression statement macro.
|
// Since none of the above applied, this is an expression statement macro.
|
||||||
let e = self.mk_expr(lo.to(hi), ExprKind::Mac(mac), ThinVec::new());
|
let e = self.mk_expr(lo.to(hi), ExprKind::Mac(mac), AttrVec::new());
|
||||||
let e = self.maybe_recover_from_bad_qpath(e, true)?;
|
let e = self.maybe_recover_from_bad_qpath(e, true)?;
|
||||||
let e = self.parse_dot_or_call_expr_with(e, lo, attrs)?;
|
let e = self.parse_dot_or_call_expr_with(e, lo, attrs)?;
|
||||||
let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?;
|
let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?;
|
||||||
@ -191,7 +190,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parses a local variable declaration.
|
/// Parses a local variable declaration.
|
||||||
fn parse_local(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Local>> {
|
fn parse_local(&mut self, attrs: AttrVec) -> PResult<'a, P<Local>> {
|
||||||
let lo = self.prev_span;
|
let lo = self.prev_span;
|
||||||
let pat = self.parse_top_pat(GateOr::Yes)?;
|
let pat = self.parse_top_pat(GateOr::Yes)?;
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ pub enum GenericParamKind {
|
|||||||
pub struct GenericParam {
|
pub struct GenericParam {
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub ident: Ident,
|
pub ident: Ident,
|
||||||
pub attrs: ThinVec<Attribute>,
|
pub attrs: AttrVec,
|
||||||
pub bounds: GenericBounds,
|
pub bounds: GenericBounds,
|
||||||
pub is_placeholder: bool,
|
pub is_placeholder: bool,
|
||||||
pub kind: GenericParamKind,
|
pub kind: GenericParamKind,
|
||||||
@ -599,7 +599,7 @@ pub struct FieldPat {
|
|||||||
/// The pattern the field is destructured to
|
/// The pattern the field is destructured to
|
||||||
pub pat: P<Pat>,
|
pub pat: P<Pat>,
|
||||||
pub is_shorthand: bool,
|
pub is_shorthand: bool,
|
||||||
pub attrs: ThinVec<Attribute>,
|
pub attrs: AttrVec,
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub is_placeholder: bool,
|
pub is_placeholder: bool,
|
||||||
@ -911,7 +911,7 @@ pub enum StmtKind {
|
|||||||
/// Expr with a trailing semi-colon.
|
/// Expr with a trailing semi-colon.
|
||||||
Semi(P<Expr>),
|
Semi(P<Expr>),
|
||||||
/// Macro.
|
/// Macro.
|
||||||
Mac(P<(Mac, MacStmtStyle, ThinVec<Attribute>)>),
|
Mac(P<(Mac, MacStmtStyle, AttrVec)>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)]
|
||||||
@ -936,7 +936,7 @@ pub struct Local {
|
|||||||
/// Initializer expression to set the value, if any.
|
/// Initializer expression to set the value, if any.
|
||||||
pub init: Option<P<Expr>>,
|
pub init: Option<P<Expr>>,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub attrs: ThinVec<Attribute>,
|
pub attrs: AttrVec,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An arm of a 'match'.
|
/// An arm of a 'match'.
|
||||||
@ -966,7 +966,7 @@ pub struct Arm {
|
|||||||
/// Access of a named (e.g., `obj.foo`) or unnamed (e.g., `obj.0`) struct field.
|
/// Access of a named (e.g., `obj.foo`) or unnamed (e.g., `obj.0`) struct field.
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub struct Field {
|
pub struct Field {
|
||||||
pub attrs: ThinVec<Attribute>,
|
pub attrs: AttrVec,
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub ident: Ident,
|
pub ident: Ident,
|
||||||
@ -1004,7 +1004,7 @@ pub struct Expr {
|
|||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub kind: ExprKind,
|
pub kind: ExprKind,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub attrs: ThinVec<Attribute>,
|
pub attrs: AttrVec,
|
||||||
}
|
}
|
||||||
|
|
||||||
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
|
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||||
@ -1961,7 +1961,7 @@ pub struct InlineAsm {
|
|||||||
/// E.g., `bar: usize` as in `fn foo(bar: usize)`.
|
/// E.g., `bar: usize` as in `fn foo(bar: usize)`.
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub struct Param {
|
pub struct Param {
|
||||||
pub attrs: ThinVec<Attribute>,
|
pub attrs: AttrVec,
|
||||||
pub ty: P<Ty>,
|
pub ty: P<Ty>,
|
||||||
pub pat: P<Pat>,
|
pub pat: P<Pat>,
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
@ -2014,7 +2014,7 @@ impl Param {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a `Param` object from `ExplicitSelf`.
|
/// Builds a `Param` object from `ExplicitSelf`.
|
||||||
pub fn from_self(attrs: ThinVec<Attribute>, eself: ExplicitSelf, eself_ident: Ident) -> Param {
|
pub fn from_self(attrs: AttrVec, eself: ExplicitSelf, eself_ident: Ident) -> Param {
|
||||||
let span = eself.span.to(eself_ident.span);
|
let span = eself.span.to(eself_ident.span);
|
||||||
let infer_ty = P(Ty {
|
let infer_ty = P(Ty {
|
||||||
id: DUMMY_NODE_ID,
|
id: DUMMY_NODE_ID,
|
||||||
@ -2332,6 +2332,9 @@ pub struct AttrItem {
|
|||||||
pub args: MacArgs,
|
pub args: MacArgs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A list of attributes.
|
||||||
|
pub type AttrVec = ThinVec<Attribute>;
|
||||||
|
|
||||||
/// Metadata associated with an item.
|
/// Metadata associated with an item.
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub struct Attribute {
|
pub struct Attribute {
|
||||||
|
@ -9,7 +9,7 @@ pub use StabilityLevel::*;
|
|||||||
pub use crate::ast::Attribute;
|
pub use crate::ast::Attribute;
|
||||||
|
|
||||||
use crate::ast;
|
use crate::ast;
|
||||||
use crate::ast::{AttrItem, AttrId, AttrKind, AttrStyle, Name, Ident, Path, PathSegment};
|
use crate::ast::{AttrVec, AttrItem, AttrId, AttrKind, AttrStyle, Name, Ident, Path, PathSegment};
|
||||||
use crate::ast::{MacArgs, MacDelimiter, MetaItem, MetaItemKind, NestedMetaItem};
|
use crate::ast::{MacArgs, MacDelimiter, MetaItem, MetaItemKind, NestedMetaItem};
|
||||||
use crate::ast::{Lit, LitKind, Expr, Item, Local, Stmt, StmtKind, GenericParam};
|
use crate::ast::{Lit, LitKind, Expr, Item, Local, Stmt, StmtKind, GenericParam};
|
||||||
use crate::mut_visit::visit_clobber;
|
use crate::mut_visit::visit_clobber;
|
||||||
@ -17,7 +17,6 @@ use crate::source_map::{BytePos, Spanned};
|
|||||||
use crate::token::{self, Token};
|
use crate::token::{self, Token};
|
||||||
use crate::ptr::P;
|
use crate::ptr::P;
|
||||||
use crate::symbol::{sym, Symbol};
|
use crate::symbol::{sym, Symbol};
|
||||||
use crate::ThinVec;
|
|
||||||
use crate::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint};
|
use crate::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint};
|
||||||
use crate::GLOBALS;
|
use crate::GLOBALS;
|
||||||
|
|
||||||
@ -665,7 +664,7 @@ impl HasAttrs for Vec<Attribute> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasAttrs for ThinVec<Attribute> {
|
impl HasAttrs for AttrVec {
|
||||||
fn attrs(&self) -> &[Attribute] {
|
fn attrs(&self) -> &[Attribute] {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
pub use errors;
|
pub use errors;
|
||||||
use rustc_data_structures::sync::Lock;
|
use rustc_data_structures::sync::Lock;
|
||||||
use rustc_index::bit_set::GrowableBitSet;
|
use rustc_index::bit_set::GrowableBitSet;
|
||||||
pub use rustc_data_structures::thin_vec::ThinVec;
|
|
||||||
use ast::AttrId;
|
use ast::AttrId;
|
||||||
use syntax_pos::edition::Edition;
|
use syntax_pos::edition::Edition;
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ use crate::ast::*;
|
|||||||
use crate::source_map::{Spanned, respan};
|
use crate::source_map::{Spanned, respan};
|
||||||
use crate::token::{self, Token};
|
use crate::token::{self, Token};
|
||||||
use crate::ptr::P;
|
use crate::ptr::P;
|
||||||
use crate::ThinVec;
|
|
||||||
use crate::tokenstream::*;
|
use crate::tokenstream::*;
|
||||||
use crate::util::map_in_place::MapInPlace;
|
use crate::util::map_in_place::MapInPlace;
|
||||||
|
|
||||||
@ -337,7 +336,7 @@ pub fn visit_attrs<T: MutVisitor>(attrs: &mut Vec<Attribute>, vis: &mut T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
|
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
|
||||||
pub fn visit_thin_attrs<T: MutVisitor>(attrs: &mut ThinVec<Attribute>, vis: &mut T) {
|
pub fn visit_thin_attrs<T: MutVisitor>(attrs: &mut AttrVec, vis: &mut T) {
|
||||||
for attr in attrs.iter_mut() {
|
for attr in attrs.iter_mut() {
|
||||||
vis.visit_attribute(attr);
|
vis.visit_attribute(attr);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ use syntax::mut_visit::{self, MutVisitor};
|
|||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::sess::ParseSess;
|
use syntax::sess::ParseSess;
|
||||||
use syntax::symbol::{kw, sym, Ident, Symbol};
|
use syntax::symbol::{kw, sym, Ident, Symbol};
|
||||||
use syntax::ThinVec;
|
|
||||||
use syntax::token;
|
use syntax::token;
|
||||||
use syntax::tokenstream::{self, TokenStream};
|
use syntax::tokenstream::{self, TokenStream};
|
||||||
use syntax::visit::Visitor;
|
use syntax::visit::Visitor;
|
||||||
@ -552,7 +551,7 @@ impl DummyResult {
|
|||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
kind: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(Vec::new()) },
|
kind: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(Vec::new()) },
|
||||||
span: sp,
|
span: sp,
|
||||||
attrs: ThinVec::new(),
|
attrs: ast::AttrVec::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
use crate::base::ExtCtxt;
|
use crate::base::ExtCtxt;
|
||||||
|
|
||||||
use syntax::ast::{self, Ident, Expr, BlockCheckMode, UnOp, PatKind};
|
use syntax::ast::{self, AttrVec, Ident, Expr, BlockCheckMode, UnOp, PatKind};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::source_map::{respan, Spanned};
|
use syntax::source_map::{respan, Spanned};
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::symbol::{kw, sym, Symbol};
|
use syntax::symbol::{kw, sym, Symbol};
|
||||||
use syntax::ThinVec;
|
|
||||||
|
|
||||||
use syntax_pos::{Pos, Span};
|
use syntax_pos::{Pos, Span};
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ impl<'a> ExtCtxt<'a> {
|
|||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
kind,
|
kind,
|
||||||
span,
|
span,
|
||||||
attrs: ThinVec::new(),
|
attrs: AttrVec::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,7 +189,7 @@ impl<'a> ExtCtxt<'a> {
|
|||||||
init: Some(ex),
|
init: Some(ex),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
span: sp,
|
span: sp,
|
||||||
attrs: ThinVec::new(),
|
attrs: AttrVec::new(),
|
||||||
});
|
});
|
||||||
ast::Stmt {
|
ast::Stmt {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
@ -207,7 +206,7 @@ impl<'a> ExtCtxt<'a> {
|
|||||||
init: None,
|
init: None,
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
span,
|
span,
|
||||||
attrs: ThinVec::new(),
|
attrs: AttrVec::new(),
|
||||||
});
|
});
|
||||||
ast::Stmt {
|
ast::Stmt {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
@ -245,7 +244,7 @@ impl<'a> ExtCtxt<'a> {
|
|||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
kind,
|
kind,
|
||||||
span,
|
span,
|
||||||
attrs: ThinVec::new(),
|
attrs: AttrVec::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +303,7 @@ impl<'a> ExtCtxt<'a> {
|
|||||||
expr: e,
|
expr: e,
|
||||||
span,
|
span,
|
||||||
is_shorthand: false,
|
is_shorthand: false,
|
||||||
attrs: ThinVec::new(),
|
attrs: AttrVec::new(),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
is_placeholder: false,
|
is_placeholder: false,
|
||||||
}
|
}
|
||||||
@ -549,7 +548,7 @@ impl<'a> ExtCtxt<'a> {
|
|||||||
pub fn param(&self, span: Span, ident: ast::Ident, ty: P<ast::Ty>) -> ast::Param {
|
pub fn param(&self, span: Span, ident: ast::Ident, ty: P<ast::Ty>) -> ast::Param {
|
||||||
let arg_pat = self.pat_ident(span, ident);
|
let arg_pat = self.pat_ident(span, ident);
|
||||||
ast::Param {
|
ast::Param {
|
||||||
attrs: ThinVec::default(),
|
attrs: AttrVec::default(),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
pat: arg_pat,
|
pat: arg_pat,
|
||||||
span,
|
span,
|
||||||
|
@ -5,7 +5,6 @@ use syntax::ast;
|
|||||||
use syntax::source_map::{DUMMY_SP, dummy_spanned};
|
use syntax::source_map::{DUMMY_SP, dummy_spanned};
|
||||||
use syntax::mut_visit::*;
|
use syntax::mut_visit::*;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::ThinVec;
|
|
||||||
|
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId, vis: Option<ast::Visi
|
|||||||
let span = DUMMY_SP;
|
let span = DUMMY_SP;
|
||||||
let expr_placeholder = || P(ast::Expr {
|
let expr_placeholder = || P(ast::Expr {
|
||||||
id, span,
|
id, span,
|
||||||
attrs: ThinVec::new(),
|
attrs: ast::AttrVec::new(),
|
||||||
kind: ast::ExprKind::Mac(mac_placeholder()),
|
kind: ast::ExprKind::Mac(mac_placeholder()),
|
||||||
});
|
});
|
||||||
let ty = || P(ast::Ty {
|
let ty = || P(ast::Ty {
|
||||||
@ -75,7 +74,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId, vis: Option<ast::Visi
|
|||||||
id, span, kind: ast::TyKind::Mac(mac_placeholder()),
|
id, span, kind: ast::TyKind::Mac(mac_placeholder()),
|
||||||
})),
|
})),
|
||||||
AstFragmentKind::Stmts => AstFragment::Stmts(smallvec![{
|
AstFragmentKind::Stmts => AstFragment::Stmts(smallvec![{
|
||||||
let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ThinVec::new()));
|
let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ast::AttrVec::new()));
|
||||||
ast::Stmt { id, span, kind: ast::StmtKind::Mac(mac) }
|
ast::Stmt { id, span, kind: ast::StmtKind::Mac(mac) }
|
||||||
}]),
|
}]),
|
||||||
AstFragmentKind::Arms => AstFragment::Arms(smallvec![
|
AstFragmentKind::Arms => AstFragment::Arms(smallvec![
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
use State::*;
|
use State::*;
|
||||||
|
|
||||||
use errors::{DiagnosticBuilder, PResult};
|
use errors::{DiagnosticBuilder, PResult};
|
||||||
use rustc_data_structures::thin_vec::ThinVec;
|
|
||||||
use rustc_parse::parser::Parser;
|
use rustc_parse::parser::Parser;
|
||||||
use syntax_expand::base::*;
|
use syntax_expand::base::*;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
@ -63,7 +62,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt<'_>,
|
|||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
kind: ast::ExprKind::InlineAsm(P(inline_asm)),
|
kind: ast::ExprKind::InlineAsm(P(inline_asm)),
|
||||||
span: cx.with_def_site_ctxt(sp),
|
span: cx.with_def_site_ctxt(sp),
|
||||||
attrs: ThinVec::new(),
|
attrs: ast::AttrVec::new(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use rustc_data_structures::thin_vec::ThinVec;
|
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax_expand::base::{self, *};
|
use syntax_expand::base::{self, *};
|
||||||
use syntax::token::{self, Token};
|
use syntax::token::{self, Token};
|
||||||
@ -49,7 +47,7 @@ pub fn expand_concat_idents<'cx>(cx: &'cx mut ExtCtxt<'_>,
|
|||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
kind: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)),
|
kind: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)),
|
||||||
span: self.ident.span,
|
span: self.ident.span,
|
||||||
attrs: ThinVec::new(),
|
attrs: ast::AttrVec::new(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@ use crate::deriving::path_std;
|
|||||||
use crate::deriving::generic::*;
|
use crate::deriving::generic::*;
|
||||||
use crate::deriving::generic::ty::*;
|
use crate::deriving::generic::ty::*;
|
||||||
|
|
||||||
use rustc_data_structures::thin_vec::ThinVec;
|
|
||||||
|
|
||||||
use syntax::ast::{self, Ident};
|
use syntax::ast::{self, Ident};
|
||||||
use syntax::ast::{Expr, MetaItem};
|
use syntax::ast::{Expr, MetaItem};
|
||||||
use syntax_expand::base::{Annotatable, ExtCtxt};
|
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),
|
init: Some(expr),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
span: sp,
|
span: sp,
|
||||||
attrs: ThinVec::new(),
|
attrs: ast::AttrVec::new(),
|
||||||
});
|
});
|
||||||
ast::Stmt {
|
ast::Stmt {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
|
@ -181,7 +181,6 @@ use std::cell::RefCell;
|
|||||||
use std::iter;
|
use std::iter;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
|
|
||||||
use rustc_data_structures::thin_vec::ThinVec;
|
|
||||||
use syntax::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind};
|
use syntax::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind};
|
||||||
use syntax::ast::{VariantData, GenericParamKind, GenericArg};
|
use syntax::ast::{VariantData, GenericParamKind, GenericArg};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
@ -919,7 +918,7 @@ impl<'a> MethodDef<'a> {
|
|||||||
let args = {
|
let args = {
|
||||||
let self_args = explicit_self.map(|explicit_self| {
|
let self_args = explicit_self.map(|explicit_self| {
|
||||||
let ident = Ident::with_dummy_span(kw::SelfLower).with_span_pos(trait_.span);
|
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()
|
let nonself_args = arg_types.into_iter()
|
||||||
.map(|(name, ty)| cx.param(trait_.span, name, ty));
|
.map(|(name, ty)| cx.param(trait_.span, name, ty));
|
||||||
@ -1608,7 +1607,7 @@ impl<'a> TraitDef<'a> {
|
|||||||
ast::FieldPat {
|
ast::FieldPat {
|
||||||
ident: ident.unwrap(),
|
ident: ident.unwrap(),
|
||||||
is_shorthand: false,
|
is_shorthand: false,
|
||||||
attrs: ThinVec::new(),
|
attrs: ast::AttrVec::new(),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
span: pat.span.with_ctxt(self.span.ctxt()),
|
span: pat.span.with_ctxt(self.span.ctxt()),
|
||||||
pat,
|
pat,
|
||||||
|
Loading…
Reference in New Issue
Block a user