Skip to content

Commit 8ca7fc6

Browse files
csmoespastorino
authored andcommitted
generate tys of sub-places
1 parent 4420fff commit 8ca7fc6

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

src/librustc/mir/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,7 +2129,7 @@ impl<'tcx> NeoPlace<'tcx> {
21292129
self,
21302130
tcx: TyCtxt<'_, '_, 'tcx>,
21312131
adt_def: &'tcx AdtDef,
2132-
variant_index: usize,
2132+
variant_index: VariantIdx,
21332133
) -> Self {
21342134
self.elem(tcx, ProjectionElem::Downcast(adt_def, variant_index))
21352135
}
@@ -3619,7 +3619,9 @@ where
36193619
V: TypeFoldable<'tcx>,
36203620
T: TypeFoldable<'tcx>,
36213621
{
3622-
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
3622+
default fn super_fold_with<'gcx: 'tcx, F>(&self, folder: &mut F) -> Self
3623+
where F: TypeFolder<'gcx, 'tcx>
3624+
{
36233625
use self::ProjectionElem::*;
36243626
match self {
36253627
Deref => Deref,
@@ -3629,7 +3631,7 @@ where
36293631
}
36303632
}
36313633

3632-
fn super_visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> bool {
3634+
default fn super_visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> bool {
36333635
use self::ProjectionElem::*;
36343636
match self {
36353637
Field(_, ty) => ty.visit_with(visitor),

src/librustc/mir/tcx.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,29 @@ impl<'tcx> NeoPlace<'tcx> {
334334
}
335335
}
336336
}
337+
338+
// Generate types of sub-places
339+
//
340+
// Base.[a, b]
341+
// ^^^^-- base_ty
342+
// ^^^^^^^-- elem1_ty
343+
// ^^^^^^^^^^--elem2_ty
344+
//
345+
// [base_ty, elem1_ty, elem2_ty]
346+
pub fn place_tys<'cx, 'gcx>(
347+
&self,
348+
mir: &'cx Mir<'tcx>,
349+
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
350+
) -> Vec<PlaceTy<'tcx>> {
351+
let mut base_ty = PlaceTy::from(self.base.ty(mir));
352+
let mut place_tys: Vec<PlaceTy<'tcx>> = vec![base_ty];
353+
for elem in self.elems.iter() {
354+
let elem_ty = base_ty.projection_ty(tcx, elem);
355+
place_tys.push(elem_ty);
356+
base_ty = elem_ty;
357+
}
358+
place_tys
359+
}
337360
}
338361

339362
pub enum RvalueInitializationState {

src/librustc/mir/visit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,6 @@ macro_rules! make_mir_visitor {
788788
for elem in elems.iter().cloned().rev() {
789789
self.visit_projection_elem(
790790
&$($mutability)* elem.clone(),
791-
context,
792791
location
793792
);
794793
}

src/librustc_mir/borrow_check/borrow_set.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ use rustc::mir::visit::{
88
};
99
use rustc::mir::{self, Location, Mir, Local};
1010
use rustc::ty::{RegionVid, TyCtxt};
11+
<<<<<<< HEAD
12+
||||||| merged common ancestors
13+
use rustc::mir::PlaceBase;
14+
use rustc::ty::{RegionVid, TyCtxt};
15+
=======
16+
use rustc::mir::PlaceBase;
17+
>>>>>>> generate tys of sub-places
1118
use rustc::util::nodemap::{FxHashMap, FxHashSet};
1219
use rustc_data_structures::indexed_vec::IndexVec;
1320
use rustc_data_structures::bit_set::BitSet;

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
10961096
);
10971097

10981098
let annotated_type = self.mir.user_type_annotations[user_ty.base].inferred_ty;
1099-
let mut curr_projected_ty = PlaceTy::from_ty(annotated_type);
1099+
let mut curr_projected_ty = PlaceTy::from(annotated_type);
11001100

11011101
let tcx = self.infcx.tcx;
11021102

0 commit comments

Comments
 (0)