@@ -207,7 +207,7 @@ pub(crate) fn should_write_ir(tcx: TyCtxt<'_>) -> bool {
207
207
208
208
pub ( crate ) fn write_ir_file (
209
209
tcx : TyCtxt < ' _ > ,
210
- name : & str ,
210
+ name : impl FnOnce ( ) -> String ,
211
211
write : impl FnOnce ( & mut dyn Write ) -> std:: io:: Result < ( ) > ,
212
212
) {
213
213
if !should_write_ir ( tcx) {
@@ -222,7 +222,7 @@ pub(crate) fn write_ir_file(
222
222
res @ Err ( _) => res. unwrap ( ) ,
223
223
}
224
224
225
- let clif_file_name = clif_output_dir. join ( name) ;
225
+ let clif_file_name = clif_output_dir. join ( name ( ) ) ;
226
226
227
227
let res = std:: fs:: File :: create ( clif_file_name) . and_then ( |mut file| write ( & mut file) ) ;
228
228
if let Err ( err) = res {
@@ -238,27 +238,31 @@ pub(crate) fn write_clif_file<'tcx>(
238
238
context : & cranelift_codegen:: Context ,
239
239
mut clif_comments : & CommentWriter ,
240
240
) {
241
- write_ir_file ( tcx, & format ! ( "{}.{}.clif" , tcx. symbol_name( instance) . name, postfix) , |file| {
242
- let value_ranges =
243
- isa. map ( |isa| context. build_value_labels_ranges ( isa) . expect ( "value location ranges" ) ) ;
241
+ write_ir_file (
242
+ tcx,
243
+ || format ! ( "{}.{}.clif" , tcx. symbol_name( instance) . name, postfix) ,
244
+ |file| {
245
+ let value_ranges = isa
246
+ . map ( |isa| context. build_value_labels_ranges ( isa) . expect ( "value location ranges" ) ) ;
244
247
245
- let mut clif = String :: new ( ) ;
246
- cranelift_codegen:: write:: decorate_function (
247
- & mut clif_comments,
248
- & mut clif,
249
- & context. func ,
250
- & DisplayFunctionAnnotations { isa, value_ranges : value_ranges. as_ref ( ) } ,
251
- )
252
- . unwrap ( ) ;
248
+ let mut clif = String :: new ( ) ;
249
+ cranelift_codegen:: write:: decorate_function (
250
+ & mut clif_comments,
251
+ & mut clif,
252
+ & context. func ,
253
+ & DisplayFunctionAnnotations { isa, value_ranges : value_ranges. as_ref ( ) } ,
254
+ )
255
+ . unwrap ( ) ;
253
256
254
- writeln ! ( file, "test compile" ) ?;
255
- writeln ! ( file, "set is_pic" ) ?;
256
- writeln ! ( file, "set enable_simd" ) ?;
257
- writeln ! ( file, "target {} haswell" , crate :: target_triple( tcx. sess) ) ?;
258
- writeln ! ( file) ?;
259
- file. write_all ( clif. as_bytes ( ) ) ?;
260
- Ok ( ( ) )
261
- } ) ;
257
+ writeln ! ( file, "test compile" ) ?;
258
+ writeln ! ( file, "set is_pic" ) ?;
259
+ writeln ! ( file, "set enable_simd" ) ?;
260
+ writeln ! ( file, "target {} haswell" , crate :: target_triple( tcx. sess) ) ?;
261
+ writeln ! ( file) ?;
262
+ file. write_all ( clif. as_bytes ( ) ) ?;
263
+ Ok ( ( ) )
264
+ } ,
265
+ ) ;
262
266
}
263
267
264
268
impl fmt:: Debug for FunctionCx < ' _ , ' _ , ' _ > {
0 commit comments