Skip to content

Commit fc838ad

Browse files
author
Jorge Aparicio
committed
syntax: Use UFCS instead of secret_* fns in expansion of format_args!
1 parent 3327ecc commit fc838ad

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/libsyntax/ext/format.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -663,28 +663,28 @@ impl<'a, 'b> Context<'a, 'b> {
663663
fn format_arg(ecx: &ExtCtxt, sp: Span,
664664
ty: &ArgumentType, arg: P<ast::Expr>)
665665
-> P<ast::Expr> {
666-
let (krate, fmt_fn) = match *ty {
666+
let trait_ = match *ty {
667667
Known(ref tyname) => {
668668
match tyname.as_slice() {
669-
"" => ("std", "secret_show"),
670-
"b" => ("std", "secret_bool"),
671-
"c" => ("std", "secret_char"),
672-
"d" | "i" => ("std", "secret_signed"),
673-
"e" => ("std", "secret_lower_exp"),
674-
"E" => ("std", "secret_upper_exp"),
675-
"f" => ("std", "secret_float"),
676-
"o" => ("std", "secret_octal"),
677-
"p" => ("std", "secret_pointer"),
678-
"s" => ("std", "secret_string"),
679-
"t" => ("std", "secret_binary"),
680-
"u" => ("std", "secret_unsigned"),
681-
"x" => ("std", "secret_lower_hex"),
682-
"X" => ("std", "secret_upper_hex"),
669+
"" => "Show",
670+
"b" => "Bool",
671+
"c" => "Char",
672+
"d" | "i" => "Signed",
673+
"e" => "LowerExp",
674+
"E" => "UpperExp",
675+
"f" => "Float",
676+
"o" => "Octal",
677+
"p" => "Pointer",
678+
"s" => "String",
679+
"t" => "Binary",
680+
"u" => "Unsigned",
681+
"x" => "LowerHex",
682+
"X" => "UpperHex",
683683
_ => {
684684
ecx.span_err(sp,
685685
format!("unknown format trait `{}`",
686686
*tyname).as_slice());
687-
("std", "dummy")
687+
"Dummy"
688688
}
689689
}
690690
}
@@ -697,9 +697,10 @@ impl<'a, 'b> Context<'a, 'b> {
697697
};
698698

699699
let format_fn = ecx.path_global(sp, vec![
700-
ecx.ident_of(krate),
700+
ecx.ident_of("std"),
701701
ecx.ident_of("fmt"),
702-
ecx.ident_of(fmt_fn)]);
702+
ecx.ident_of(trait_),
703+
ecx.ident_of("fmt")]);
703704
ecx.expr_call_global(sp, vec![
704705
ecx.ident_of("std"),
705706
ecx.ident_of("fmt"),

0 commit comments

Comments
 (0)