From 795d96d87b5ed28e090a7d9ad883b08eb926607b Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sun, 21 Jul 2019 22:38:30 +0200 Subject: [PATCH] Place::as_place_ref is now Place::as_ref --- src/librustc/mir/mod.rs | 2 +- src/librustc_codegen_ssa/mir/analyze.rs | 2 +- src/librustc_codegen_ssa/mir/block.rs | 8 +-- src/librustc_codegen_ssa/mir/operand.rs | 2 +- src/librustc_codegen_ssa/mir/rvalue.rs | 6 +-- src/librustc_codegen_ssa/mir/statement.rs | 6 +-- .../borrow_check/conflict_errors.rs | 54 +++++++++---------- .../borrow_check/error_reporting.rs | 4 +- src/librustc_mir/borrow_check/mod.rs | 18 +++---- src/librustc_mir/borrow_check/move_errors.rs | 24 ++++----- .../borrow_check/mutability_errors.rs | 8 +-- .../borrow_check/nll/explain_borrow/mod.rs | 4 +- src/librustc_mir/borrow_check/path_utils.rs | 2 +- .../borrow_check/places_conflict.rs | 2 +- src/librustc_mir/build/matches/mod.rs | 2 +- .../dataflow/drop_flag_effects.rs | 2 +- src/librustc_mir/dataflow/impls/mod.rs | 6 +-- .../dataflow/move_paths/builder.rs | 10 ++-- src/librustc_mir/transform/add_retag.rs | 2 +- src/librustc_mir/transform/elaborate_drops.rs | 12 ++--- src/librustc_mir/transform/qualify_consts.rs | 6 +-- src/librustc_mir/transform/rustc_peek.rs | 4 +- 22 files changed, 93 insertions(+), 93 deletions(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index d8b641fbe31..75f03949d99 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1931,7 +1931,7 @@ fn iterate_over2<'tcx, R>( iterate_over2(place_base, place_projection, &Projections::Empty, op) } - pub fn as_place_ref(&self) -> PlaceRef<'_, 'tcx> { + pub fn as_ref(&self) -> PlaceRef<'_, 'tcx> { PlaceRef { base: &self.base, projection: &self.projection, diff --git a/src/librustc_codegen_ssa/mir/analyze.rs b/src/librustc_codegen_ssa/mir/analyze.rs index 09c346117f9..907689541f9 100644 --- a/src/librustc_codegen_ssa/mir/analyze.rs +++ b/src/librustc_codegen_ssa/mir/analyze.rs @@ -238,7 +238,7 @@ fn visit_place(&mut self, context: PlaceContext, location: Location) { debug!("visit_place(place={:?}, context={:?})", place, context); - self.process_place(&place.as_place_ref(), context, location); + self.process_place(&place.as_ref(), context, location); } fn visit_local(&mut self, diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index d4b434ffe80..54afefd1a64 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -253,7 +253,7 @@ fn codegen_return_terminator(&mut self, mut bx: Bx) { PassMode::Direct(_) | PassMode::Pair(..) => { let op = - self.codegen_consume(&mut bx, &mir::Place::RETURN_PLACE.as_place_ref()); + self.codegen_consume(&mut bx, &mir::Place::RETURN_PLACE.as_ref()); if let Ref(llval, _, align) = op.val { bx.load(llval, align) } else { @@ -314,7 +314,7 @@ fn codegen_drop_terminator<'b>( return } - let place = self.codegen_place(&mut bx, &location.as_place_ref()); + let place = self.codegen_place(&mut bx, &location.as_ref()); let (args1, args2); let mut args = if let Some(llextra) = place.llextra { args2 = [place.llval, llextra]; @@ -1171,7 +1171,7 @@ fn codegen_transmute( LocalRef::Place(place) => self.codegen_transmute_into(bx, src, place), LocalRef::UnsizedPlace(_) => bug!("transmute must not involve unsized locals"), LocalRef::Operand(None) => { - let dst_layout = bx.layout_of(self.monomorphized_place_ty(&dst.as_place_ref())); + let dst_layout = bx.layout_of(self.monomorphized_place_ty(&dst.as_ref())); assert!(!dst_layout.ty.has_erasable_regions()); let place = PlaceRef::alloca(bx, dst_layout, "transmute_temp"); place.storage_live(bx); @@ -1186,7 +1186,7 @@ fn codegen_transmute( } } } else { - let dst = self.codegen_place(bx, &dst.as_place_ref()); + let dst = self.codegen_place(bx, &dst.as_ref()); self.codegen_transmute_into(bx, src, dst); } } diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index 0f6a95c1968..302dcfcc682 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -462,7 +462,7 @@ pub fn codegen_operand( match *operand { mir::Operand::Copy(ref place) | mir::Operand::Move(ref place) => { - self.codegen_consume(bx, &place.as_place_ref()) + self.codegen_consume(bx, &place.as_ref()) } mir::Operand::Constant(ref constant) => { diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index cfb7db73658..202cf147f1f 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -355,7 +355,7 @@ pub fn codegen_rvalue_operand( } mir::Rvalue::Ref(_, bk, ref place) => { - let cg_place = self.codegen_place(&mut bx, &place.as_place_ref()); + let cg_place = self.codegen_place(&mut bx, &place.as_ref()); let ty = cg_place.layout.ty; @@ -446,7 +446,7 @@ pub fn codegen_rvalue_operand( mir::Rvalue::Discriminant(ref place) => { let discr_ty = rvalue.ty(&*self.mir, bx.tcx()); - let discr = self.codegen_place(&mut bx, &place.as_place_ref()) + let discr = self.codegen_place(&mut bx, &place.as_ref()) .codegen_get_discr(&mut bx, discr_ty); (bx, OperandRef { val: OperandValue::Immediate(discr), @@ -527,7 +527,7 @@ fn evaluate_array_len( } } // use common size calculation for non zero-sized types - let cg_value = self.codegen_place(bx, &place.as_place_ref()); + let cg_value = self.codegen_place(bx, &place.as_ref()); cg_value.len(bx.cx()) } diff --git a/src/librustc_codegen_ssa/mir/statement.rs b/src/librustc_codegen_ssa/mir/statement.rs index 499cda1cf84..3717be4b417 100644 --- a/src/librustc_codegen_ssa/mir/statement.rs +++ b/src/librustc_codegen_ssa/mir/statement.rs @@ -46,12 +46,12 @@ pub fn codegen_statement( } } } else { - let cg_dest = self.codegen_place(&mut bx, &place.as_place_ref()); + let cg_dest = self.codegen_place(&mut bx, &place.as_ref()); self.codegen_rvalue(bx, cg_dest, rvalue) } } mir::StatementKind::SetDiscriminant{ref place, variant_index} => { - self.codegen_place(&mut bx, &place.as_place_ref()) + self.codegen_place(&mut bx, &place.as_ref()) .codegen_set_discr(&mut bx, variant_index); bx } @@ -73,7 +73,7 @@ pub fn codegen_statement( } mir::StatementKind::InlineAsm(ref asm) => { let outputs = asm.outputs.iter().map(|output| { - self.codegen_place(&mut bx, &output.as_place_ref()) + self.codegen_place(&mut bx, &output.as_ref()) }).collect(); let input_vals = asm.inputs.iter() diff --git a/src/librustc_mir/borrow_check/conflict_errors.rs b/src/librustc_mir/borrow_check/conflict_errors.rs index 95fc22dc5eb..5d0e490ebea 100644 --- a/src/librustc_mir/borrow_check/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/conflict_errors.rs @@ -139,14 +139,14 @@ pub(super) fn report_use_of_moved_or_uninitialized( let is_partial_move = move_site_vec.iter().any(|move_site| { let move_out = self.move_data.moves[(*move_site).moi]; let moved_place = &self.move_data.move_paths[move_out.path].place; - used_place != moved_place.as_place_ref() - && used_place.is_prefix_of(moved_place.as_place_ref()) + used_place != moved_place.as_ref() + && used_place.is_prefix_of(moved_place.as_ref()) }); for move_site in &move_site_vec { let move_out = self.move_data.moves[(*move_site).moi]; let moved_place = &self.move_data.move_paths[move_out.path].place; - let move_spans = self.move_spans(moved_place.as_place_ref(), move_out.source); + let move_spans = self.move_spans(moved_place.as_ref(), move_out.source); let move_span = move_spans.args_or_use(); let move_msg = if move_spans.for_closure() { @@ -223,7 +223,7 @@ pub(super) fn report_use_of_moved_or_uninitialized( let ty = place.ty(self.body, self.infcx.tcx).ty; let opt_name = - self.describe_place_with_options(place.as_place_ref(), IncludingDowncast(true)); + self.describe_place_with_options(place.as_ref(), IncludingDowncast(true)); let note_msg = match opt_name { Some(ref name) => format!("`{}`", name), None => "value".to_owned(), @@ -275,11 +275,11 @@ pub(super) fn report_move_out_while_borrowed( "report_move_out_while_borrowed: location={:?} place={:?} span={:?} borrow={:?}", location, place, span, borrow ); - let value_msg = match self.describe_place(place.as_place_ref()) { + let value_msg = match self.describe_place(place.as_ref()) { Some(name) => format!("`{}`", name), None => "value".to_owned(), }; - let borrow_msg = match self.describe_place(borrow.borrowed_place.as_place_ref()) { + let borrow_msg = match self.describe_place(borrow.borrowed_place.as_ref()) { Some(name) => format!("`{}`", name), None => "value".to_owned(), }; @@ -287,12 +287,12 @@ pub(super) fn report_move_out_while_borrowed( let borrow_spans = self.retrieve_borrow_spans(borrow); let borrow_span = borrow_spans.args_or_use(); - let move_spans = self.move_spans(place.as_place_ref(), location); + let move_spans = self.move_spans(place.as_ref(), location); let span = move_spans.args_or_use(); let mut err = self.cannot_move_when_borrowed( span, - &self.describe_place(place.as_place_ref()).unwrap_or_else(|| "_".to_owned()), + &self.describe_place(place.as_ref()).unwrap_or_else(|| "_".to_owned()), ); err.span_label(borrow_span, format!("borrow of {} occurs here", borrow_msg)); err.span_label(span, format!("move out of {} occurs here", value_msg)); @@ -326,21 +326,21 @@ pub(super) fn report_use_while_mutably_borrowed( // Conflicting borrows are reported separately, so only check for move // captures. - let use_spans = self.move_spans(place.as_place_ref(), location); + let use_spans = self.move_spans(place.as_ref(), location); let span = use_spans.var_or_use(); let mut err = self.cannot_use_when_mutably_borrowed( span, - &self.describe_place(place.as_place_ref()).unwrap_or_else(|| "_".to_owned()), + &self.describe_place(place.as_ref()).unwrap_or_else(|| "_".to_owned()), borrow_span, - &self.describe_place(borrow.borrowed_place.as_place_ref()) + &self.describe_place(borrow.borrowed_place.as_ref()) .unwrap_or_else(|| "_".to_owned()), ); borrow_spans.var_span_label(&mut err, { let place = &borrow.borrowed_place; let desc_place = - self.describe_place(place.as_place_ref()).unwrap_or_else(|| "_".to_owned()); + self.describe_place(place.as_ref()).unwrap_or_else(|| "_".to_owned()); format!("borrow occurs due to use of `{}`{}", desc_place, borrow_spans.describe()) }); @@ -517,7 +517,7 @@ pub(super) fn report_conflicting_borrow( ); } else { let borrow_place = &issued_borrow.borrowed_place; - let borrow_place_desc = self.describe_place(borrow_place.as_place_ref()) + let borrow_place_desc = self.describe_place(borrow_place.as_ref()) .unwrap_or_else(|| "_".to_owned()); issued_spans.var_span_label( &mut err, @@ -650,8 +650,8 @@ pub(super) fn describe_place_for_conflicting_borrow( return Some(( describe_base_place, - describe_place(first_borrowed_place.as_place_ref()), - describe_place(second_borrowed_place.as_place_ref()), + describe_place(first_borrowed_place.as_ref()), + describe_place(second_borrowed_place.as_ref()), union_ty.to_string(), )); } @@ -666,7 +666,7 @@ pub(super) fn describe_place_for_conflicting_borrow( // If we didn't find a field access into a union, or both places match, then // only return the description of the first place. ( - describe_place(first_borrowed_place.as_place_ref()), + describe_place(first_borrowed_place.as_ref()), "".to_string(), "".to_string(), "".to_string(), @@ -697,7 +697,7 @@ pub(super) fn report_borrowed_value_does_not_live_long_enough( ); let drop_span = place_span.1; - let root_place = self.prefixes(borrow.borrowed_place.as_place_ref(), PrefixSet::All) + let root_place = self.prefixes(borrow.borrowed_place.as_ref(), PrefixSet::All) .last() .unwrap(); @@ -730,13 +730,13 @@ pub(super) fn report_borrowed_value_does_not_live_long_enough( }, borrow_span)); if let StorageDeadOrDrop::Destructor(dropped_ty) = - self.classify_drop_access_kind(borrow.borrowed_place.as_place_ref()) + self.classify_drop_access_kind(borrow.borrowed_place.as_ref()) { // If a borrow of path `B` conflicts with drop of `D` (and // we're not in the uninteresting case where `B` is a // prefix of `D`), then report this as a more interesting // destructor conflict. - if !borrow.borrowed_place.as_place_ref().is_prefix_of(place_span.0.as_place_ref()) { + if !borrow.borrowed_place.as_ref().is_prefix_of(place_span.0.as_ref()) { self.report_borrow_conflicts_with_destructor( location, borrow, place_span, kind, dropped_ty, ); @@ -744,7 +744,7 @@ pub(super) fn report_borrowed_value_does_not_live_long_enough( } } - let place_desc = self.describe_place(borrow.borrowed_place.as_place_ref()); + let place_desc = self.describe_place(borrow.borrowed_place.as_ref()); let kind_place = kind.filter(|_| place_desc.is_some()).map(|k| (k, place_span.0)); let explanation = self.explain_why_borrow_contains_point(location, &borrow, kind_place); @@ -951,12 +951,12 @@ fn report_borrow_conflicts_with_destructor( let mut err = self.cannot_borrow_across_destructor(borrow_span); - let what_was_dropped = match self.describe_place(place.as_place_ref()) { + let what_was_dropped = match self.describe_place(place.as_ref()) { Some(name) => format!("`{}`", name.as_str()), None => String::from("temporary value"), }; - let label = match self.describe_place(borrow.borrowed_place.as_place_ref()) { + let label = match self.describe_place(borrow.borrowed_place.as_ref()) { Some(borrowed) => format!( "here, drop of {D} needs exclusive access to `{B}`, \ because the type `{T}` implements the `Drop` trait", @@ -1127,7 +1127,7 @@ fn try_report_cannot_return_reference_to_local( format!("`{}` is borrowed here", place_desc), ) } else { - let root_place = self.prefixes(borrow.borrowed_place.as_place_ref(), + let root_place = self.prefixes(borrow.borrowed_place.as_ref(), PrefixSet::All) .last() .unwrap(); @@ -1390,7 +1390,7 @@ pub(super) fn report_illegal_mutation_of_borrowed( let mut err = self.cannot_mutate_in_match_guard( span, loan_span, - &self.describe_place(place.as_place_ref()).unwrap_or_else(|| "_".to_owned()), + &self.describe_place(place.as_ref()).unwrap_or_else(|| "_".to_owned()), "assign", ); loan_spans.var_span_label( @@ -1406,7 +1406,7 @@ pub(super) fn report_illegal_mutation_of_borrowed( let mut err = self.cannot_assign_to_borrowed( span, loan_span, - &self.describe_place(place.as_place_ref()).unwrap_or_else(|| "_".to_owned()), + &self.describe_place(place.as_ref()).unwrap_or_else(|| "_".to_owned()), ); loan_spans.var_span_label( @@ -1466,8 +1466,8 @@ pub(super) fn report_illegal_reassignment( is_user_variable: None, .. }) - | None => (self.describe_place(place.as_place_ref()), assigned_span), - Some(decl) => (self.describe_place(err_place.as_place_ref()), decl.source_info.span), + | None => (self.describe_place(place.as_ref()), assigned_span), + Some(decl) => (self.describe_place(err_place.as_ref()), decl.source_info.span), }; let mut err = self.cannot_reassign_immutable( diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 156897aedb7..a05c77aad67 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -855,7 +855,7 @@ pub(super) fn borrow_spans(&self, use_span: Span, location: Location) -> UseSpan def_id, is_generator, places ); if let Some((args_span, var_span)) = self.closure_span( - *def_id, Place::from(target).as_place_ref(), places + *def_id, Place::from(target).as_ref(), places ) { return ClosureUse { is_generator, @@ -895,7 +895,7 @@ fn closure_span( for (upvar, place) in self.infcx.tcx.upvars(def_id)?.values().zip(places) { match place { Operand::Copy(place) | - Operand::Move(place) if target_place == place.as_place_ref() => { + Operand::Move(place) if target_place == place.as_ref() => { debug!("closure_span: found captured local {:?}", place); return Some((*args_span, upvar.span)); }, diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index cfc7e77f4e5..5ec1e514100 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -560,7 +560,7 @@ fn visit_statement_entry( self.check_if_path_or_subpath_is_moved( location, InitializationRequiringAction::Use, - (place.as_place_ref(), span), + (place.as_ref(), span), flow_state, ); } @@ -591,7 +591,7 @@ fn visit_statement_entry( self.check_if_path_or_subpath_is_moved( location, InitializationRequiringAction::Use, - (output.as_place_ref(), o.span), + (output.as_ref(), o.span), flow_state, ); } else { @@ -1154,7 +1154,7 @@ fn mutate_place( self.check_if_path_or_subpath_is_moved( location, InitializationRequiringAction::Update, - (place_span.0.as_place_ref(), place_span.1), + (place_span.0.as_ref(), place_span.1), flow_state, ); } @@ -1232,7 +1232,7 @@ fn consume_rvalue( self.check_if_path_or_subpath_is_moved( location, action, - (place.as_place_ref(), span), + (place.as_ref(), span), flow_state, ); } @@ -1260,7 +1260,7 @@ fn consume_rvalue( self.check_if_path_or_subpath_is_moved( location, InitializationRequiringAction::Use, - (place.as_place_ref(), span), + (place.as_ref(), span), flow_state, ); } @@ -1309,7 +1309,7 @@ fn consume_rvalue( fn propagate_closure_used_mut_upvar(&mut self, operand: &Operand<'tcx>) { let propagate_closure_used_mut_place = |this: &mut Self, place: &Place<'tcx>| { if place.projection.is_some() { - if let Some(field) = this.is_upvar_field_projection(place.as_place_ref()) { + if let Some(field) = this.is_upvar_field_projection(place.as_ref()) { this.used_mut_upvars.push(field); } } else if let PlaceBase::Local(local) = place.base { @@ -1401,7 +1401,7 @@ fn consume_operand( self.check_if_path_or_subpath_is_moved( location, InitializationRequiringAction::Use, - (place.as_place_ref(), span), + (place.as_ref(), span), flow_state, ); } @@ -1419,7 +1419,7 @@ fn consume_operand( self.check_if_path_or_subpath_is_moved( location, InitializationRequiringAction::Use, - (place.as_place_ref(), span), + (place.as_ref(), span), flow_state, ); } @@ -1437,7 +1437,7 @@ fn check_for_invalidation_at_exit( ) { debug!("check_for_invalidation_at_exit({:?})", borrow); let place = &borrow.borrowed_place; - let root_place = self.prefixes(place.as_place_ref(), PrefixSet::All).last().unwrap(); + let root_place = self.prefixes(place.as_ref(), PrefixSet::All).last().unwrap(); // FIXME(nll-rfc#40): do more precise destructor tracking here. For now // we just know that all locals are dropped at function exit (otherwise diff --git a/src/librustc_mir/borrow_check/move_errors.rs b/src/librustc_mir/borrow_check/move_errors.rs index 38653dc0e5e..738a091b0dd 100644 --- a/src/librustc_mir/borrow_check/move_errors.rs +++ b/src/librustc_mir/borrow_check/move_errors.rs @@ -131,7 +131,7 @@ fn append_to_grouped_errors( } } - let move_spans = self.move_spans(original_path.as_place_ref(), location); + let move_spans = self.move_spans(original_path.as_ref(), location); grouped_errors.push(GroupedMoveError::OtherIllegalMove { use_spans: move_spans, original_path, @@ -160,7 +160,7 @@ fn append_binding_error( let from_simple_let = match_place.is_none(); let match_place = match_place.as_ref().unwrap_or(move_from); - match self.move_data.rev_lookup.find(match_place.as_place_ref()) { + match self.move_data.rev_lookup.find(match_place.as_ref()) { // Error with the match place LookupResult::Parent(_) => { for ge in &mut *grouped_errors { @@ -192,7 +192,7 @@ fn append_binding_error( } // Error with the pattern LookupResult::Exact(_) => { - let mpi = match self.move_data.rev_lookup.find(move_from.as_place_ref()) { + let mpi = match self.move_data.rev_lookup.find(move_from.as_ref()) { LookupResult::Parent(Some(mpi)) => mpi, // move_from should be a projection from match_place. _ => unreachable!("Probably not unreachable..."), @@ -242,7 +242,7 @@ fn report(&mut self, error: GroupedMoveError<'tcx>) { }; debug!("report: original_path={:?} span={:?}, kind={:?} \ original_path.is_upvar_field_projection={:?}", original_path, span, kind, - self.is_upvar_field_projection(original_path.as_place_ref())); + self.is_upvar_field_projection(original_path.as_ref())); ( match kind { IllegalMoveOriginKind::Static => { @@ -277,7 +277,7 @@ fn report_cannot_move_from_static( span: Span ) -> DiagnosticBuilder<'a> { let description = if place.projection.is_none() { - format!("static item `{}`", self.describe_place(place.as_place_ref()).unwrap()) + format!("static item `{}`", self.describe_place(place.as_ref()).unwrap()) } else { let mut base_static = &place.projection; while let Some(box Projection { base: Some(ref proj), .. }) = base_static { @@ -290,7 +290,7 @@ fn report_cannot_move_from_static( format!( "`{:?}` as `{:?}` is a static item", - self.describe_place(place.as_place_ref()).unwrap(), + self.describe_place(place.as_ref()).unwrap(), self.describe_place(base_static).unwrap(), ) }; @@ -308,7 +308,7 @@ fn report_cannot_move_from_borrowed_content( // 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 upvar_field = self.prefixes(move_place.as_place_ref(), PrefixSet::All) + let upvar_field = self.prefixes(move_place.as_ref(), PrefixSet::All) .find_map(|p| self.is_upvar_field_projection(p)); let deref_base = match deref_target_place.projection { @@ -363,10 +363,10 @@ fn report_cannot_move_from_borrowed_content( let upvar_name = upvar.name; let upvar_span = self.infcx.tcx.hir().span(upvar_hir_id); - let place_name = self.describe_place(move_place.as_place_ref()).unwrap(); + let place_name = self.describe_place(move_place.as_ref()).unwrap(); let place_description = if self - .is_upvar_field_projection(move_place.as_place_ref()) + .is_upvar_field_projection(move_place.as_ref()) .is_some() { format!("`{}`, a {}", place_name, capture_description) @@ -393,7 +393,7 @@ fn report_cannot_move_from_borrowed_content( _ => { let source = self.borrowed_content_source(deref_base); match ( - self.describe_place(move_place.as_place_ref()), + self.describe_place(move_place.as_ref()), source.describe_for_named_place(), ) { (Some(place_desc), Some(source_desc)) => { @@ -455,7 +455,7 @@ fn add_move_hints( if binds_to.is_empty() { let place_ty = move_from.ty(self.body, self.infcx.tcx).ty; - let place_desc = match self.describe_place(move_from.as_place_ref()) { + let place_desc = match self.describe_place(move_from.as_ref()) { Some(desc) => format!("`{}`", desc), None => format!("value"), }; @@ -483,7 +483,7 @@ fn add_move_hints( 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_desc = match self.describe_place(original_path.as_place_ref()) { + let place_desc = match self.describe_place(original_path.as_ref()) { Some(desc) => format!("`{}`", desc), None => format!("value"), }; diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index c424c06c41a..937c6383be3 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -42,7 +42,7 @@ pub(super) fn report_mutability_error( let item_msg; let reason; let mut opt_source = None; - let access_place_desc = self.describe_place(access_place.as_place_ref()); + let access_place_desc = self.describe_place(access_place.as_ref()); debug!("report_mutability_error: access_place_desc={:?}", access_place_desc); match the_place_err { @@ -77,7 +77,7 @@ pub(super) fn report_mutability_error( )); item_msg = format!("`{}`", access_place_desc.unwrap()); - if self.is_upvar_field_projection(access_place.as_place_ref()).is_some() { + if self.is_upvar_field_projection(access_place.as_ref()).is_some() { reason = ", as it is not declared as mutable".to_string(); } else { let name = self.upvars[upvar_index.index()].name; @@ -109,7 +109,7 @@ pub(super) fn report_mutability_error( )); reason = - if self.is_upvar_field_projection(access_place.as_place_ref()).is_some() { + if self.is_upvar_field_projection(access_place.as_ref()).is_some() { ", as it is a captured variable in a `Fn` closure".to_string() } else { ", as `Fn` closures cannot mutate their captured variables".to_string() @@ -244,7 +244,7 @@ pub(super) fn report_mutability_error( format!( "mutable borrow occurs due to use of `{}` in closure", // always Some() if the message is printed. - self.describe_place(access_place.as_place_ref()).unwrap_or_default(), + self.describe_place(access_place.as_ref()).unwrap_or_default(), ) ); borrow_span diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs index abb84c59d9b..aba3ef1cbbf 100644 --- a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs +++ b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs @@ -252,7 +252,7 @@ pub(in crate::borrow_check) fn explain_why_borrow_contains_point( Some(Cause::LiveVar(local, location)) => { let span = body.source_info(location).span; let spans = self - .move_spans(Place::from(local).as_place_ref(), location) + .move_spans(Place::from(local).as_ref(), location) .or_else(|| self.borrow_spans(span, location)); let borrow_location = location; @@ -305,7 +305,7 @@ pub(in crate::borrow_check) fn explain_why_borrow_contains_point( ); if let Some(region_name) = region_name { let opt_place_desc = - self.describe_place(borrow.borrowed_place.as_place_ref()); + self.describe_place(borrow.borrowed_place.as_ref()); BorrowExplanation::MustBeValidFor { category, from_closure, diff --git a/src/librustc_mir/borrow_check/path_utils.rs b/src/librustc_mir/borrow_check/path_utils.rs index 75065816df0..da3f1654826 100644 --- a/src/librustc_mir/borrow_check/path_utils.rs +++ b/src/librustc_mir/borrow_check/path_utils.rs @@ -50,7 +50,7 @@ pub(super) fn each_borrow_involving_path<'tcx, F, I, S>( body, &borrowed.borrowed_place, borrowed.kind, - place.as_place_ref(), + place.as_ref(), access, places_conflict::PlaceConflictBias::Overlap, ) { diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs index 348214f97f2..b2a03147ecf 100644 --- a/src/librustc_mir/borrow_check/places_conflict.rs +++ b/src/librustc_mir/borrow_check/places_conflict.rs @@ -36,7 +36,7 @@ body, borrow_place, BorrowKind::Mut { allow_two_phase_borrow: true }, - access_place.as_place_ref(), + access_place.as_ref(), AccessDepth::Deep, bias, ) diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index b58cef9cce1..d72b0addae9 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -1304,7 +1304,7 @@ fn calculate_fake_borrows<'b>( prefix_cursor = base; } - all_fake_borrows.push(place.as_place_ref()); + all_fake_borrows.push(place.as_ref()); } // Deduplicate and ensure a deterministic order. diff --git a/src/librustc_mir/dataflow/drop_flag_effects.rs b/src/librustc_mir/dataflow/drop_flag_effects.rs index b6dd544d395..c071b3101fc 100644 --- a/src/librustc_mir/dataflow/drop_flag_effects.rs +++ b/src/librustc_mir/dataflow/drop_flag_effects.rs @@ -171,7 +171,7 @@ pub(crate) fn drop_flag_effects_for_function_entry<'tcx, F>( let move_data = &ctxt.move_data; for arg in body.args_iter() { let place = mir::Place::from(arg); - let lookup_result = move_data.rev_lookup.find(place.as_place_ref()); + let lookup_result = move_data.rev_lookup.find(place.as_ref()); on_lookup_result_bits(tcx, body, move_data, lookup_result, |mpi| callback(mpi, DropFlagState::Present)); diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index ade732bbb75..69bbe087921 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -309,7 +309,7 @@ fn propagate_call_return( // when a call returns successfully, that means we need to set // the bits for that dest_place to 1 (initialized). on_lookup_result_bits(self.tcx, self.body, self.move_data(), - self.move_data().rev_lookup.find(dest_place.as_place_ref()), + self.move_data().rev_lookup.find(dest_place.as_ref()), |mpi| { in_out.insert(mpi); }); } } @@ -367,7 +367,7 @@ fn propagate_call_return( // when a call returns successfully, that means we need to set // the bits for that dest_place to 0 (initialized). on_lookup_result_bits(self.tcx, self.body, self.move_data(), - self.move_data().rev_lookup.find(dest_place.as_place_ref()), + self.move_data().rev_lookup.find(dest_place.as_ref()), |mpi| { in_out.remove(mpi); }); } } @@ -423,7 +423,7 @@ fn propagate_call_return( // when a call returns successfully, that means we need to set // the bits for that dest_place to 1 (initialized). on_lookup_result_bits(self.tcx, self.body, self.move_data(), - self.move_data().rev_lookup.find(dest_place.as_place_ref()), + self.move_data().rev_lookup.find(dest_place.as_ref()), |mpi| { in_out.insert(mpi); }); } } diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 436ac30ffb4..366b96b53b4 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -274,9 +274,9 @@ fn gather_statement(&mut self, stmt: &Statement<'tcx>) { // move-path for the interior so it will be separate from // the exterior. self.create_move_path(&place.clone().deref()); - self.gather_init(place.as_place_ref(), InitKind::Shallow); + self.gather_init(place.as_ref(), InitKind::Shallow); } else { - self.gather_init(place.as_place_ref(), InitKind::Deep); + self.gather_init(place.as_ref(), InitKind::Deep); } self.gather_rvalue(rval); } @@ -286,7 +286,7 @@ fn gather_statement(&mut self, stmt: &Statement<'tcx>) { StatementKind::InlineAsm(ref asm) => { for (output, kind) in asm.outputs.iter().zip(&asm.asm.outputs) { if !kind.is_indirect { - self.gather_init(output.as_place_ref(), InitKind::Deep); + self.gather_init(output.as_ref(), InitKind::Deep); } } for (_, input) in asm.inputs.iter() { @@ -376,7 +376,7 @@ fn gather_terminator(&mut self, term: &Terminator<'tcx>) { TerminatorKind::DropAndReplace { ref location, ref value, .. } => { self.create_move_path(location); self.gather_operand(value); - self.gather_init(location.as_place_ref(), InitKind::Deep); + self.gather_init(location.as_ref(), InitKind::Deep); } TerminatorKind::Call { ref func, @@ -391,7 +391,7 @@ fn gather_terminator(&mut self, term: &Terminator<'tcx>) { } if let Some((ref destination, _bb)) = *destination { self.create_move_path(destination); - self.gather_init(destination.as_place_ref(), InitKind::NonPanicPathOnly); + self.gather_init(destination.as_ref(), InitKind::NonPanicPathOnly); } } } diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index 887f93c6478..d573423906c 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -79,7 +79,7 @@ fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, _src: MirSource<'tcx>, body: &mut Bo let needs_retag = |place: &Place<'tcx>| { // FIXME: Instead of giving up for unstable places, we should introduce // a temporary and retag on that. - is_stable(place.as_place_ref()) + is_stable(place.as_ref()) && may_have_reference(place.ty(&*local_decls, tcx).ty, tcx) }; diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 0748321f605..0a021d9b8fa 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -105,7 +105,7 @@ fn find_dead_unwinds<'tcx>( init_data.apply_location(tcx, body, env, loc); } - let path = match env.move_data.rev_lookup.find(location.as_place_ref()) { + let path = match env.move_data.rev_lookup.find(location.as_ref()) { LookupResult::Exact(e) => e, LookupResult::Parent(..) => { debug!("find_dead_unwinds: has parent; skipping"); @@ -360,7 +360,7 @@ fn collect_drop_flags(&mut self) statement_index: data.statements.len() }); - let path = self.move_data().rev_lookup.find(location.as_place_ref()); + let path = self.move_data().rev_lookup.find(location.as_ref()); debug!("collect_drop_flags: {:?}, place {:?} ({:?})", bb, location, path); @@ -399,7 +399,7 @@ fn elaborate_drops(&mut self) match terminator.kind { TerminatorKind::Drop { ref location, target, unwind } => { let init_data = self.initialization_data_at(loc); - match self.move_data().rev_lookup.find(location.as_place_ref()) { + match self.move_data().rev_lookup.find(location.as_ref()) { LookupResult::Exact(path) => { elaborate_drop( &mut Elaborator { @@ -488,7 +488,7 @@ fn elaborate_replace( is_cleanup: false, }); - match self.move_data().rev_lookup.find(location.as_place_ref()) { + match self.move_data().rev_lookup.find(location.as_ref()) { LookupResult::Exact(path) => { debug!("elaborate_drop_and_replace({:?}) - tracked {:?}", terminator, path); let init_data = self.initialization_data_at(loc); @@ -558,7 +558,7 @@ fn drop_flags_for_fn_rets(&mut self) { assert!(!self.patch.is_patched(bb)); let loc = Location { block: tgt, statement_index: 0 }; - let path = self.move_data().rev_lookup.find(place.as_place_ref()); + let path = self.move_data().rev_lookup.find(place.as_ref()); on_lookup_result_bits( self.tcx, self.body, self.move_data(), path, |child| self.set_drop_flag(loc, child, DropFlagState::Present) @@ -632,7 +632,7 @@ fn drop_flags_for_locs(&mut self) { assert!(!self.patch.is_patched(bb)); let loc = Location { block: bb, statement_index: data.statements.len() }; - let path = self.move_data().rev_lookup.find(place.as_place_ref()); + let path = self.move_data().rev_lookup.find(place.as_ref()); on_lookup_result_bits( self.tcx, self.body, self.move_data(), path, |child| self.set_drop_flag(loc, child, DropFlagState::Present) diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 739e2172b03..ffeaf4e19c2 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -243,7 +243,7 @@ fn in_place(cx: &ConstCx<'_, 'tcx>, place: PlaceRef<'_, 'tcx>) -> bool { fn in_operand(cx: &ConstCx<'_, 'tcx>, operand: &Operand<'tcx>) -> bool { match *operand { Operand::Copy(ref place) | - Operand::Move(ref place) => Self::in_place(cx, place.as_place_ref()), + Operand::Move(ref place) => Self::in_place(cx, place.as_ref()), Operand::Constant(ref constant) => { if let ConstValue::Unevaluated(def_id, _) = constant.literal.val { @@ -272,7 +272,7 @@ fn in_rvalue_structurally(cx: &ConstCx<'_, 'tcx>, rvalue: &Rvalue<'tcx>) -> bool Rvalue::NullaryOp(..) => false, Rvalue::Discriminant(ref place) | - Rvalue::Len(ref place) => Self::in_place(cx, place.as_place_ref()), + Rvalue::Len(ref place) => Self::in_place(cx, place.as_ref()), Rvalue::Use(ref operand) | Rvalue::Repeat(ref operand, _) | @@ -298,7 +298,7 @@ fn in_rvalue_structurally(cx: &ConstCx<'_, 'tcx>, rvalue: &Rvalue<'tcx>) -> bool } } - Self::in_place(cx, place.as_place_ref()) + Self::in_place(cx, place.as_ref()) } Rvalue::Aggregate(_, ref operands) => { diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index 1fd865c42fc..7fe8480c819 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -168,7 +168,7 @@ fn each_block<'tcx, O>( if place == peek_arg_place { if let mir::Rvalue::Ref(_, mir::BorrowKind::Shared, ref peeking_at_place) = **rvalue { // Okay, our search is over. - match move_data.rev_lookup.find(peeking_at_place.as_place_ref()) { + match move_data.rev_lookup.find(peeking_at_place.as_ref()) { LookupResult::Exact(peek_mpi) => { let bit_state = on_entry.contains(peek_mpi); debug!("rustc_peek({:?} = &{:?}) bit_state: {}", @@ -192,7 +192,7 @@ fn each_block<'tcx, O>( } } - let lhs_mpi = move_data.rev_lookup.find(place.as_place_ref()); + let lhs_mpi = move_data.rev_lookup.find(place.as_ref()); debug!("rustc_peek: computing effect on place: {:?} ({:?}) in stmt: {:?}", place, lhs_mpi, stmt); -- 2.44.0