diff options
| author | Paul Daniel Faria <Nashenas88@users.noreply.github.com> | 2019-11-24 23:39:22 -0500 |
|---|---|---|
| committer | Paul Daniel Faria <Nashenas88@users.noreply.github.com> | 2019-12-02 08:43:01 -0500 |
| commit | 9978574c9e18ac2feb2daf0758ec00e407be75ca (patch) | |
| tree | 3cf08e3992c19b39b9b4a6413de8427dfa55bdf5 /src | |
| parent | 64654ce1f171faad7461db90435bffefe0390151 (diff) | |
| download | rust-9978574c9e18ac2feb2daf0758ec00e407be75ca.tar.gz rust-9978574c9e18ac2feb2daf0758ec00e407be75ca.zip | |
Fix rebasing errors, convert some BodyCache::body() calls to reborrows
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/borrow_check/mutability_errors.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/type_check/mod.rs | 28 | ||||
| -rw-r--r-- | src/librustc_mir/transform/check_consts/qualifs.rs | 6 | ||||
| -rw-r--r-- | src/librustc_mir/transform/check_consts/resolver.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/transform/check_consts/validation.rs | 16 | ||||
| -rw-r--r-- | src/librustc_mir/transform/mod.rs | 1 | ||||
| -rw-r--r-- | src/librustc_mir/transform/promote_consts.rs | 18 | ||||
| -rw-r--r-- | src/librustc_mir/transform/simplify_try.rs | 4 |
8 files changed, 39 insertions, 38 deletions
diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index 348c788eb33..e135f8d1be9 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -365,7 +365,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { PlaceRef { base: PlaceBase::Local(local), projection: [ProjectionElem::Deref], - } if self.body_cache.local_decls[*local].is_user_variable.is_some() => + } if self.body.local_decls[*local].is_user_variable() => { let local_decl = &self.body.local_decls[*local]; let suggestion = match local_decl.local_info { diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 3fcc6e9e176..b8a275e5b34 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -1406,9 +1406,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { _ => ConstraintCategory::Assignment, }; - let place_ty = place.ty(body.body(), tcx).ty; + let place_ty = place.ty(&*body, tcx).ty; let place_ty = self.normalize(place_ty, location); - let rv_ty = rv.ty(body.body(), tcx); + let rv_ty = rv.ty(&*body, tcx); let rv_ty = self.normalize(rv_ty, location); if let Err(terr) = self.sub_types_or_anon(rv_ty, place_ty, location.to_locations(), category) @@ -1460,7 +1460,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ref place, variant_index, } => { - let place_type = place.ty(body.body(), tcx).ty; + let place_type = place.ty(&*body, tcx).ty; let adt = match place_type.kind { ty::Adt(adt, _) if adt.is_enum() => adt, _ => { @@ -1482,7 +1482,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { }; } StatementKind::AscribeUserType(box(ref place, ref projection), variance) => { - let place_ty = place.ty(body.body(), tcx).ty; + let place_ty = place.ty(&*body, tcx).ty; if let Err(terr) = self.relate_type_and_user_type( place_ty, variance, @@ -1998,7 +1998,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { // While this is located in `nll::typeck` this error is not an NLL error, it's // a required check to make sure that repeated elements implement `Copy`. let span = body.source_info(location).span; - let ty = operand.ty(body.body(), tcx); + let ty = operand.ty(&*body, tcx); if !self.infcx.type_is_copy_modulo_regions(self.param_env, ty, span) { // To determine if `const_in_array_repeat_expressions` feature gate should // be mentioned, need to check if the rvalue is promotable. @@ -2052,7 +2052,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { Rvalue::Cast(cast_kind, op, ty) => { match cast_kind { CastKind::Pointer(PointerCast::ReifyFnPointer) => { - let fn_sig = op.ty(body.body(), tcx).fn_sig(tcx); + let fn_sig = op.ty(&*body, tcx).fn_sig(tcx); // The type that we see in the fcx is like // `foo::<'a, 'b>`, where `foo` is the path to a @@ -2081,7 +2081,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } CastKind::Pointer(PointerCast::ClosureFnPointer(unsafety)) => { - let sig = match op.ty(body.body(), tcx).kind { + let sig = match op.ty(&*body, tcx).kind { ty::Closure(def_id, substs) => { substs.as_closure().sig_ty(def_id, tcx).fn_sig(tcx) } @@ -2107,7 +2107,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } CastKind::Pointer(PointerCast::UnsafeFnPointer) => { - let fn_sig = op.ty(body.body(), tcx).fn_sig(tcx); + let fn_sig = op.ty(&*body, tcx).fn_sig(tcx); // The type that we see in the fcx is like // `foo::<'a, 'b>`, where `foo` is the path to a @@ -2139,7 +2139,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let &ty = ty; let trait_ref = ty::TraitRef { def_id: tcx.lang_items().coerce_unsized_trait().unwrap(), - substs: tcx.mk_substs_trait(op.ty(body.body(), tcx), &[ty.into()]), + substs: tcx.mk_substs_trait(op.ty(&*body, tcx), &[ty.into()]), }; self.prove_trait_ref( @@ -2150,7 +2150,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } CastKind::Pointer(PointerCast::MutToConstPointer) => { - let ty_from = match op.ty(body.body(), tcx).kind { + let ty_from = match op.ty(&*body, tcx).kind { ty::RawPtr(ty::TypeAndMut { ty: ty_from, mutbl: hir::Mutability::Mutable, @@ -2198,7 +2198,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } CastKind::Pointer(PointerCast::ArrayToPointer) => { - let ty_from = op.ty(body.body(), tcx); + let ty_from = op.ty(&*body, tcx); let opt_ty_elem = match ty_from.kind { ty::RawPtr( @@ -2260,7 +2260,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } CastKind::Misc => { - let ty_from = op.ty(body.body(), tcx); + let ty_from = op.ty(&*body, tcx); let cast_ty_from = CastTy::from_ty(ty_from); let cast_ty_to = CastTy::from_ty(ty); match (cast_ty_from, cast_ty_to) { @@ -2327,9 +2327,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { | Rvalue::BinaryOp(BinOp::Le, left, right) | Rvalue::BinaryOp(BinOp::Gt, left, right) | Rvalue::BinaryOp(BinOp::Ge, left, right) => { - let ty_left = left.ty(body.body(), tcx); + let ty_left = left.ty(&*body, tcx); if let ty::RawPtr(_) | ty::FnPtr(_) = ty_left.kind { - let ty_right = right.ty(body.body(), tcx); + let ty_right = right.ty(&*body, tcx); let common_ty = self.infcx.next_ty_var( TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, diff --git a/src/librustc_mir/transform/check_consts/qualifs.rs b/src/librustc_mir/transform/check_consts/qualifs.rs index 718988b26d8..62b4a4ccc98 100644 --- a/src/librustc_mir/transform/check_consts/qualifs.rs +++ b/src/librustc_mir/transform/check_consts/qualifs.rs @@ -51,7 +51,7 @@ pub trait Qualif { }); let qualif = base_qualif && Self::in_any_value_of_ty( cx, - Place::ty_from(place.base, proj_base, cx.body.body(), cx.tcx) + Place::ty_from(place.base, proj_base, &*cx.body, cx.tcx) .projection_ty(cx.tcx, elem) .ty, ); @@ -155,7 +155,7 @@ pub trait Qualif { // Special-case reborrows to be more like a copy of the reference. if let &[ref proj_base @ .., elem] = place.projection.as_ref() { if ProjectionElem::Deref == elem { - let base_ty = Place::ty_from(&place.base, proj_base, cx.body.body(), cx.tcx).ty; + let base_ty = Place::ty_from(&place.base, proj_base, &*cx.body, cx.tcx).ty; if let ty::Ref(..) = base_ty.kind { return Self::in_place(cx, per_local, PlaceRef { base: &place.base, @@ -221,7 +221,7 @@ impl Qualif for HasMutInterior { Rvalue::Aggregate(ref kind, _) => { if let AggregateKind::Adt(def, ..) = **kind { if Some(def.did) == cx.tcx.lang_items().unsafe_cell_type() { - let ty = rvalue.ty(cx.body.body(), cx.tcx); + let ty = rvalue.ty(&*cx.body, cx.tcx); assert_eq!(Self::in_any_value_of_ty(cx, ty), true); return true; } diff --git a/src/librustc_mir/transform/check_consts/resolver.rs b/src/librustc_mir/transform/check_consts/resolver.rs index 7db649e6ba0..9004c5be987 100644 --- a/src/librustc_mir/transform/check_consts/resolver.rs +++ b/src/librustc_mir/transform/check_consts/resolver.rs @@ -77,7 +77,7 @@ where args: &[mir::Operand<'tcx>], return_place: &mir::Place<'tcx>, ) { - let return_ty = return_place.ty(self.item.body.body(), self.item.tcx).ty; + let return_ty = return_place.ty(&*self.item.body, self.item.tcx).ty; let qualif = Q::in_call( self.item, &|l| self.qualifs_per_local.contains(l), diff --git a/src/librustc_mir/transform/check_consts/validation.rs b/src/librustc_mir/transform/check_consts/validation.rs index 63b100dc86d..86e1d6584fc 100644 --- a/src/librustc_mir/transform/check_consts/validation.rs +++ b/src/librustc_mir/transform/check_consts/validation.rs @@ -172,7 +172,7 @@ impl Validator<'a, 'mir, 'tcx> { let indirectly_mutable = old_dataflow::do_dataflow( item.tcx, - item.body.body(), + &*item.body, item.def_id, &item.tcx.get_attrs(item.def_id), &dead_unwinds, @@ -304,7 +304,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { // Special-case reborrows to be more like a copy of a reference. if let Rvalue::Ref(_, kind, ref place) = *rvalue { - if let Some(reborrowed_proj) = place_as_reborrow(self.tcx, self.body.body(), place) { + if let Some(reborrowed_proj) = place_as_reborrow(self.tcx, &*self.body, place) { let ctx = match kind { BorrowKind::Shared => PlaceContext::NonMutatingUse( NonMutatingUseContext::SharedBorrow, @@ -390,7 +390,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { } Rvalue::Cast(CastKind::Misc, ref operand, cast_ty) => { - let operand_ty = operand.ty(self.body.body(), self.tcx); + let operand_ty = operand.ty(&*self.body, self.tcx); let cast_in = CastTy::from_ty(operand_ty).expect("bad input type for cast"); let cast_out = CastTy::from_ty(cast_ty).expect("bad output type for cast"); @@ -401,7 +401,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { } Rvalue::BinaryOp(op, ref lhs, _) => { - if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(self.body.body(), self.tcx).kind { + if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(&*self.body, self.tcx).kind { assert!(op == BinOp::Eq || op == BinOp::Ne || op == BinOp::Le || op == BinOp::Lt || op == BinOp::Ge || op == BinOp::Gt || @@ -475,7 +475,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { match elem { ProjectionElem::Deref => { - let base_ty = Place::ty_from(place_base, proj_base, self.body.body(), self.tcx).ty; + let base_ty = Place::ty_from(place_base, proj_base, &*self.body, self.tcx).ty; if let ty::RawPtr(_) = base_ty.kind { if proj_base.is_empty() { if let (PlaceBase::Local(local), []) = (place_base, proj_base) { @@ -499,7 +499,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { ProjectionElem::Subslice {..} | ProjectionElem::Field(..) | ProjectionElem::Index(_) => { - let base_ty = Place::ty_from(place_base, proj_base, self.body.body(), self.tcx).ty; + let base_ty = Place::ty_from(place_base, proj_base, &*self.body, self.tcx).ty; match base_ty.ty_adt_def() { Some(def) if def.is_union() => { self.check_op(ops::UnionAccess); @@ -548,7 +548,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { match kind { TerminatorKind::Call { func, .. } => { - let fn_ty = func.ty(self.body.body(), self.tcx); + let fn_ty = func.ty(&*self.body, self.tcx); let def_id = match fn_ty.kind { ty::FnDef(def_id, _) => def_id, @@ -609,7 +609,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { // Check to see if the type of this place can ever have a drop impl. If not, this // `Drop` terminator is frivolous. let ty_needs_drop = dropped_place - .ty(self.body.body(), self.tcx) + .ty(&*self.body, self.tcx) .ty .needs_drop(self.tcx, self.param_env); diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 3273588ec1a..df4cb761533 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -231,6 +231,7 @@ fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal<BodyCache<'_>> { &rustc_peek::SanityCheck, &uniform_array_move_out::UniformArrayMoveOut, ]); + body.ensure_predecessors(); tcx.alloc_steal_mir(body) } diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 1a2eeb9025b..4af9ccb83ac 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -349,7 +349,7 @@ impl<'tcx> Validator<'_, 'tcx> { let ty = Place::ty_from( &place.base, proj_base, - self.body.body(), + &*self.body, self.tcx ) .projection_ty(self.tcx, elem) @@ -372,7 +372,7 @@ impl<'tcx> Validator<'_, 'tcx> { } if let BorrowKind::Mut { .. } = kind { - let ty = place.ty(self.body.body(), self.tcx).ty; + let ty = place.ty(&*self.body, self.tcx).ty; // In theory, any zero-sized value could be borrowed // mutably without consequences. However, only &mut [] @@ -521,7 +521,7 @@ impl<'tcx> Validator<'_, 'tcx> { ProjectionElem::Field(..) => { if self.const_kind.is_none() { let base_ty = - Place::ty_from(place.base, proj_base, self.body.body(), self.tcx).ty; + Place::ty_from(place.base, proj_base, &*self.body, self.tcx).ty; if let Some(def) = base_ty.ty_adt_def() { // No promotion of union field accesses. if def.is_union() { @@ -570,7 +570,7 @@ impl<'tcx> Validator<'_, 'tcx> { fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> { match *rvalue { Rvalue::Cast(CastKind::Misc, ref operand, cast_ty) if self.const_kind.is_none() => { - let operand_ty = operand.ty(self.body.body(), self.tcx); + let operand_ty = operand.ty(&*self.body, self.tcx); let cast_in = CastTy::from_ty(operand_ty).expect("bad input type for cast"); let cast_out = CastTy::from_ty(cast_ty).expect("bad output type for cast"); match (cast_in, cast_out) { @@ -584,7 +584,7 @@ impl<'tcx> Validator<'_, 'tcx> { } Rvalue::BinaryOp(op, ref lhs, _) if self.const_kind.is_none() => { - if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(self.body.body(), self.tcx).kind { + if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(&*self.body, self.tcx).kind { assert!(op == BinOp::Eq || op == BinOp::Ne || op == BinOp::Le || op == BinOp::Lt || op == BinOp::Ge || op == BinOp::Gt || @@ -619,7 +619,7 @@ impl<'tcx> Validator<'_, 'tcx> { Rvalue::Ref(_, kind, place) => { if let BorrowKind::Mut { .. } = kind { - let ty = place.ty(self.body.body(), self.tcx).ty; + let ty = place.ty(&*self.body, self.tcx).ty; // In theory, any zero-sized value could be borrowed // mutably without consequences. However, only &mut [] @@ -646,7 +646,7 @@ impl<'tcx> Validator<'_, 'tcx> { let mut place = place.as_ref(); if let [proj_base @ .., ProjectionElem::Deref] = &place.projection { let base_ty = - Place::ty_from(&place.base, proj_base, self.body.body(), self.tcx).ty; + Place::ty_from(&place.base, proj_base, &*self.body, self.tcx).ty; if let ty::Ref(..) = base_ty.kind { place = PlaceRef { base: &place.base, @@ -672,7 +672,7 @@ impl<'tcx> Validator<'_, 'tcx> { while let [proj_base @ .., elem] = place_projection { // FIXME(eddyb) this is probably excessive, with // the exception of `union` member accesses. - let ty = Place::ty_from(place.base, proj_base, self.body.body(), self.tcx) + let ty = Place::ty_from(place.base, proj_base, &*self.body, self.tcx) .projection_ty(self.tcx, elem) .ty; if ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) { @@ -705,7 +705,7 @@ impl<'tcx> Validator<'_, 'tcx> { callee: &Operand<'tcx>, args: &[Operand<'tcx>], ) -> Result<(), Unpromotable> { - let fn_ty = callee.ty(self.body.body(), self.tcx); + let fn_ty = callee.ty(&*self.body, self.tcx); if !self.explicit && self.const_kind.is_none() { if let ty::FnDef(def_id, _) = fn_ty.kind { diff --git a/src/librustc_mir/transform/simplify_try.rs b/src/librustc_mir/transform/simplify_try.rs index 9dc5daa9b07..2235de9a153 100644 --- a/src/librustc_mir/transform/simplify_try.rs +++ b/src/librustc_mir/transform/simplify_try.rs @@ -33,7 +33,7 @@ use itertools::Itertools as _; pub struct SimplifyArmIdentity; impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity { - fn run_pass(&self, _: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) { + fn run_pass(&self, _: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut BodyCache<'tcx>) { let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut(); for bb in basic_blocks { // Need 3 statements: @@ -151,7 +151,7 @@ fn match_variant_field_place<'tcx>(place: &Place<'tcx>) -> Option<(Local, VarFie pub struct SimplifyBranchSame; impl<'tcx> MirPass<'tcx> for SimplifyBranchSame { - fn run_pass(&self, _: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) { + fn run_pass(&self, _: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut BodyCache<'tcx>) { let mut did_remove_blocks = false; let bbs = body.basic_blocks_mut(); for bb_idx in bbs.indices() { |
