about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src/format.rs
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2021-10-18 00:41:57 +0100
committerGary Guo <gary@garyguo.net>2022-01-29 13:52:19 +0000
commita832f5f7bc33002f2b983b0e05bd3cb98f899ed2 (patch)
tree3e3a9e8302cdacf70e71d13cd6f112a8d115d9b8 /compiler/rustc_builtin_macros/src/format.rs
parentbfe15646761a75f0259e204cab071565eed2b1e5 (diff)
downloadrust-a832f5f7bc33002f2b983b0e05bd3cb98f899ed2.tar.gz
rust-a832f5f7bc33002f2b983b0e05bd3cb98f899ed2.zip
Create `core::fmt::ArgumentV1` with generics instead of fn pointer
Diffstat (limited to 'compiler/rustc_builtin_macros/src/format.rs')
-rw-r--r--compiler/rustc_builtin_macros/src/format.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs
index d1393528d1c..453f2163da1 100644
--- a/compiler/rustc_builtin_macros/src/format.rs
+++ b/compiler/rustc_builtin_macros/src/format.rs
@@ -877,11 +877,21 @@ impl<'a, 'b> Context<'a, 'b> {
                 return ecx.expr_call_global(macsp, path, vec![arg]);
             }
         };
+        let new_fn_name = match trait_ {
+            "Display" => "new_display",
+            "Debug" => "new_debug",
+            "LowerExp" => "new_lower_exp",
+            "UpperExp" => "new_upper_exp",
+            "Octal" => "new_octal",
+            "Pointer" => "new_pointer",
+            "Binary" => "new_binary",
+            "LowerHex" => "new_lower_hex",
+            "UpperHex" => "new_upper_hex",
+            _ => unreachable!(),
+        };
 
-        let path = ecx.std_path(&[sym::fmt, Symbol::intern(trait_), sym::fmt]);
-        let format_fn = ecx.path_global(sp, path);
-        let path = ecx.std_path(&[sym::fmt, sym::ArgumentV1, sym::new]);
-        ecx.expr_call_global(macsp, path, vec![arg, ecx.expr_path(format_fn)])
+        let path = ecx.std_path(&[sym::fmt, sym::ArgumentV1, Symbol::intern(new_fn_name)]);
+        ecx.expr_call_global(sp, path, vec![arg])
     }
 }