]> git.lizzy.rs Git - rust.git/commitdiff
Don't use `*` for deref-coercion
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Sun, 12 Apr 2020 17:28:41 +0000 (10:28 -0700)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Wed, 22 Apr 2020 16:57:43 +0000 (09:57 -0700)
17 files changed:
src/librustc_codegen_ssa/mir/analyze.rs
src/librustc_codegen_ssa/mir/block.rs
src/librustc_codegen_ssa/mir/place.rs
src/librustc_codegen_ssa/mir/rvalue.rs
src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs
src/librustc_mir/borrow_check/diagnostics/mod.rs
src/librustc_mir/borrow_check/diagnostics/move_errors.rs
src/librustc_mir/borrow_check/diagnostics/mutability_errors.rs
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/borrow_check/prefixes.rs
src/librustc_mir/borrow_check/type_check/mod.rs
src/librustc_mir/const_eval/machine.rs
src/librustc_mir/transform/check_consts/qualifs.rs
src/librustc_mir/transform/check_consts/resolver.rs
src/librustc_mir/transform/check_consts/validation.rs
src/librustc_mir/transform/inline.rs
src/librustc_mir/transform/promote_consts.rs

index 71b9ff26140f96401a2f4d82b0a2f0827499769b..8baa19023640b8c16ce0305174d85071c6d3eca9 100644 (file)
@@ -120,7 +120,7 @@ fn process_place(
             };
             if is_consume {
                 let base_ty =
-                    mir::Place::ty_from(place_ref.local, proj_base, *self.fx.mir, cx.tcx());
+                    mir::Place::ty_from(place_ref.local, proj_base, self.fx.mir, cx.tcx());
                 let base_ty = self.fx.monomorphize(&base_ty);
 
                 // ZSTs don't require any actual memory access.
index 112833845e5a461ac536b68009e6a21982910a60..bea1d319fe794d93a25364556a888844664f9c38 100644 (file)
@@ -306,7 +306,7 @@ fn codegen_drop_terminator(
         target: mir::BasicBlock,
         unwind: Option<mir::BasicBlock>,
     ) {
-        let ty = location.ty(*self.mir, bx.tcx()).ty;
+        let ty = location.ty(self.mir, bx.tcx()).ty;
         let ty = self.monomorphize(&ty);
         let drop_fn = Instance::resolve_drop_in_place(bx.tcx(), ty);
 
@@ -572,7 +572,7 @@ fn codegen_call_terminator(
         let extra_args = extra_args
             .iter()
             .map(|op_arg| {
-                let op_ty = op_arg.ty(*self.mir, bx.tcx());
+                let op_ty = op_arg.ty(self.mir, bx.tcx());
                 self.monomorphize(&op_ty)
             })
             .collect::<Vec<_>>();
index 461695129c2f37d573e0259acca8c10d416f9da6..aaba2ec1362ac77e25b1b4b5331c59983a7d8fad 100644 (file)
@@ -497,7 +497,7 @@ pub fn codegen_place(
 
     pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'tcx>) -> Ty<'tcx> {
         let tcx = self.cx.tcx();
-        let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, *self.mir, tcx);
+        let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, self.mir, tcx);
         self.monomorphize(&place_ty.ty)
     }
 }
index b9c59cde53a70c7b3034996dc1f9cf8dc0a54dc5..19a0138d9cb6d026fd23a2a95dc044bb985aa6cf 100644 (file)
@@ -473,7 +473,7 @@ pub fn codegen_rvalue_operand(
             }
 
             mir::Rvalue::Discriminant(ref place) => {
-                let discr_ty = rvalue.ty(*self.mir, bx.tcx());
+                let discr_ty = rvalue.ty(self.mir, bx.tcx());
                 let discr = self
                     .codegen_place(&mut bx, place.as_ref())
                     .codegen_get_discr(&mut bx, discr_ty);
@@ -529,7 +529,7 @@ pub fn codegen_rvalue_operand(
             mir::Rvalue::Repeat(..) | mir::Rvalue::Aggregate(..) => {
                 // According to `rvalue_creates_operand`, only ZST
                 // aggregate rvalues are allowed to be operands.
-                let ty = rvalue.ty(*self.mir, self.cx.tcx());
+                let ty = rvalue.ty(self.mir, self.cx.tcx());
                 let operand =
                     OperandRef::new_zst(&mut bx, self.cx.layout_of(self.monomorphize(&ty)));
                 (bx, operand)
@@ -749,7 +749,7 @@ pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Span) ->
                 true,
             mir::Rvalue::Repeat(..) |
             mir::Rvalue::Aggregate(..) => {
-                let ty = rvalue.ty(*self.mir, self.cx.tcx());
+                let ty = rvalue.ty(self.mir, self.cx.tcx());
                 let ty = self.monomorphize(&ty);
                 self.cx.spanned_layout_of(ty, span).is_zst()
             }
index 2529bba6d92f524a11518a03066e34dfc3c5b5f4..860300d834d09d3f07686f481eb79aa0d70bc60c 100644 (file)
@@ -186,7 +186,7 @@ pub(in crate::borrow_check) fn report_use_of_moved_or_uninitialized(
             }
 
             let ty =
-                Place::ty_from(used_place.local, used_place.projection, *self.body, self.infcx.tcx)
+                Place::ty_from(used_place.local, used_place.projection, self.body, self.infcx.tcx)
                     .ty;
             let needs_note = match ty.kind {
                 ty::Closure(id, _) => {
@@ -202,7 +202,7 @@ pub(in crate::borrow_check) fn report_use_of_moved_or_uninitialized(
                 let mpi = self.move_data.moves[move_out_indices[0]].path;
                 let place = &self.move_data.move_paths[mpi].place;
 
-                let ty = place.ty(*self.body, self.infcx.tcx).ty;
+                let ty = place.ty(self.body, self.infcx.tcx).ty;
                 let opt_name =
                     self.describe_place_with_options(place.as_ref(), IncludingDowncast(true));
                 let note_msg = match opt_name {
@@ -591,7 +591,7 @@ pub(in crate::borrow_check) fn describe_place_for_conflicting_borrow(
         // Define a small closure that we can use to check if the type of a place
         // is a union.
         let union_ty = |place_base, place_projection| {
-            let ty = Place::ty_from(place_base, place_projection, *self.body, self.infcx.tcx).ty;
+            let ty = Place::ty_from(place_base, place_projection, self.body, self.infcx.tcx).ty;
             ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty)
         };
 
@@ -1486,7 +1486,7 @@ fn classify_drop_access_kind(&self, place: PlaceRef<'tcx>) -> StorageDeadOrDrop<
                         StorageDeadOrDrop::LocalStorageDead
                         | StorageDeadOrDrop::BoxedStorageDead => {
                             assert!(
-                                Place::ty_from(place.local, proj_base, *self.body, tcx).ty.is_box(),
+                                Place::ty_from(place.local, proj_base, self.body, tcx).ty.is_box(),
                                 "Drop of value behind a reference or raw pointer"
                             );
                             StorageDeadOrDrop::BoxedStorageDead
@@ -1494,7 +1494,7 @@ fn classify_drop_access_kind(&self, place: PlaceRef<'tcx>) -> StorageDeadOrDrop<
                         StorageDeadOrDrop::Destructor(_) => base_access,
                     },
                     ProjectionElem::Field(..) | ProjectionElem::Downcast(..) => {
-                        let base_ty = Place::ty_from(place.local, proj_base, *self.body, tcx).ty;
+                        let base_ty = Place::ty_from(place.local, proj_base, self.body, tcx).ty;
                         match base_ty.kind {
                             ty::Adt(def, _) if def.has_dtor(tcx) => {
                                 // Report the outermost adt with a destructor
index c4aafd101543da081076df3a5b4bb2a647ce4879..91d8d853eafdb780d86321de0c525a3dc64c4a45 100644 (file)
@@ -331,8 +331,7 @@ fn describe_field(&self, place: PlaceRef<'tcx>, field: Field) -> String {
                 }
                 ProjectionElem::Downcast(_, variant_index) => {
                     let base_ty =
-                        Place::ty_from(place.local, place.projection, *self.body, self.infcx.tcx)
-                            .ty;
+                        Place::ty_from(place.local, place.projection, self.body, self.infcx.tcx).ty;
                     self.describe_field_from_ty(&base_ty, field, Some(*variant_index))
                 }
                 ProjectionElem::Field(_, field_type) => {
@@ -449,7 +448,7 @@ pub(super) fn borrowed_content_source(
                     }) = bbd.terminator
                     {
                         if let Some(source) =
-                            BorrowedContentSource::from_call(func.ty(*self.body, tcx), tcx)
+                            BorrowedContentSource::from_call(func.ty(self.body, tcx), tcx)
                         {
                             return source;
                         }
@@ -462,7 +461,7 @@ pub(super) fn borrowed_content_source(
 
         // If we didn't find an overloaded deref or index, then assume it's a
         // built in deref and check the type of the base.
-        let base_ty = Place::ty_from(deref_base.local, deref_base.projection, *self.body, tcx).ty;
+        let base_ty = Place::ty_from(deref_base.local, deref_base.projection, self.body, tcx).ty;
         if base_ty.is_unsafe_ptr() {
             BorrowedContentSource::DerefRawPointer
         } else if base_ty.is_mutable_ptr() {
index 1fbecb75dff531b3787bd5bbbeb2d1086177500e..457e263a46611912cbadca99819e455ebe2020dd 100644 (file)
@@ -296,7 +296,7 @@ fn report_cannot_move_from_borrowed_content(
         // Inspect the type of the content behind the
         // borrow to provide feedback about why this
         // was a move rather than a copy.
-        let ty = deref_target_place.ty(*self.body, self.infcx.tcx).ty;
+        let ty = deref_target_place.ty(self.body, self.infcx.tcx).ty;
         let upvar_field = self
             .prefixes(move_place.as_ref(), PrefixSet::All)
             .find_map(|p| self.is_upvar_field_projection(p));
@@ -385,7 +385,7 @@ fn report_cannot_move_from_borrowed_content(
             }
         };
         if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) {
-            let def_id = match move_place.ty(*self.body, self.infcx.tcx).ty.kind {
+            let def_id = match move_place.ty(self.body, self.infcx.tcx).ty.kind {
                 ty::Adt(self_def, _) => self_def.did,
                 ty::Foreign(def_id)
                 | ty::FnDef(def_id, _)
@@ -441,7 +441,7 @@ fn add_move_hints(
                 }
 
                 if binds_to.is_empty() {
-                    let place_ty = move_from.ty(*self.body, self.infcx.tcx).ty;
+                    let place_ty = move_from.ty(self.body, self.infcx.tcx).ty;
                     let place_desc = match self.describe_place(move_from.as_ref()) {
                         Some(desc) => format!("`{}`", desc),
                         None => "value".to_string(),
@@ -464,7 +464,7 @@ fn add_move_hints(
             // No binding. Nothing to suggest.
             GroupedMoveError::OtherIllegalMove { ref original_path, use_spans, .. } => {
                 let span = use_spans.var_or_use();
-                let place_ty = original_path.ty(*self.body, self.infcx.tcx).ty;
+                let place_ty = original_path.ty(self.body, self.infcx.tcx).ty;
                 let place_desc = match self.describe_place(original_path.as_ref()) {
                     Some(desc) => format!("`{}`", desc),
                     None => "value".to_string(),
index 798b2db571dd48caf096a2884fa57f05cc181aba..c0aee31781e4fcf811e6a1e6e924377edd28ee7f 100644 (file)
@@ -58,7 +58,7 @@ pub(crate) fn report_mutability_error(
                 projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
             } => {
                 debug_assert!(is_closure_or_generator(
-                    Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty
+                    Place::ty_from(local, proj_base, self.body, self.infcx.tcx).ty
                 ));
 
                 item_msg = format!("`{}`", access_place_desc.unwrap());
@@ -104,7 +104,7 @@ pub(crate) fn report_mutability_error(
                         Place::ty_from(
                             the_place_err.local,
                             the_place_err.projection,
-                            *self.body,
+                            self.body,
                             self.infcx.tcx
                         )
                         .ty
@@ -197,7 +197,7 @@ pub(crate) fn report_mutability_error(
 
                 if let Some((span, message)) = annotate_struct_field(
                     self.infcx.tcx,
-                    Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty,
+                    Place::ty_from(local, proj_base, self.body, self.infcx.tcx).ty,
                     field,
                 ) {
                     err.span_suggestion(
@@ -273,7 +273,7 @@ pub(crate) fn report_mutability_error(
                 projection: [proj_base @ .., ProjectionElem::Field(upvar_index, _)],
             } => {
                 debug_assert!(is_closure_or_generator(
-                    Place::ty_from(local, proj_base, *self.body, self.infcx.tcx).ty
+                    Place::ty_from(local, proj_base, self.body, self.infcx.tcx).ty
                 ));
 
                 err.span_label(span, format!("cannot {ACT}", ACT = act));
index ad85e218b86d60bceebf3fd2b2a23bb731332a97..a1f005e3b45d985375777666216c08d626c54555 100644 (file)
@@ -619,7 +619,7 @@ fn visit_terminator(
                 let tcx = self.infcx.tcx;
 
                 // Compute the type with accurate region information.
-                let drop_place_ty = drop_place.ty(*self.body, self.infcx.tcx);
+                let drop_place_ty = drop_place.ty(self.body, self.infcx.tcx);
 
                 // Erase the regions.
                 let drop_place_ty = self.infcx.tcx.erase_regions(&drop_place_ty).ty;
@@ -871,7 +871,7 @@ fn as_verb_in_past_tense(self) -> &'static str {
 
 impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
     fn body(&self) -> &'cx Body<'tcx> {
-        *self.body
+        self.body
     }
 
     /// Checks an access to the given place to see if it is allowed. Examines the set of borrows
index e3d0cdbd18820768c67ef487bbd135bf74bfabeb..7350167684f7a64638d11e765dfb2eb4d7d5bb87 100644 (file)
@@ -120,7 +120,7 @@ fn next(&mut self) -> Option<Self::Item> {
                     // derefs, except we stop at the deref of a shared
                     // reference.
 
-                    let ty = Place::ty_from(cursor.local, proj_base, *self.body, self.tcx).ty;
+                    let ty = Place::ty_from(cursor.local, proj_base, self.body, self.tcx).ty;
                     match ty.kind {
                         ty::RawPtr(_) | ty::Ref(_ /*rgn*/, _ /*ty*/, hir::Mutability::Not) => {
                             // don't continue traversing over derefs of raw pointers or shared
index bd85b48bf4b98a75e34ea3d4b7fc5052f804f55a..f706ac26d07c8c039c3d79273eb84dfc42447338 100644 (file)
@@ -200,7 +200,7 @@ fn type_check_internal<'a, 'tcx, R>(
 ) -> R {
     let mut checker = TypeChecker::new(
         infcx,
-        *body,
+        body,
         mir_def_id,
         param_env,
         region_bound_pairs,
@@ -209,7 +209,7 @@ fn type_check_internal<'a, 'tcx, R>(
         universal_region_relations,
     );
     let errors_reported = {
-        let mut verifier = TypeVerifier::new(&mut checker, *body, promoted);
+        let mut verifier = TypeVerifier::new(&mut checker, body, promoted);
         verifier.visit_body(&body);
         verifier.errors_reported
     };
@@ -341,11 +341,11 @@ fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) {
                     };
 
                     if !self.errors_reported {
-                        let promoted_body = self.promoted[promoted];
+                        let promoted_body = &self.promoted[promoted];
                         self.sanitize_promoted(promoted_body, location);
 
                         let promoted_ty = promoted_body.return_ty();
-                        check_err(self, &promoted_body, ty, promoted_ty);
+                        check_err(self, promoted_body, ty, promoted_ty);
                     }
                 } else {
                     if let Err(terr) = self.cx.fully_perform_op(
@@ -534,7 +534,7 @@ fn sanitize_promoted(
         // checker on the promoted MIR, then transfer the constraints back to
         // the main MIR, changing the locations to the provided location.
 
-        let parent_body = mem::replace(&mut self.body, *promoted_body);
+        let parent_body = mem::replace(&mut self.body, promoted_body);
 
         // Use new sets of constraints and closure bounds so that we can
         // modify their locations.
@@ -1433,9 +1433,9 @@ fn check_stmt(
                     _ => ConstraintCategory::Assignment,
                 };
 
-                let place_ty = place.ty(*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, 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)
@@ -1484,7 +1484,7 @@ fn check_stmt(
                 }
             }
             StatementKind::SetDiscriminant { ref place, variant_index } => {
-                let place_type = place.ty(*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,
                     _ => {
@@ -1506,7 +1506,7 @@ fn check_stmt(
                 };
             }
             StatementKind::AscribeUserType(box (ref place, ref projection), variance) => {
-                let place_ty = place.ty(*body, tcx).ty;
+                let place_ty = place.ty(body, tcx).ty;
                 if let Err(terr) = self.relate_type_and_user_type(
                     place_ty,
                     variance,
@@ -1996,7 +1996,7 @@ fn check_rvalue(
                         // 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, 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.
@@ -2060,7 +2060,7 @@ fn check_rvalue(
             Rvalue::Cast(cast_kind, op, ty) => {
                 match cast_kind {
                     CastKind::Pointer(PointerCast::ReifyFnPointer) => {
-                        let fn_sig = op.ty(*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
@@ -2089,7 +2089,7 @@ fn check_rvalue(
                     }
 
                     CastKind::Pointer(PointerCast::ClosureFnPointer(unsafety)) => {
-                        let sig = match op.ty(*body, tcx).kind {
+                        let sig = match op.ty(body, tcx).kind {
                             ty::Closure(_, substs) => substs.as_closure().sig(),
                             _ => bug!(),
                         };
@@ -2113,7 +2113,7 @@ fn check_rvalue(
                     }
 
                     CastKind::Pointer(PointerCast::UnsafeFnPointer) => {
-                        let fn_sig = op.ty(*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
@@ -2145,7 +2145,7 @@ fn check_rvalue(
                         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, tcx), &[ty.into()]),
+                            substs: tcx.mk_substs_trait(op.ty(body, tcx), &[ty.into()]),
                         };
 
                         self.prove_trait_ref(
@@ -2156,7 +2156,7 @@ fn check_rvalue(
                     }
 
                     CastKind::Pointer(PointerCast::MutToConstPointer) => {
-                        let ty_from = match op.ty(*body, tcx).kind {
+                        let ty_from = match op.ty(body, tcx).kind {
                             ty::RawPtr(ty::TypeAndMut {
                                 ty: ty_from,
                                 mutbl: hir::Mutability::Mut,
@@ -2204,7 +2204,7 @@ fn check_rvalue(
                     }
 
                     CastKind::Pointer(PointerCast::ArrayToPointer) => {
-                        let ty_from = op.ty(*body, tcx);
+                        let ty_from = op.ty(body, tcx);
 
                         let opt_ty_elem = match ty_from.kind {
                             ty::RawPtr(ty::TypeAndMut {
@@ -2264,7 +2264,7 @@ fn check_rvalue(
                     }
 
                     CastKind::Misc => {
-                        let ty_from = op.ty(*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) {
@@ -2295,9 +2295,9 @@ fn check_rvalue(
                 left,
                 right,
             ) => {
-                let ty_left = left.ty(*body, tcx);
+                let ty_left = left.ty(body, tcx);
                 if let ty::RawPtr(_) | ty::FnPtr(_) = ty_left.kind {
-                    let ty_right = right.ty(*body, tcx);
+                    let ty_right = right.ty(body, tcx);
                     let common_ty = self.infcx.next_ty_var(TypeVariableOrigin {
                         kind: TypeVariableOriginKind::MiscVariable,
                         span: body.source_info(location).span,
index 30990853b516a9cd22568a3f97c895070aa19869..cb146059fb1bf93ddea4cbc60b27de92c6b74dc3 100644 (file)
@@ -226,7 +226,7 @@ fn find_mir_or_eval_fn(
         }
         // This is a const fn. Call it.
         Ok(Some(match ecx.load_mir(instance.def, None) {
-            Ok(body) => *body,
+            Ok(body) => body,
             Err(err) => {
                 if let err_unsup!(NoMirFor(did)) = err.kind {
                     let path = ecx.tcx.def_path_str(did);
index f38b9d8ef8586a7fca5ec3581ed954473d543153..5f50e073e29a6f6f75d8c3a24f1224abf33d0705 100644 (file)
@@ -113,7 +113,7 @@ pub fn in_rvalue<Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, rvalue: &Rvalue
     F: FnMut(Local) -> bool,
 {
     match rvalue {
-        Rvalue::NullaryOp(..) => Q::in_any_value_of_ty(cx, rvalue.ty(*cx.body, cx.tcx)),
+        Rvalue::NullaryOp(..) => Q::in_any_value_of_ty(cx, rvalue.ty(cx.body, cx.tcx)),
 
         Rvalue::Discriminant(place) | Rvalue::Len(place) => {
             in_place::<Q, _>(cx, in_local, place.as_ref())
@@ -131,7 +131,7 @@ pub fn in_rvalue<Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, rvalue: &Rvalue
         Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
             // Special-case reborrows to be more like a copy of the reference.
             if let &[ref proj_base @ .., ProjectionElem::Deref] = place.projection.as_ref() {
-                let base_ty = Place::ty_from(place.local, proj_base, *cx.body, cx.tcx).ty;
+                let base_ty = Place::ty_from(place.local, proj_base, cx.body, cx.tcx).ty;
                 if let ty::Ref(..) = base_ty.kind {
                     return in_place::<Q, _>(
                         cx,
@@ -178,7 +178,7 @@ pub fn in_place<Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, place: PlaceRef<
             | ProjectionElem::Index(_) => {}
         }
 
-        let base_ty = Place::ty_from(place.local, proj_base, *cx.body, cx.tcx);
+        let base_ty = Place::ty_from(place.local, proj_base, cx.body, cx.tcx);
         let proj_ty = base_ty.projection_ty(cx.tcx, proj_elem).ty;
         if !Q::in_any_value_of_ty(cx, proj_ty) {
             return false;
index b95a3939389bace36adc7db94eb2b1ffd2dbe221..6ae314b973ffea8a450c3bb5bc61dc920247d46b 100644 (file)
@@ -72,7 +72,7 @@ fn apply_call_return_effect(
     ) {
         // We cannot reason about another function's internals, so use conservative type-based
         // qualification for the result of a function call.
-        let return_ty = return_place.ty(*self.item.body, self.item.tcx).ty;
+        let return_ty = return_place.ty(self.item.body, self.item.tcx).ty;
         let qualif = Q::in_any_value_of_ty(self.item, return_ty);
 
         if !return_place.is_indirect() {
index c51136cdaba2c879c6861e52b5de9f43f6cbb6ec..a3127d4fd258f127a9c81a7635190132c9220cd7 100644 (file)
@@ -39,9 +39,9 @@ struct QualifCursor<'a, 'mir, 'tcx, Q: Qualif> {
 impl<Q: Qualif> QualifCursor<'a, 'mir, 'tcx, Q> {
     pub fn new(q: Q, item: &'a Item<'mir, 'tcx>) -> Self {
         let cursor = FlowSensitiveAnalysis::new(q, item)
-            .into_engine(item.tcx, &item.body, item.def_id)
+            .into_engine(item.tcx, item.body, item.def_id)
             .iterate_to_fixpoint()
-            .into_results_cursor(*item.body);
+            .into_results_cursor(item.body);
 
         let mut in_any_value_of_ty = BitSet::new_empty(item.body.local_decls.len());
         for (local, decl) in item.body.local_decls.iter_enumerated() {
@@ -148,11 +148,11 @@ pub fn new(item: &'a Item<'mir, 'tcx>) -> Self {
         //
         // FIXME(ecstaticmorse): Someday we want to allow custom drop impls. How do we do this
         // without breaking stable code?
-        let indirectly_mutable = MaybeMutBorrowedLocals::mut_borrows_only(tcx, *body, param_env)
+        let indirectly_mutable = MaybeMutBorrowedLocals::mut_borrows_only(tcx, body, param_env)
             .unsound_ignore_borrow_on_drop()
-            .into_engine(tcx, *body, def_id)
+            .into_engine(tcx, body, def_id)
             .iterate_to_fixpoint()
-            .into_results_cursor(*body);
+            .into_results_cursor(body);
 
         let qualifs = Qualifs { needs_drop, has_mut_interior, indirectly_mutable };
 
@@ -261,7 +261,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
         // Special-case reborrows to be more like a copy of a reference.
         match *rvalue {
             Rvalue::Ref(_, kind, place) => {
-                if let Some(reborrowed_proj) = place_as_reborrow(self.tcx, *self.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)
@@ -282,7 +282,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
                 }
             }
             Rvalue::AddressOf(mutbl, place) => {
-                if let Some(reborrowed_proj) = place_as_reborrow(self.tcx, *self.body, place) {
+                if let Some(reborrowed_proj) = place_as_reborrow(self.tcx, self.body, place) {
                     let ctx = match mutbl {
                         Mutability::Not => {
                             PlaceContext::NonMutatingUse(NonMutatingUseContext::AddressOf)
@@ -313,7 +313,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
 
             Rvalue::Ref(_, kind @ BorrowKind::Mut { .. }, ref place)
             | Rvalue::Ref(_, kind @ BorrowKind::Unique, ref place) => {
-                let ty = place.ty(*self.body, self.tcx).ty;
+                let ty = place.ty(self.body, self.tcx).ty;
                 let is_allowed = match ty.kind {
                     // Inside a `static mut`, `&mut [...]` is allowed.
                     ty::Array(..) | ty::Slice(_) if self.const_kind() == ConstKind::StaticMut => {
@@ -355,7 +355,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
             }
 
             Rvalue::Cast(CastKind::Misc, ref operand, cast_ty) => {
-                let operand_ty = operand.ty(*self.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");
 
@@ -365,7 +365,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
             }
 
             Rvalue::BinaryOp(op, ref lhs, _) => {
-                if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(*self.body, self.tcx).kind {
+                if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(self.body, self.tcx).kind {
                     assert!(
                         op == BinOp::Eq
                             || op == BinOp::Ne
@@ -426,7 +426,7 @@ fn visit_projection_elem(
 
         match elem {
             ProjectionElem::Deref => {
-                let base_ty = Place::ty_from(place_local, proj_base, *self.body, self.tcx).ty;
+                let base_ty = Place::ty_from(place_local, proj_base, self.body, self.tcx).ty;
                 if let ty::RawPtr(_) = base_ty.kind {
                     if proj_base.is_empty() {
                         if let (local, []) = (place_local, proj_base) {
@@ -450,7 +450,7 @@ fn visit_projection_elem(
             | ProjectionElem::Subslice { .. }
             | ProjectionElem::Field(..)
             | ProjectionElem::Index(_) => {
-                let base_ty = Place::ty_from(place_local, proj_base, *self.body, self.tcx).ty;
+                let base_ty = Place::ty_from(place_local, proj_base, self.body, self.tcx).ty;
                 match base_ty.ty_adt_def() {
                     Some(def) if def.is_union() => {
                         self.check_op(ops::UnionAccess);
@@ -498,7 +498,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
 
         match &terminator.kind {
             TerminatorKind::Call { func, .. } => {
-                let fn_ty = func.ty(*self.body, self.tcx);
+                let fn_ty = func.ty(self.body, self.tcx);
 
                 let (def_id, substs) = match fn_ty.kind {
                     ty::FnDef(def_id, substs) => (def_id, substs),
@@ -553,7 +553,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
                 // 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, self.tcx).ty.needs_drop(self.tcx, self.param_env);
+                    dropped_place.ty(self.body, self.tcx).ty.needs_drop(self.tcx, self.param_env);
 
                 if !ty_needs_drop {
                     return;
index 6f67ef92da4b14f4fae054c88601f6d77db9c183..c1705b0ff7e0b60e0e28243200caf9f553e928fe 100644 (file)
@@ -468,7 +468,7 @@ fn dest_needs_borrow(place: Place<'_>) -> bool {
                         destination.0,
                     );
 
-                    let ty = dest.ty(&**caller_body, self.tcx);
+                    let ty = dest.ty(caller_body, self.tcx);
 
                     let temp = LocalDecl::new_temp(ty, callsite.location.span);
 
@@ -568,7 +568,7 @@ fn make_call_args(
             assert!(args.next().is_none());
 
             let tuple = Place::from(tuple);
-            let tuple_tys = if let ty::Tuple(s) = tuple.ty(&**caller_body, tcx).ty.kind {
+            let tuple_tys = if let ty::Tuple(s) = tuple.ty(caller_body, tcx).ty.kind {
                 s
             } else {
                 bug!("Closure arguments are not passed as a tuple");
@@ -619,7 +619,7 @@ fn create_temp_if_necessary(
         // Otherwise, create a temporary for the arg
         let arg = Rvalue::Use(arg);
 
-        let ty = arg.ty(&**caller_body, self.tcx);
+        let ty = arg.ty(caller_body, self.tcx);
 
         let arg_tmp = LocalDecl::new_temp(ty, callsite.location.span);
         let arg_tmp = caller_body.local_decls.push(arg_tmp);
index dd63fdf5e26ed69034703f969ea8a7ec25d48a96..9c18a298b24ffda7b41b786600dd1a517e64142f 100644 (file)
@@ -329,7 +329,7 @@ fn validate_candidate(&self, candidate: Candidate) -> Result<(), Unpromotable> {
                                 // FIXME(eddyb) this is probably excessive, with
                                 // the exception of `union` member accesses.
                                 let ty =
-                                    Place::ty_from(place.local, proj_base, *self.body, self.tcx)
+                                    Place::ty_from(place.local, proj_base, self.body, self.tcx)
                                         .projection_ty(self.tcx, elem)
                                         .ty;
                                 if ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) {
@@ -350,7 +350,7 @@ fn validate_candidate(&self, candidate: Candidate) -> Result<(), Unpromotable> {
                         }
 
                         if let BorrowKind::Mut { .. } = kind {
-                            let ty = place.ty(*self.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 []
@@ -494,7 +494,7 @@ fn validate_place(&self, place: PlaceRef<'tcx>) -> Result<(), Unpromotable> {
                     ProjectionElem::Field(..) => {
                         if self.const_kind.is_none() {
                             let base_ty =
-                                Place::ty_from(place.local, proj_base, *self.body, self.tcx).ty;
+                                Place::ty_from(place.local, 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() {
@@ -539,7 +539,7 @@ fn validate_operand(&self, operand: &Operand<'tcx>) -> Result<(), Unpromotable>
     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, 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) {
@@ -552,7 +552,7 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
             }
 
             Rvalue::BinaryOp(op, ref lhs, _) if self.const_kind.is_none() => {
-                if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(*self.body, self.tcx).kind {
+                if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(self.body, self.tcx).kind {
                     assert!(
                         op == BinOp::Eq
                             || op == BinOp::Ne
@@ -592,7 +592,7 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
                 // Raw reborrows can come from reference to pointer coercions,
                 // so are allowed.
                 if let [proj_base @ .., ProjectionElem::Deref] = place.projection.as_ref() {
-                    let base_ty = Place::ty_from(place.local, proj_base, *self.body, self.tcx).ty;
+                    let base_ty = Place::ty_from(place.local, proj_base, self.body, self.tcx).ty;
                     if let ty::Ref(..) = base_ty.kind {
                         return self.validate_place(PlaceRef {
                             local: place.local,
@@ -605,7 +605,7 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
 
             Rvalue::Ref(_, kind, place) => {
                 if let BorrowKind::Mut { .. } = kind {
-                    let ty = place.ty(*self.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 []
@@ -631,7 +631,7 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
                 // Special-case reborrows to be more like a copy of the reference.
                 let mut place = place.as_ref();
                 if let [proj_base @ .., ProjectionElem::Deref] = &place.projection {
-                    let base_ty = Place::ty_from(place.local, proj_base, *self.body, self.tcx).ty;
+                    let base_ty = Place::ty_from(place.local, proj_base, self.body, self.tcx).ty;
                     if let ty::Ref(..) = base_ty.kind {
                         place = PlaceRef { local: place.local, projection: proj_base };
                     }
@@ -650,7 +650,7 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
                     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.local, proj_base, *self.body, self.tcx)
+                        let ty = Place::ty_from(place.local, proj_base, self.body, self.tcx)
                             .projection_ty(self.tcx, elem)
                             .ty;
                         if ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) {
@@ -683,7 +683,7 @@ fn validate_call(
         callee: &Operand<'tcx>,
         args: &[Operand<'tcx>],
     ) -> Result<(), Unpromotable> {
-        let fn_ty = callee.ty(*self.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 {