1
Fork 0

Rollup merge of #69787 - spastorino:use-local-directly-its-copy, r=oli-obk

mir::Local is Copy we can pass it by value in these cases

r? @oli-obk
This commit is contained in:
Mazdak Farrokhzad 2020-03-07 17:27:34 +01:00 committed by GitHub
commit f1f4864de3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View file

@ -888,7 +888,7 @@ macro_rules! visit_place_fns {
() => ( () => (
fn visit_projection( fn visit_projection(
&mut self, &mut self,
local: &Local, local: Local,
projection: &[PlaceElem<'tcx>], projection: &[PlaceElem<'tcx>],
context: PlaceContext, context: PlaceContext,
location: Location, location: Location,
@ -898,7 +898,7 @@ macro_rules! visit_place_fns {
fn visit_projection_elem( fn visit_projection_elem(
&mut self, &mut self,
local: &Local, local: Local,
proj_base: &[PlaceElem<'tcx>], proj_base: &[PlaceElem<'tcx>],
elem: &PlaceElem<'tcx>, elem: &PlaceElem<'tcx>,
context: PlaceContext, context: PlaceContext,
@ -925,7 +925,7 @@ macro_rules! visit_place_fns {
self.visit_place_base(&place.local, context, location); self.visit_place_base(&place.local, context, location);
self.visit_projection(&place.local, self.visit_projection(place.local,
&place.projection, &place.projection,
context, context,
location); location);
@ -933,7 +933,7 @@ macro_rules! visit_place_fns {
fn super_projection( fn super_projection(
&mut self, &mut self,
local: &Local, local: Local,
projection: &[PlaceElem<'tcx>], projection: &[PlaceElem<'tcx>],
context: PlaceContext, context: PlaceContext,
location: Location, location: Location,
@ -947,7 +947,7 @@ macro_rules! visit_place_fns {
fn super_projection_elem( fn super_projection_elem(
&mut self, &mut self,
_local: &Local, _local: Local,
_proj_base: &[PlaceElem<'tcx>], _proj_base: &[PlaceElem<'tcx>],
elem: &PlaceElem<'tcx>, elem: &PlaceElem<'tcx>,
_context: PlaceContext, _context: PlaceContext,

View file

@ -203,7 +203,7 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
} }
self.visit_place_base(&place_ref.local, context, location); self.visit_place_base(&place_ref.local, context, location);
self.visit_projection(&place_ref.local, place_ref.projection, context, location); self.visit_projection(place_ref.local, place_ref.projection, context, location);
} }
} }
} }

View file

@ -276,7 +276,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
} }
}; };
self.visit_place_base(&place.local, ctx, location); self.visit_place_base(&place.local, ctx, location);
self.visit_projection(&place.local, reborrowed_proj, ctx, location); self.visit_projection(place.local, reborrowed_proj, ctx, location);
return; return;
} }
} }
@ -289,7 +289,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
Mutability::Mut => PlaceContext::MutatingUse(MutatingUseContext::AddressOf), Mutability::Mut => PlaceContext::MutatingUse(MutatingUseContext::AddressOf),
}; };
self.visit_place_base(&place.local, ctx, location); self.visit_place_base(&place.local, ctx, location);
self.visit_projection(&place.local, reborrowed_proj, ctx, location); self.visit_projection(place.local, reborrowed_proj, ctx, location);
return; return;
} }
} }
@ -408,7 +408,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
} }
fn visit_projection_elem( fn visit_projection_elem(
&mut self, &mut self,
place_local: &Local, place_local: Local,
proj_base: &[PlaceElem<'tcx>], proj_base: &[PlaceElem<'tcx>],
elem: &PlaceElem<'tcx>, elem: &PlaceElem<'tcx>,
context: PlaceContext, context: PlaceContext,
@ -428,11 +428,11 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
match elem { match elem {
ProjectionElem::Deref => { 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 let ty::RawPtr(_) = base_ty.kind {
if proj_base.is_empty() { if proj_base.is_empty() {
if let (local, []) = (place_local, proj_base) { if let (local, []) = (place_local, proj_base) {
let decl = &self.body.local_decls[*local]; let decl = &self.body.local_decls[local];
if let LocalInfo::StaticRef { def_id, .. } = decl.local_info { if let LocalInfo::StaticRef { def_id, .. } = decl.local_info {
let span = decl.source_info.span; let span = decl.source_info.span;
self.check_static(def_id, span); self.check_static(def_id, span);
@ -452,7 +452,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
| ProjectionElem::Subslice { .. } | ProjectionElem::Subslice { .. }
| ProjectionElem::Field(..) | ProjectionElem::Field(..)
| ProjectionElem::Index(_) => { | 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() { match base_ty.ty_adt_def() {
Some(def) if def.is_union() => { Some(def) if def.is_union() => {
self.check_op(ops::UnionAccess); self.check_op(ops::UnionAccess);