Skip to content

Commit 9f6d0cb

Browse files
authored
Rollup merge of #93463 - dtolnay:_args, r=cjgillot
Rename _args -> args in format_args expansion As observed in #91359 (comment), prior to that PR this variable was sometimes never used, such as in the case of: ```rust println!(""); // used to expand to: ::std::io::_print( ::core::fmt::Arguments::new_v1( &["\n"], &match () { _args => [], }, ), ); ``` so the leading underscore in `_args` was used to suppress an unused variable lint. However after #91359 the variable is always used when present, as the unused case would instead expand to: ```rust ::std::io::_print(::core::fmt::Arguments::new_v1(&["\n"], &[])); ```
2 parents 0d08bbc + 6667d78 commit 9f6d0cb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler/rustc_builtin_macros/src/format.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ impl<'a, 'b> Context<'a, 'b> {
791791
// Thus in the not nicely ordered case we emit the following instead:
792792
//
793793
// match (&$arg0, &$arg1, …) {
794-
// _args => [ArgumentV1::new(_args.$i, …), ArgumentV1::new(_args.$j, …), …]
794+
// args => [ArgumentV1::new(args.$i, …), ArgumentV1::new(args.$j, …), …]
795795
// }
796796
//
797797
// for the sequence of indices $i, $j, … governed by fmt_arg_index_and_ty.
@@ -804,7 +804,7 @@ impl<'a, 'b> Context<'a, 'b> {
804804
self.ecx.expr_addr_of(expansion_span, P(e.take()))
805805
} else {
806806
let def_site = self.ecx.with_def_site_ctxt(span);
807-
let args_tuple = self.ecx.expr_ident(def_site, Ident::new(sym::_args, def_site));
807+
let args_tuple = self.ecx.expr_ident(def_site, Ident::new(sym::args, def_site));
808808
let member = Ident::new(sym::integer(arg_index), def_site);
809809
self.ecx.expr(def_site, ast::ExprKind::Field(args_tuple, member))
810810
};
@@ -828,7 +828,7 @@ impl<'a, 'b> Context<'a, 'b> {
828828
.map(|e| self.ecx.expr_addr_of(e.span.with_ctxt(self.macsp.ctxt()), e))
829829
.collect();
830830

831-
let pat = self.ecx.pat_ident(self.macsp, Ident::new(sym::_args, self.macsp));
831+
let pat = self.ecx.pat_ident(self.macsp, Ident::new(sym::args, self.macsp));
832832
let arm = self.ecx.arm(self.macsp, pat, args_array);
833833
let head = self.ecx.expr(self.macsp, ast::ExprKind::Tup(heads));
834834
self.ecx.expr_match(self.macsp, head, vec![arm])

compiler/rustc_span/src/symbol.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ symbols! {
272272
__H,
273273
__S,
274274
__try_var,
275-
_args,
276275
_d,
277276
_e,
278277
_task_context,
@@ -324,6 +323,7 @@ symbols! {
324323
append_const_msg,
325324
arbitrary_enum_discriminant,
326325
arbitrary_self_types,
326+
args,
327327
arith_offset,
328328
arm,
329329
arm_target_feature,

0 commit comments

Comments
 (0)