@@ -96,7 +96,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
96
96
span,
97
97
desired_action. as_noun ( ) ,
98
98
& self . describe_place_with_options ( moved_place, IncludingDowncast ( true ) )
99
- . unwrap_or ( "_" . to_owned ( ) ) ,
99
+ . unwrap_or_else ( || "_" . to_owned ( ) ) ,
100
100
Origin :: Mir ,
101
101
) ;
102
102
err. span_label ( span, format ! ( "use of possibly uninitialized {}" , item_msg) ) ;
@@ -260,7 +260,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
260
260
261
261
let mut err = tcx. cannot_move_when_borrowed (
262
262
span,
263
- & self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ,
263
+ & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
264
264
Origin :: Mir ,
265
265
) ;
266
266
err. span_label ( borrow_span, format ! ( "borrow of {} occurs here" , borrow_msg) ) ;
@@ -299,16 +299,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
299
299
300
300
let mut err = tcx. cannot_use_when_mutably_borrowed (
301
301
span,
302
- & self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ,
302
+ & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
303
303
borrow_span,
304
304
& self . describe_place ( & borrow. borrowed_place )
305
- . unwrap_or ( "_" . to_owned ( ) ) ,
305
+ . unwrap_or_else ( || "_" . to_owned ( ) ) ,
306
306
Origin :: Mir ,
307
307
) ;
308
308
309
309
borrow_spans. var_span_label ( & mut err, {
310
310
let place = & borrow. borrowed_place ;
311
- let desc_place = self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ;
311
+ let desc_place = self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ;
312
312
313
313
format ! ( "borrow occurs due to use of `{}`{}" , desc_place, borrow_spans. describe( ) )
314
314
} ) ;
@@ -337,7 +337,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
337
337
"closure"
338
338
} ;
339
339
340
- let desc_place = self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ;
340
+ let desc_place = self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ;
341
341
let tcx = self . infcx . tcx ;
342
342
343
343
let first_borrow_desc;
@@ -490,7 +490,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
490
490
) ;
491
491
} else {
492
492
let borrow_place = & issued_borrow. borrowed_place ;
493
- let borrow_place_desc = self . describe_place ( borrow_place) . unwrap_or ( "_" . to_owned ( ) ) ;
493
+ let borrow_place_desc = self . describe_place ( borrow_place)
494
+ . unwrap_or_else ( || "_" . to_owned ( ) ) ;
494
495
issued_spans. var_span_label (
495
496
& mut err,
496
497
format ! (
@@ -943,15 +944,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
943
944
tcx. cannot_mutate_in_match_guard (
944
945
span,
945
946
loan_span,
946
- & self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ,
947
+ & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
947
948
"assign" ,
948
949
Origin :: Mir ,
949
950
)
950
951
} else {
951
952
tcx. cannot_assign_to_borrowed (
952
953
span,
953
954
loan_span,
954
- & self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ,
955
+ & self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
955
956
Origin :: Mir ,
956
957
)
957
958
} ;
0 commit comments