File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -307,6 +307,35 @@ impl<'tcx> NeoPlace<'tcx> {
307
307
None
308
308
}
309
309
}
310
+
311
+ // for a place_elem returns it's prefix path
312
+ // Base.[a, b, c]
313
+ // ^-- place_elem
314
+ // ^^^^^^^-- prefix
315
+ pub fn prefix < ' cx , ' gcx > (
316
+ & self ,
317
+ tcx : TyCtxt < ' cx , ' gcx , ' tcx > ,
318
+ elem_index : usize ,
319
+ ) -> Self {
320
+ // only works for place with projections
321
+ assert ! ( !self . elems. is_empty( ) ) ;
322
+
323
+ if elem_index < 1 {
324
+ // Base.[a]
325
+ // ^-- elems[0]
326
+ Self {
327
+ base : self . clone ( ) . base ,
328
+ elems : List :: empty ( ) ,
329
+ }
330
+ } else {
331
+ Self {
332
+ base : self . clone ( ) . base ,
333
+ elems : tcx. mk_place_elems (
334
+ self . elems . iter ( ) . cloned ( ) . take ( elem_index)
335
+ )
336
+ }
337
+ }
338
+ }
310
339
}
311
340
312
341
pub enum RvalueInitializationState {
You can’t perform that action at this time.
0 commit comments