@@ -66,6 +66,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
66
66
location, desired_action, moved_place, used_place, span, mpi
67
67
) ;
68
68
69
+ let tcx = self . infcx . tcx ;
69
70
let use_spans =
70
71
self . move_spans ( moved_place, location) . or_else ( || self . borrow_spans ( span, location) ) ;
71
72
let span = use_spans. args_or_use ( ) ;
@@ -243,11 +244,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
243
244
) ;
244
245
}
245
246
246
- let ty = used_place. ty ( self . body , self . infcx . tcx ) . ty ;
247
+ let ty = used_place. ty ( self . body , tcx) . ty ;
247
248
let needs_note = match ty. kind ( ) {
248
249
ty:: Closure ( id, _) => {
249
- let tables = self . infcx . tcx . typeck ( id. expect_local ( ) ) ;
250
- let hir_id = self . infcx . tcx . hir ( ) . local_def_id_to_hir_id ( id. expect_local ( ) ) ;
250
+ let tables = tcx. typeck ( id. expect_local ( ) ) ;
251
+ let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( id. expect_local ( ) ) ;
251
252
252
253
tables. closure_kind_origins ( ) . get ( hir_id) . is_none ( )
253
254
}
@@ -256,7 +257,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
256
257
257
258
let mpi = self . move_data . moves [ move_out_indices[ 0 ] ] . path ;
258
259
let place = & self . move_data . move_paths [ mpi] . place ;
259
- let ty = place. ty ( self . body , self . infcx . tcx ) . ty ;
260
+ let ty = place. ty ( self . body , tcx) . ty ;
260
261
261
262
// If we're in pattern, we do nothing in favor of the previous suggestion (#80913).
262
263
if is_loop_move & !in_pattern {
@@ -285,7 +286,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
285
286
} ;
286
287
287
288
// Try to find predicates on *generic params* that would allow copying `ty`
288
- let tcx = self . infcx . tcx ;
289
289
let generics = tcx. generics_of ( self . mir_def_id ( ) ) ;
290
290
if let Some ( hir_generics) = tcx
291
291
. typeck_root_def_id ( self . mir_def_id ( ) . to_def_id ( ) )
@@ -329,7 +329,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
329
329
) ) ;
330
330
331
331
// Check first whether the source is accessible (issue #87060)
332
- if self . infcx . tcx . sess . source_map ( ) . span_to_snippet ( deref_target) . is_ok ( ) {
332
+ if tcx. sess . source_map ( ) . span_to_snippet ( deref_target) . is_ok ( ) {
333
333
err. span_note ( deref_target, "deref defined here" ) ;
334
334
}
335
335
}
@@ -1012,6 +1012,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1012
1012
location, name, borrow, drop_span, borrow_spans
1013
1013
) ;
1014
1014
1015
+ let tcx = self . infcx . tcx ;
1015
1016
let borrow_span = borrow_spans. var_or_use_path_span ( ) ;
1016
1017
if let BorrowExplanation :: MustBeValidFor {
1017
1018
category,
@@ -1048,19 +1049,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1048
1049
format ! (
1049
1050
"...but `{}` will be dropped here, when the {} returns" ,
1050
1051
name,
1051
- self . infcx
1052
- . tcx
1053
- . hir( )
1052
+ tcx. hir( )
1054
1053
. opt_name( fn_hir_id)
1055
1054
. map( |name| format!( "function `{}`" , name) )
1056
1055
. unwrap_or_else( || {
1057
- match & self
1058
- . infcx
1059
- . tcx
1060
- . typeck( self . mir_def_id( ) )
1061
- . node_type( fn_hir_id)
1062
- . kind( )
1063
- {
1056
+ match & tcx. typeck( self . mir_def_id( ) ) . node_type( fn_hir_id) . kind( ) {
1064
1057
ty:: Closure ( ..) => "enclosing closure" ,
1065
1058
ty:: Generator ( ..) => "enclosing generator" ,
1066
1059
kind => bug!( "expected closure or generator, found {:?}" , kind) ,
@@ -1082,7 +1075,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1082
1075
if let BorrowExplanation :: MustBeValidFor { .. } = explanation {
1083
1076
} else {
1084
1077
explanation. add_explanation_to_diagnostic (
1085
- self . infcx . tcx ,
1078
+ tcx,
1086
1079
& self . body ,
1087
1080
& self . local_names ,
1088
1081
& mut err,
@@ -1100,7 +1093,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1100
1093
borrow_spans. args_span_label ( & mut err, format ! ( "value captured here{}" , within) ) ;
1101
1094
1102
1095
explanation. add_explanation_to_diagnostic (
1103
- self . infcx . tcx ,
1096
+ tcx,
1104
1097
& self . body ,
1105
1098
& self . local_names ,
1106
1099
& mut err,
0 commit comments