@@ -2,7 +2,9 @@ use core::unicode::property::Pattern_White_Space;
2
2
use rustc:: hir;
3
3
use rustc:: hir:: Node ;
4
4
use rustc:: mir:: { self , BindingForm , ClearCrossCrate , Local , Location , Body } ;
5
- use rustc:: mir:: { Mutability , Place , PlaceBase , Projection , ProjectionElem , Static , StaticKind } ;
5
+ use rustc:: mir:: {
6
+ Mutability , Place , PlaceRef , PlaceBase , Projection , ProjectionElem , Static , StaticKind
7
+ } ;
6
8
use rustc:: ty:: { self , Ty , TyCtxt } ;
7
9
use rustc_data_structures:: indexed_vec:: Idx ;
8
10
use syntax_pos:: Span ;
@@ -25,7 +27,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
25
27
& mut self ,
26
28
access_place : & Place < ' tcx > ,
27
29
span : Span ,
28
- the_place_err : & Place < ' tcx > ,
30
+ the_place_err : PlaceRef < ' cx , ' tcx > ,
29
31
error_access : AccessKind ,
30
32
location : Location ,
31
33
) {
@@ -44,7 +46,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
44
46
debug ! ( "report_mutability_error: access_place_desc={:?}" , access_place_desc) ;
45
47
46
48
match the_place_err {
47
- Place {
49
+ PlaceRef {
48
50
base : PlaceBase :: Local ( local) ,
49
51
projection : None ,
50
52
} => {
@@ -62,7 +64,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
62
64
}
63
65
}
64
66
65
- Place {
67
+ PlaceRef {
66
68
base : _,
67
69
projection :
68
70
Some ( box Projection {
@@ -83,21 +85,27 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
83
85
}
84
86
}
85
87
86
- Place {
88
+ PlaceRef {
87
89
base : _,
88
90
projection :
89
91
Some ( box Projection {
90
92
base,
91
93
elem : ProjectionElem :: Deref ,
92
94
} ) ,
93
95
} => {
94
- if the_place_err. base == PlaceBase :: Local ( Local :: new ( 1 ) ) &&
96
+ if the_place_err. base == & PlaceBase :: Local ( Local :: new ( 1 ) ) &&
95
97
base. is_none ( ) &&
96
98
!self . upvars . is_empty ( ) {
97
99
item_msg = format ! ( "`{}`" , access_place_desc. unwrap( ) ) ;
98
100
debug_assert ! ( self . body. local_decls[ Local :: new( 1 ) ] . ty. is_region_ptr( ) ) ;
99
101
debug_assert ! ( is_closure_or_generator(
100
- the_place_err. ty( self . body, self . infcx. tcx) . ty
102
+ Place :: ty_from(
103
+ the_place_err. base,
104
+ the_place_err. projection,
105
+ self . body,
106
+ self . infcx. tcx
107
+ )
108
+ . ty
101
109
) ) ;
102
110
103
111
reason =
@@ -138,7 +146,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
138
146
}
139
147
}
140
148
141
- Place {
149
+ PlaceRef {
142
150
base :
143
151
PlaceBase :: Static ( box Static {
144
152
kind : StaticKind :: Promoted ( _) ,
@@ -147,7 +155,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
147
155
projection : None ,
148
156
} => unreachable ! ( ) ,
149
157
150
- Place {
158
+ PlaceRef {
151
159
base :
152
160
PlaceBase :: Static ( box Static {
153
161
kind : StaticKind :: Static ( def_id) ,
@@ -168,30 +176,30 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
168
176
}
169
177
}
170
178
171
- Place {
179
+ PlaceRef {
172
180
base : _,
173
181
projection :
174
182
Some ( box Projection {
175
183
base : _,
176
184
elem : ProjectionElem :: Index ( _) ,
177
185
} ) ,
178
186
}
179
- | Place {
187
+ | PlaceRef {
180
188
base : _,
181
189
projection :
182
190
Some ( box Projection {
183
191
base : _,
184
192
elem : ProjectionElem :: ConstantIndex { .. } ,
185
193
} ) ,
186
194
}
187
- | Place {
195
+ | PlaceRef {
188
196
base : _,
189
197
projection : Some ( box Projection {
190
198
base : _,
191
199
elem : ProjectionElem :: Subslice { .. } ,
192
200
} ) ,
193
201
}
194
- | Place {
202
+ | PlaceRef {
195
203
base : _,
196
204
projection : Some ( box Projection {
197
205
base : _,
@@ -252,7 +260,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
252
260
// something like `*((*_1).0`. The local that we get will be a reference to the
253
261
// struct we've got a field access of (it must be a reference since there's a deref
254
262
// after the field access).
255
- Place {
263
+ PlaceRef {
256
264
base,
257
265
projection : Some ( box Projection {
258
266
base : Some ( box Projection {
@@ -282,7 +290,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
282
290
} ,
283
291
284
292
// Suggest removing a `&mut` from the use of a mutable reference.
285
- Place {
293
+ PlaceRef {
286
294
base : PlaceBase :: Local ( local) ,
287
295
projection : None ,
288
296
} if {
@@ -318,7 +326,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
318
326
319
327
// We want to suggest users use `let mut` for local (user
320
328
// variable) mutations...
321
- Place {
329
+ PlaceRef {
322
330
base : PlaceBase :: Local ( local) ,
323
331
projection : None ,
324
332
} if self . body . local_decls [ * local] . can_be_made_mutable ( ) => {
@@ -339,7 +347,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
339
347
}
340
348
341
349
// Also suggest adding mut for upvars
342
- Place {
350
+ PlaceRef {
343
351
base,
344
352
projection : Some ( box Projection {
345
353
base : proj_base,
@@ -375,7 +383,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
375
383
// complete hack to approximate old AST-borrowck
376
384
// diagnostic: if the span starts with a mutable borrow of
377
385
// a local variable, then just suggest the user remove it.
378
- Place {
386
+ PlaceRef {
379
387
base : PlaceBase :: Local ( _) ,
380
388
projection : None ,
381
389
} if {
@@ -390,7 +398,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
390
398
err. span_label ( span, "try removing `&mut` here" ) ;
391
399
}
392
400
393
- Place {
401
+ PlaceRef {
394
402
base : PlaceBase :: Local ( local) ,
395
403
projection : Some ( box Projection {
396
404
base : None ,
@@ -417,7 +425,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
417
425
//
418
426
// FIXME: can this case be generalized to work for an
419
427
// arbitrary base for the projection?
420
- Place {
428
+ PlaceRef {
421
429
base : PlaceBase :: Local ( local) ,
422
430
projection : Some ( box Projection {
423
431
base : None ,
@@ -500,7 +508,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
500
508
}
501
509
}
502
510
503
- Place {
511
+ PlaceRef {
504
512
base,
505
513
projection : Some ( box Projection {
506
514
base : None ,
@@ -517,7 +525,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
517
525
) ;
518
526
}
519
527
520
- Place {
528
+ PlaceRef {
521
529
base : _,
522
530
projection : Some ( box Projection {
523
531
base : _,
0 commit comments