From d8b6919d4fcd1b69494278bb4472e095e2cd52f3 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Fri, 31 Jan 2014 21:32:39 +1100 Subject: std::fmt: prepare to convert the formatting traits to methods, and work around the lack of UFCS. The further work is pending a snapshot, to avoid putting #[cfg(stage0)] attributes on all the traits and duplicating them. --- src/libsyntax/ext/format.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 535f5a5d0cd..1893cc0c722 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -702,7 +702,7 @@ impl<'a> Context<'a> { Named(ref s) => self.name_types.get(s) }; - let fmt_trait = match *ty { + let fmt_fn = match *ty { Known(ref tyname) => { match tyname.as_slice() { "" => "secret_show", @@ -721,10 +721,9 @@ impl<'a> Context<'a> { "x" => "secret_lower_hex", "X" => "secret_upper_hex", _ => { - self.ecx.span_err(sp, - format!("unknown format trait `{}`", - *tyname)); - "Dummy" + self.ecx.span_err(sp, format!("unknown format trait `{}`", + *tyname)); + "dummy" } } } @@ -747,8 +746,7 @@ impl<'a> Context<'a> { let format_fn = self.ecx.path_global(sp, ~[ self.ecx.ident_of("std"), self.ecx.ident_of("fmt"), - self.ecx.ident_of(fmt_trait), - self.ecx.ident_of("fmt"), + self.ecx.ident_of(fmt_fn), ]); self.ecx.expr_call_global(sp, ~[ self.ecx.ident_of("std"), -- cgit 1.4.1-3-g733a5