@@ -72,7 +72,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
72
72
Some ( name) => format ! ( "`{}`" , name) ,
73
73
None => "value" . to_owned ( ) ,
74
74
} ;
75
- let mut err = self . tcx . cannot_act_on_uninitialized_variable (
75
+ let mut err = self . infcx . tcx . cannot_act_on_uninitialized_variable (
76
76
span,
77
77
desired_action. as_noun ( ) ,
78
78
& self
@@ -99,7 +99,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
99
99
100
100
let msg = "" ; //FIXME: add "partially " or "collaterally "
101
101
102
- let mut err = self . tcx . cannot_act_on_moved_value (
102
+ let mut err = self . infcx . tcx . cannot_act_on_moved_value (
103
103
span,
104
104
desired_action. as_noun ( ) ,
105
105
msg,
@@ -151,9 +151,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
151
151
if let Some ( ty) = self . retrieve_type_for_place ( place) {
152
152
let needs_note = match ty. sty {
153
153
ty:: Closure ( id, _) => {
154
- let tables = self . tcx . typeck_tables_of ( id) ;
155
- let node_id = self . tcx . hir . as_local_node_id ( id) . unwrap ( ) ;
156
- let hir_id = self . tcx . hir . node_to_hir_id ( node_id) ;
154
+ let tables = self . infcx . tcx . typeck_tables_of ( id) ;
155
+ let node_id = self . infcx . tcx . hir . as_local_node_id ( id) . unwrap ( ) ;
156
+ let hir_id = self . infcx . tcx . hir . node_to_hir_id ( node_id) ;
157
157
if tables. closure_kind_origins ( ) . get ( hir_id) . is_some ( ) {
158
158
false
159
159
} else {
@@ -200,7 +200,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
200
200
( place, _span) : ( & Place < ' tcx > , Span ) ,
201
201
borrow : & BorrowData < ' tcx > ,
202
202
) {
203
- let tcx = self . tcx ;
203
+ let tcx = self . infcx . tcx ;
204
204
let value_msg = match self . describe_place ( place) {
205
205
Some ( name) => format ! ( "`{}`" , name) ,
206
206
None => "value" . to_owned ( ) ,
@@ -228,7 +228,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
228
228
229
229
move_spans. var_span_label ( & mut err, "move occurs due to use in closure" ) ;
230
230
231
- self . explain_why_borrow_contains_point ( context, borrow, None ) . emit ( self . tcx , & mut err) ;
231
+ self . explain_why_borrow_contains_point ( context, borrow, None )
232
+ . emit ( self . infcx . tcx , & mut err) ;
232
233
err. buffer ( & mut self . errors_buffer ) ;
233
234
}
234
235
@@ -238,7 +239,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
238
239
( place, _span) : ( & Place < ' tcx > , Span ) ,
239
240
borrow : & BorrowData < ' tcx > ,
240
241
) {
241
- let tcx = self . tcx ;
242
+ let tcx = self . infcx . tcx ;
242
243
243
244
let borrow_spans = self . retrieve_borrow_spans ( borrow) ;
244
245
let borrow_span = borrow_spans. args_or_use ( ) ;
@@ -265,7 +266,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
265
266
format ! ( "borrow occurs due to use of `{}` in closure" , desc_place)
266
267
} ) ;
267
268
268
- self . explain_why_borrow_contains_point ( context, borrow, None ) . emit ( self . tcx , & mut err) ;
269
+ self . explain_why_borrow_contains_point ( context, borrow, None )
270
+ . emit ( self . infcx . tcx , & mut err) ;
269
271
err. buffer ( & mut self . errors_buffer ) ;
270
272
}
271
273
@@ -283,7 +285,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
283
285
let span = borrow_spans. args_or_use ( ) ;
284
286
285
287
let desc_place = self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ;
286
- let tcx = self . tcx ;
288
+ let tcx = self . infcx . tcx ;
287
289
288
290
// FIXME: supply non-"" `opt_via` when appropriate
289
291
let mut err = match (
@@ -393,7 +395,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
393
395
}
394
396
395
397
self . explain_why_borrow_contains_point ( context, issued_borrow, None )
396
- . emit ( self . tcx , & mut err) ;
398
+ . emit ( self . infcx . tcx , & mut err) ;
397
399
398
400
err. buffer ( & mut self . errors_buffer ) ;
399
401
}
@@ -420,7 +422,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
420
422
) ;
421
423
422
424
let drop_span = place_span. 1 ;
423
- let scope_tree = self . tcx . region_scope_tree ( self . mir_def_id ) ;
425
+ let scope_tree = self . infcx . tcx . region_scope_tree ( self . mir_def_id ) ;
424
426
let root_place = self
425
427
. prefixes ( & borrow. borrowed_place , PrefixSet :: All )
426
428
. last ( )
@@ -503,7 +505,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
503
505
context, name, scope_tree, borrow, drop_span, borrow_span
504
506
) ;
505
507
506
- let mut err = self . tcx . path_does_not_live_long_enough (
508
+ let mut err = self . infcx . tcx . path_does_not_live_long_enough (
507
509
borrow_span,
508
510
& format ! ( "`{}`" , name) ,
509
511
Origin :: Mir ,
@@ -516,7 +518,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
516
518
) ;
517
519
518
520
self . explain_why_borrow_contains_point ( context, borrow, kind_place)
519
- . emit ( self . tcx , & mut err) ;
521
+ . emit ( self . infcx . tcx , & mut err) ;
520
522
521
523
err
522
524
}
@@ -594,9 +596,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
594
596
drop_span, borrow_span
595
597
) ;
596
598
597
- let mut err = self
598
- . tcx
599
- . thread_local_value_does_not_live_long_enough ( borrow_span , Origin :: Mir ) ;
599
+ let mut err = self . infcx . tcx . thread_local_value_does_not_live_long_enough (
600
+ borrow_span , Origin :: Mir
601
+ ) ;
600
602
601
603
err. span_label (
602
604
borrow_span,
@@ -622,7 +624,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
622
624
context, scope_tree, borrow, drop_span, proper_span
623
625
) ;
624
626
625
- let tcx = self . tcx ;
627
+ let tcx = self . infcx . tcx ;
626
628
let mut err =
627
629
tcx. path_does_not_live_long_enough ( proper_span, "borrowed value" , Origin :: Mir ) ;
628
630
err. span_label ( proper_span, "temporary value does not live long enough" ) ;
@@ -638,7 +640,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
638
640
} ,
639
641
_ => { } ,
640
642
}
641
- explanation. emit ( self . tcx , & mut err) ;
643
+ explanation. emit ( self . infcx . tcx , & mut err) ;
642
644
643
645
err
644
646
}
@@ -713,7 +715,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
713
715
714
716
// check for inits
715
717
let mut any_match = false ;
716
- drop_flag_effects:: for_location_inits ( self . tcx , self . mir , self . move_data , l, |m| {
718
+ drop_flag_effects:: for_location_inits ( self . infcx . tcx , self . mir , self . move_data , l, |m| {
717
719
if m == mpi {
718
720
any_match = true ;
719
721
}
@@ -737,7 +739,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
737
739
let loan_spans = self . retrieve_borrow_spans ( loan) ;
738
740
let loan_span = loan_spans. args_or_use ( ) ;
739
741
740
- let tcx = self . tcx ;
742
+ let tcx = self . infcx . tcx ;
741
743
let mut err = tcx. cannot_assign_to_borrowed (
742
744
span,
743
745
loan_span,
@@ -747,7 +749,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
747
749
748
750
loan_spans. var_span_label ( & mut err, "borrow occurs due to use in closure" ) ;
749
751
750
- self . explain_why_borrow_contains_point ( context, loan, None ) . emit ( self . tcx , & mut err) ;
752
+ self . explain_why_borrow_contains_point ( context, loan, None ) . emit ( self . infcx . tcx , & mut err) ;
751
753
752
754
err. buffer ( & mut self . errors_buffer ) ;
753
755
}
@@ -799,7 +801,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
799
801
Some ( decl) => ( self . describe_place ( err_place) , decl. source_info . span ) ,
800
802
} ;
801
803
802
- let mut err = self . tcx . cannot_reassign_immutable (
804
+ let mut err = self . infcx . tcx . cannot_reassign_immutable (
803
805
span,
804
806
place_description. as_ref ( ) . map ( AsRef :: as_ref) . unwrap_or ( "_" ) ,
805
807
from_arg,
@@ -877,13 +879,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
877
879
self . append_local_to_string ( local, buf) ?;
878
880
}
879
881
Place :: Static ( ref static_) => {
880
- buf. push_str ( & self . tcx . item_name ( static_. def_id ) . to_string ( ) ) ;
882
+ buf. push_str ( & self . infcx . tcx . item_name ( static_. def_id ) . to_string ( ) ) ;
881
883
}
882
884
Place :: Projection ( ref proj) => {
883
885
match proj. elem {
884
886
ProjectionElem :: Deref => {
885
887
let upvar_field_projection =
886
- place. is_upvar_field_projection ( self . mir , & self . tcx ) ;
888
+ place. is_upvar_field_projection ( self . mir , & self . infcx . tcx ) ;
887
889
if let Some ( field) = upvar_field_projection {
888
890
let var_index = field. index ( ) ;
889
891
let name = self . mir . upvar_decls [ var_index] . debug_name . to_string ( ) ;
@@ -945,7 +947,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
945
947
autoderef = true ;
946
948
947
949
let upvar_field_projection =
948
- place. is_upvar_field_projection ( self . mir , & self . tcx ) ;
950
+ place. is_upvar_field_projection ( self . mir , & self . infcx . tcx ) ;
949
951
if let Some ( field) = upvar_field_projection {
950
952
let var_index = field. index ( ) ;
951
953
let name = self . mir . upvar_decls [ var_index] . debug_name . to_string ( ) ;
@@ -1060,10 +1062,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1060
1062
// the local code in the current crate, so this returns an `Option` in case
1061
1063
// the closure comes from another crate. But in that case we wouldn't
1062
1064
// be borrowck'ing it, so we can just unwrap:
1063
- let node_id = self . tcx . hir . as_local_node_id ( def_id) . unwrap ( ) ;
1064
- let freevar = self . tcx . with_freevars ( node_id, |fv| fv[ field. index ( ) ] ) ;
1065
+ let node_id = self . infcx . tcx . hir . as_local_node_id ( def_id) . unwrap ( ) ;
1066
+ let freevar = self . infcx . tcx . with_freevars ( node_id, |fv| fv[ field. index ( ) ] ) ;
1065
1067
1066
- self . tcx . hir . name ( freevar. var_id ( ) ) . to_string ( )
1068
+ self . infcx . tcx . hir . name ( freevar. var_id ( ) ) . to_string ( )
1067
1069
}
1068
1070
_ => {
1069
1071
// Might need a revision when the fields in trait RFC is implemented
@@ -1096,7 +1098,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1096
1098
/// Check if a place is a thread-local static.
1097
1099
pub fn is_place_thread_local ( & self , place : & Place < ' tcx > ) -> bool {
1098
1100
if let Place :: Static ( statik) = place {
1099
- let attrs = self . tcx . get_attrs ( statik. def_id ) ;
1101
+ let attrs = self . infcx . tcx . get_attrs ( statik. def_id ) ;
1100
1102
let is_thread_local = attrs. iter ( ) . any ( |attr| attr. check_name ( "thread_local" ) ) ;
1101
1103
1102
1104
debug ! (
@@ -1212,9 +1214,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1212
1214
if let AggregateKind :: Closure ( def_id, _) = * * kind {
1213
1215
debug ! ( "find_closure_move_span: found closure {:?}" , places) ;
1214
1216
1215
- if let Some ( node_id) = self . tcx . hir . as_local_node_id ( def_id) {
1216
- if let Closure ( _, _, _, args_span, _) = self . tcx . hir . expect_expr ( node_id) . node {
1217
- if let Some ( var_span) = self . tcx . with_freevars ( node_id, |freevars| {
1217
+ if let Some ( node_id) = self . infcx . tcx . hir . as_local_node_id ( def_id) {
1218
+ if let Closure (
1219
+ _, _, _, args_span, _
1220
+ ) = self . infcx . tcx . hir . expect_expr ( node_id) . node {
1221
+ if let Some ( var_span) = self . infcx . tcx . with_freevars ( node_id, |freevars| {
1218
1222
for ( v, place) in freevars. iter ( ) . zip ( places) {
1219
1223
match place {
1220
1224
Operand :: Copy ( place) | Operand :: Move ( place)
@@ -1274,16 +1278,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1274
1278
if let AggregateKind :: Closure ( def_id, _) = * * kind {
1275
1279
debug ! ( "find_closure_borrow_span: found closure {:?}" , places) ;
1276
1280
1277
- return if let Some ( node_id) = self . tcx . hir . as_local_node_id ( def_id) {
1281
+ return if let Some ( node_id) = self . infcx . tcx . hir . as_local_node_id ( def_id) {
1278
1282
let args_span = if let Closure ( _, _, _, span, _) =
1279
- self . tcx . hir . expect_expr ( node_id) . node
1283
+ self . infcx . tcx . hir . expect_expr ( node_id) . node
1280
1284
{
1281
1285
span
1282
1286
} else {
1283
1287
return OtherUse ( use_span) ;
1284
1288
} ;
1285
1289
1286
- self . tcx
1290
+ self . infcx . tcx
1287
1291
. with_freevars ( node_id, |freevars| {
1288
1292
for ( v, place) in freevars. iter ( ) . zip ( places) {
1289
1293
match * place {
0 commit comments