Skip to content

Commit ce8e327

Browse files
committed
Recursive Arguments formatting
1 parent 0a77ec2 commit ce8e327

File tree

2 files changed

+6
-0
lines changed
  • compiler/rustc_const_eval/src/const_eval
  • library/core/src/fmt

2 files changed

+6
-0
lines changed

compiler/rustc_const_eval/src/const_eval/panic.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use rustc_hir::def_id::DefId;
22
use rustc_middle::ty::{self, layout::LayoutOf, subst::Subst};
3+
use rustc_span::sym;
34
use std::cell::Cell;
45
use std::fmt::{self, Debug, Formatter};
56

@@ -154,6 +155,10 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
154155
return self.fmt_arg(place.into(), fmt_trait, f);
155156
}
156157

158+
ty::Adt(adt, _) if self.tcx.is_diagnostic_item(sym::Arguments, adt.did) => {
159+
return self.fmt_arguments(arg, f);
160+
}
161+
157162
// FIXME(nbdd0121): ty::Adt(..) => (),
158163
_ => {
159164
let _ = write!(f, "<failed to format {}>", arg.layout.ty);

library/core/src/fmt/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ impl<'a> Arguments<'a> {
458458
///
459459
/// [`format()`]: ../../std/fmt/fn.format.html
460460
#[stable(feature = "rust1", since = "1.0.0")]
461+
#[rustc_diagnostic_item = "Arguments"]
461462
#[derive(Copy, Clone)]
462463
pub struct Arguments<'a> {
463464
// Format string pieces to print.

0 commit comments

Comments
 (0)