use crate::base::ExtCtxt;
-
use rustc_ast::attr;
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, AttrVec, BlockCheckMode, Expr, LocalKind, PatKind, UnOp};
use rustc_data_structures::sync::Lrc;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
-
use rustc_span::Span;
+use thin_vec::ThinVec;
impl<'a> ExtCtxt<'a> {
pub fn path(&self, span: Span, strs: Vec<Ident>) -> ast::Path {
) -> ast::Path {
assert!(!idents.is_empty());
let add_root = global && !idents[0].is_path_segment_keyword();
- let mut segments = Vec::with_capacity(idents.len() + add_root as usize);
+ let mut segments = ThinVec::with_capacity(idents.len() + add_root as usize);
if add_root {
segments.push(ast::PathSegment::path_root(span));
}
self.expr_ident(span, Ident::with_dummy_span(kw::SelfLower))
}
+ pub fn expr_field(&self, span: Span, expr: P<Expr>, field: Ident) -> P<ast::Expr> {
+ self.expr(span, ast::ExprKind::Field(expr, field))
+ }
+
pub fn expr_binary(
&self,
sp: Span,
}
fn expr_lit(&self, span: Span, lit_kind: ast::LitKind) -> P<ast::Expr> {
- let lit = ast::Lit::from_lit_kind(lit_kind, span);
- self.expr(span, ast::ExprKind::Lit(lit))
+ let token_lit = lit_kind.to_token_lit();
+ self.expr(span, ast::ExprKind::Lit(token_lit))
}
pub fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> {
// here, but that's not entirely clear.
self.expr(
span,
- ast::ExprKind::Closure(
- ast::ClosureBinder::NotPresent,
- ast::CaptureBy::Ref,
- ast::Async::No,
- ast::Movability::Movable,
+ ast::ExprKind::Closure(Box::new(ast::Closure {
+ binder: ast::ClosureBinder::NotPresent,
+ capture_clause: ast::CaptureBy::Ref,
+ asyncness: ast::Async::No,
+ movability: ast::Movability::Movable,
fn_decl,
body,
- span,
- ),
+ fn_decl_span: span,
+ })),
)
}