mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Rename some ExtCtxt
methods.
The new names are more accurate. Co-authored-by: Scott McMurray <scottmcm@users.noreply.github.com>
This commit is contained in:
parent
dc80ca78b6
commit
7586e79af8
@ -162,14 +162,13 @@ fn decodable_substructure(
|
||||
cx.expr_match(trait_span, cx.expr_ident(trait_span, variant), arms),
|
||||
);
|
||||
let lambda = cx.lambda(trait_span, vec![blkarg, variant], result);
|
||||
let variant_vec = cx.expr_vec(trait_span, variants);
|
||||
let variant_vec = cx.expr_addr_of(trait_span, variant_vec);
|
||||
let variant_array_ref = cx.expr_array_ref(trait_span, variants);
|
||||
let fn_read_enum_variant_path: Vec<_> =
|
||||
cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_enum_variant]);
|
||||
let result = cx.expr_call_global(
|
||||
trait_span,
|
||||
fn_read_enum_variant_path,
|
||||
vec![blkdecoder, variant_vec, lambda],
|
||||
vec![blkdecoder, variant_array_ref, lambda],
|
||||
);
|
||||
let fn_read_enum_path: Vec<_> =
|
||||
cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_enum]);
|
||||
|
@ -776,7 +776,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||
|
||||
// First, build up the static array which will become our precompiled
|
||||
// format "string"
|
||||
let pieces = self.ecx.expr_vec_slice(self.fmtsp, self.str_pieces);
|
||||
let pieces = self.ecx.expr_array_ref(self.fmtsp, self.str_pieces);
|
||||
|
||||
// We need to construct a &[ArgumentV1] to pass into the fmt::Arguments
|
||||
// constructor. In general the expressions in this slice might be
|
||||
@ -849,7 +849,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||
fmt_args.push(Context::format_arg(self.ecx, self.macsp, span, arg_ty, arg));
|
||||
}
|
||||
|
||||
let args_array = self.ecx.expr_vec(self.macsp, fmt_args);
|
||||
let args_array = self.ecx.expr_array(self.macsp, fmt_args);
|
||||
let args_slice = self.ecx.expr_addr_of(
|
||||
self.macsp,
|
||||
if no_need_for_match {
|
||||
@ -879,7 +879,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||
} else {
|
||||
// Build up the static array which will store our precompiled
|
||||
// nonstandard placeholders, if there are any.
|
||||
let fmt = self.ecx.expr_vec_slice(self.macsp, self.pieces);
|
||||
let fmt = self.ecx.expr_array_ref(self.macsp, self.pieces);
|
||||
|
||||
let path = self.ecx.std_path(&[sym::fmt, sym::UnsafeArg, sym::new]);
|
||||
let unsafe_arg = self.ecx.expr_call_global(self.macsp, path, Vec::new());
|
||||
|
@ -317,7 +317,7 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
|
||||
proc_macro_ty_method_path(cx, custom_derive),
|
||||
vec![
|
||||
cx.expr_str(span, cd.trait_name),
|
||||
cx.expr_vec_slice(
|
||||
cx.expr_array_ref(
|
||||
span,
|
||||
cd.attrs.iter().map(|&s| cx.expr_str(span, s)).collect::<Vec<_>>(),
|
||||
),
|
||||
@ -362,7 +362,7 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
|
||||
ast::Mutability::Not,
|
||||
),
|
||||
ast::Mutability::Not,
|
||||
cx.expr_vec_slice(span, decls),
|
||||
cx.expr_array_ref(span, decls),
|
||||
)
|
||||
.map(|mut i| {
|
||||
let attr = cx.meta_word(span, sym::rustc_proc_macro_decls);
|
||||
|
@ -351,7 +351,7 @@ fn mk_tests_slice(cx: &TestCtxt<'_>, sp: Span) -> P<ast::Expr> {
|
||||
debug!("building test vector from {} tests", cx.test_cases.len());
|
||||
let ecx = &cx.ext_cx;
|
||||
|
||||
ecx.expr_vec_slice(
|
||||
ecx.expr_array_ref(
|
||||
sp,
|
||||
cx.test_cases
|
||||
.iter()
|
||||
|
@ -315,12 +315,16 @@ impl<'a> ExtCtxt<'a> {
|
||||
self.expr_lit(sp, ast::LitKind::Bool(value))
|
||||
}
|
||||
|
||||
pub fn expr_vec(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
|
||||
/// `[expr1, expr2, ...]`
|
||||
pub fn expr_array(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprKind::Array(exprs))
|
||||
}
|
||||
pub fn expr_vec_slice(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
|
||||
self.expr_addr_of(sp, self.expr_vec(sp, exprs))
|
||||
|
||||
/// `&[expr1, expr2, ...]`
|
||||
pub fn expr_array_ref(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
|
||||
self.expr_addr_of(sp, self.expr_array(sp, exprs))
|
||||
}
|
||||
|
||||
pub fn expr_str(&self, sp: Span, s: Symbol) -> P<ast::Expr> {
|
||||
self.expr_lit(sp, ast::LitKind::Str(s, ast::StrStyle::Cooked))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user