Skip to content

Commit 7586e79

Browse files
nnethercotescottmcm
andcommitted
Rename some ExtCtxt methods.
The new names are more accurate. Co-authored-by: Scott McMurray <[email protected]>
1 parent dc80ca7 commit 7586e79

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

compiler/rustc_builtin_macros/src/deriving/decodable.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,13 @@ fn decodable_substructure(
162162
cx.expr_match(trait_span, cx.expr_ident(trait_span, variant), arms),
163163
);
164164
let lambda = cx.lambda(trait_span, vec![blkarg, variant], result);
165-
let variant_vec = cx.expr_vec(trait_span, variants);
166-
let variant_vec = cx.expr_addr_of(trait_span, variant_vec);
165+
let variant_array_ref = cx.expr_array_ref(trait_span, variants);
167166
let fn_read_enum_variant_path: Vec<_> =
168167
cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_enum_variant]);
169168
let result = cx.expr_call_global(
170169
trait_span,
171170
fn_read_enum_variant_path,
172-
vec![blkdecoder, variant_vec, lambda],
171+
vec![blkdecoder, variant_array_ref, lambda],
173172
);
174173
let fn_read_enum_path: Vec<_> =
175174
cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_enum]);

compiler/rustc_builtin_macros/src/format.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ impl<'a, 'b> Context<'a, 'b> {
776776

777777
// First, build up the static array which will become our precompiled
778778
// format "string"
779-
let pieces = self.ecx.expr_vec_slice(self.fmtsp, self.str_pieces);
779+
let pieces = self.ecx.expr_array_ref(self.fmtsp, self.str_pieces);
780780

781781
// We need to construct a &[ArgumentV1] to pass into the fmt::Arguments
782782
// constructor. In general the expressions in this slice might be
@@ -849,7 +849,7 @@ impl<'a, 'b> Context<'a, 'b> {
849849
fmt_args.push(Context::format_arg(self.ecx, self.macsp, span, arg_ty, arg));
850850
}
851851

852-
let args_array = self.ecx.expr_vec(self.macsp, fmt_args);
852+
let args_array = self.ecx.expr_array(self.macsp, fmt_args);
853853
let args_slice = self.ecx.expr_addr_of(
854854
self.macsp,
855855
if no_need_for_match {
@@ -879,7 +879,7 @@ impl<'a, 'b> Context<'a, 'b> {
879879
} else {
880880
// Build up the static array which will store our precompiled
881881
// nonstandard placeholders, if there are any.
882-
let fmt = self.ecx.expr_vec_slice(self.macsp, self.pieces);
882+
let fmt = self.ecx.expr_array_ref(self.macsp, self.pieces);
883883

884884
let path = self.ecx.std_path(&[sym::fmt, sym::UnsafeArg, sym::new]);
885885
let unsafe_arg = self.ecx.expr_call_global(self.macsp, path, Vec::new());

compiler/rustc_builtin_macros/src/proc_macro_harness.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
317317
proc_macro_ty_method_path(cx, custom_derive),
318318
vec![
319319
cx.expr_str(span, cd.trait_name),
320-
cx.expr_vec_slice(
320+
cx.expr_array_ref(
321321
span,
322322
cd.attrs.iter().map(|&s| cx.expr_str(span, s)).collect::<Vec<_>>(),
323323
),
@@ -362,7 +362,7 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
362362
ast::Mutability::Not,
363363
),
364364
ast::Mutability::Not,
365-
cx.expr_vec_slice(span, decls),
365+
cx.expr_array_ref(span, decls),
366366
)
367367
.map(|mut i| {
368368
let attr = cx.meta_word(span, sym::rustc_proc_macro_decls);

compiler/rustc_builtin_macros/src/test_harness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ fn mk_tests_slice(cx: &TestCtxt<'_>, sp: Span) -> P<ast::Expr> {
351351
debug!("building test vector from {} tests", cx.test_cases.len());
352352
let ecx = &cx.ext_cx;
353353

354-
ecx.expr_vec_slice(
354+
ecx.expr_array_ref(
355355
sp,
356356
cx.test_cases
357357
.iter()

compiler/rustc_expand/src/build.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,16 @@ impl<'a> ExtCtxt<'a> {
315315
self.expr_lit(sp, ast::LitKind::Bool(value))
316316
}
317317

318-
pub fn expr_vec(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
318+
/// `[expr1, expr2, ...]`
319+
pub fn expr_array(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
319320
self.expr(sp, ast::ExprKind::Array(exprs))
320321
}
321-
pub fn expr_vec_slice(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
322-
self.expr_addr_of(sp, self.expr_vec(sp, exprs))
322+
323+
/// `&[expr1, expr2, ...]`
324+
pub fn expr_array_ref(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
325+
self.expr_addr_of(sp, self.expr_array(sp, exprs))
323326
}
327+
324328
pub fn expr_str(&self, sp: Span, s: Symbol) -> P<ast::Expr> {
325329
self.expr_lit(sp, ast::LitKind::Str(s, ast::StrStyle::Cooked))
326330
}

0 commit comments

Comments
 (0)