File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ mod rustc;
99
1010use std:: env;
1111use std:: ffi:: OsString ;
12+ use std:: fmt:: { self , Debug , Display } ;
1213use std:: fs;
1314use std:: iter;
1415use std:: path:: Path ;
@@ -91,7 +92,7 @@ fn main() {
9192 println ! ( "cargo:rustc-check-cfg=cfg(host_os, values(\" windows\" ))" ) ;
9293 }
9394
94- let version = format ! ( "{:#? }\n " , version) ;
95+ let version = format ! ( "{:#}\n " , Render ( & version) ) ;
9596 let out_dir = env:: var_os ( "OUT_DIR" ) . expect ( "OUT_DIR not set" ) ;
9697 let out_file = Path :: new ( & out_dir) . join ( "version.expr" ) ;
9798 fs:: write ( out_file, version) . expect ( "failed to write version.expr" ) ;
@@ -101,3 +102,13 @@ fn main() {
101102 println ! ( "cargo:rustc-cfg=host_os=\" windows\" " ) ;
102103 }
103104}
105+
106+ // Shim Version's {:?} format into a {} format, because {:?} is unusable in
107+ // format strings when building with `-Zfmt-debug=none`.
108+ struct Render < ' a > ( & ' a rustc:: Version ) ;
109+
110+ impl < ' a > Display for Render < ' a > {
111+ fn fmt ( & self , formatter : & mut fmt:: Formatter ) -> fmt:: Result {
112+ Debug :: fmt ( self . 0 , formatter)
113+ }
114+ }
You can’t perform that action at this time.
0 commit comments