diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 5e8495ceddd9..f19a8658a057 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -51,13 +51,13 @@ fn owned_ptr_base_path<'a, 'tcx>(loan_path: &'a LoanPath<'tcx>) -> &'a LoanPath< match loan_path.kind { LpVar(_) | LpUpvar(_) => None, LpExtend(ref lp_base, _, LpDeref(mc::Unique)) => { - match helper(&**lp_base) { + match helper(&lp_base) { v @ Some(_) => v, - None => Some(&**lp_base) + None => Some(&lp_base) } } LpDowncast(ref lp_base, _) | - LpExtend(ref lp_base, _, _) => helper(&**lp_base) + LpExtend(ref lp_base, _, _) => helper(&lp_base) } } } @@ -319,7 +319,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { } LpDowncast(ref lp_base, _) | LpExtend(ref lp_base, _, _) => { - loan_path = &**lp_base; + loan_path = &lp_base; } } @@ -442,21 +442,21 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { // borrow prevents subsequent moves, borrows, or modification of `x` until the // borrow ends - let common = new_loan.loan_path.common(&*old_loan.loan_path); + let common = new_loan.loan_path.common(&old_loan.loan_path); let (nl, ol, new_loan_msg, old_loan_msg) = - if new_loan.loan_path.has_fork(&*old_loan.loan_path) && common.is_some() { + if new_loan.loan_path.has_fork(&old_loan.loan_path) && common.is_some() { let nl = self.bccx.loan_path_to_string(&common.unwrap()); let ol = nl.clone(); let new_loan_msg = format!(" (here through borrowing `{}`)", self.bccx.loan_path_to_string( - &*new_loan.loan_path)); + &new_loan.loan_path)); let old_loan_msg = format!(" (through borrowing `{}`)", self.bccx.loan_path_to_string( - &*old_loan.loan_path)); + &old_loan.loan_path)); (nl, ol, new_loan_msg, old_loan_msg) } else { - (self.bccx.loan_path_to_string(&*new_loan.loan_path), - self.bccx.loan_path_to_string(&*old_loan.loan_path), + (self.bccx.loan_path_to_string(&new_loan.loan_path), + self.bccx.loan_path_to_string(&old_loan.loan_path), String::new(), String::new()) }; @@ -578,7 +578,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { Some(lp) => { let moved_value_use_kind = match mode { euv::Copy => { - self.check_for_copy_of_frozen_path(id, span, &*lp); + self.check_for_copy_of_frozen_path(id, span, &lp); MovedInUse } euv::Move(_) => { @@ -593,7 +593,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { } Some(move_kind) => { self.check_for_move_of_borrowed_path(id, span, - &*lp, move_kind); + &lp, move_kind); if move_kind == move_data::Captured { MovedInCapture } else { @@ -622,7 +622,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { &self.bccx.loan_path_to_string(copy_path)) .span_note(loan_span, &format!("borrow of `{}` occurs here", - &self.bccx.loan_path_to_string(&*loan_path)) + &self.bccx.loan_path_to_string(&loan_path)) ) .emit(); } @@ -656,7 +656,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { err.span_note( loan_span, &format!("borrow of `{}` occurs here", - &self.bccx.loan_path_to_string(&*loan_path)) + &self.bccx.loan_path_to_string(&loan_path)) ); err.emit(); } @@ -706,7 +706,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { self.bccx.report_use_of_moved_value( span, use_kind, - &**lp, + &lp, the_move, moved_lp, self.param_env); @@ -760,7 +760,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { self.bccx .report_partial_reinitialization_of_uninitialized_structure( span, - &*loan_path); + &loan_path); false }); return; @@ -790,8 +790,8 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { // Check that we don't invalidate any outstanding loans if let Some(loan_path) = opt_loan_path(&assignee_cmt) { let scope = self.tcx().region_maps.node_extent(assignment_id); - self.each_in_scope_loan_affecting_path(scope, &*loan_path, |loan| { - self.report_illegal_mutation(assignment_span, &*loan_path, loan); + self.each_in_scope_loan_affecting_path(scope, &loan_path, |loan| { + self.report_illegal_mutation(assignment_span, &loan_path, loan); false }); } @@ -807,7 +807,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { } else { self.bccx.report_reassigned_immutable_variable( assignment_span, - &*lp, + &lp, assign); } false diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index 8cf10cb9b05a..38157d04a5d6 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -386,11 +386,11 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { let gen_scope = self.compute_gen_scope(borrow_scope, loan_scope); debug!("gen_scope = {:?}", gen_scope); - let kill_scope = self.compute_kill_scope(loan_scope, &*loan_path); + let kill_scope = self.compute_kill_scope(loan_scope, &loan_path); debug!("kill_scope = {:?}", kill_scope); if req_kind == ty::MutBorrow { - self.mark_loan_path_as_mutated(&*loan_path); + self.mark_loan_path_as_mutated(&loan_path); } Loan { @@ -452,7 +452,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { LpDowncast(ref base, _) | LpExtend(ref base, mc::McInherited, _) | LpExtend(ref base, mc::McDeclared, _) => { - self.mark_loan_path_as_mutated(&**base); + self.mark_loan_path_as_mutated(&base); } LpExtend(_, mc::McImmutable, _) => { // Nothing to do. @@ -527,7 +527,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for StaticInitializerCtxt<'a, 'tcx> { if let hir::ExprAddrOf(mutbl, ref base) = ex.node { let infcx = infer::new_infer_ctxt(self.bccx.tcx, &self.bccx.tcx.tables, None); let mc = mc::MemCategorizationContext::new(&infcx); - let base_cmt = mc.cat_expr(&**base).unwrap(); + let base_cmt = mc.cat_expr(&base).unwrap(); let borrow_kind = ty::BorrowKind::from_mutbl(mutbl); // Check that we don't allow borrows of unsafe static items. if check_aliasability(self.bccx, ex.span, diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 3ca9a1768648..1fa36a98ec5d 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -85,14 +85,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> { fn visit_trait_item(&mut self, ti: &hir::TraitItem) { if let hir::ConstTraitItem(_, Some(ref expr)) = ti.node { - gather_loans::gather_loans_in_static_initializer(self, &*expr); + gather_loans::gather_loans_in_static_initializer(self, &expr); } intravisit::walk_trait_item(self, ti); } fn visit_impl_item(&mut self, ii: &hir::ImplItem) { if let hir::ImplItemKind::Const(_, ref expr) = ii.node { - gather_loans::gather_loans_in_static_initializer(self, &*expr); + gather_loans::gather_loans_in_static_initializer(self, &expr); } intravisit::walk_impl_item(self, ii); } @@ -139,7 +139,7 @@ fn borrowck_item(this: &mut BorrowckCtxt, item: &hir::Item) { match item.node { hir::ItemStatic(_, _, ref ex) | hir::ItemConst(_, ref ex) => { - gather_loans::gather_loans_in_static_initializer(this, &**ex); + gather_loans::gather_loans_in_static_initializer(this, &ex); } _ => { } } @@ -251,9 +251,9 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>( let dataflow_data = build_borrowck_dataflow_data(&mut bccx, fn_parts.kind, - &*fn_parts.decl, + &fn_parts.decl, cfg, - &*fn_parts.body, + &fn_parts.body, fn_parts.span, fn_parts.id); @@ -426,12 +426,12 @@ impl<'tcx> LoanPath<'tcx> { (&LpExtend(ref base, _, LpInterior(opt_variant_id, id)), &LpExtend(ref base2, _, LpInterior(opt_variant_id2, id2))) => if id == id2 && opt_variant_id == opt_variant_id2 { - base.has_fork(&**base2) + base.has_fork(&base2) } else { true }, (&LpExtend(ref base, _, LpDeref(_)), _) => base.has_fork(other), - (_, &LpExtend(ref base, _, LpDeref(_))) => self.has_fork(&**base), + (_, &LpExtend(ref base, _, LpDeref(_))) => self.has_fork(&base), _ => false, } } @@ -449,7 +449,7 @@ impl<'tcx> LoanPath<'tcx> { (&LpExtend(ref base, a, LpInterior(opt_variant_id, id)), &LpExtend(ref base2, _, LpInterior(opt_variant_id2, id2))) => { if id == id2 && opt_variant_id == opt_variant_id2 { - base.common(&**base2).map(|x| { + base.common(&base2).map(|x| { let xd = x.depth(); if base.depth() == xd && base2.depth() == xd { assert_eq!(base.ty, base2.ty); @@ -463,11 +463,11 @@ impl<'tcx> LoanPath<'tcx> { } }) } else { - base.common(&**base2) + base.common(&base2) } } (&LpExtend(ref base, _, LpDeref(_)), _) => base.common(other), - (_, &LpExtend(ref other, _, LpDeref(_))) => self.common(&**other), + (_, &LpExtend(ref other, _, LpDeref(_))) => self.common(&other), (&LpVar(id), &LpVar(id2)) => { if id == id2 { assert_eq!(self.ty, other.ty); @@ -673,7 +673,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { .map .find(the_move.id) { Some(hir_map::NodeExpr(expr)) => { - (self.tcx.expr_ty_adjusted(&*expr), expr.span) + (self.tcx.expr_ty_adjusted(&expr), expr.span) } r => { self.tcx.sess.bug(&format!("MoveExpr({}) maps to \ @@ -735,7 +735,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { .map .find(the_move.id) { Some(hir_map::NodeExpr(expr)) => { - (self.tcx.expr_ty_adjusted(&*expr), expr.span) + (self.tcx.expr_ty_adjusted(&expr), expr.span) } r => { self.tcx.sess.bug(&format!("Captured({}) maps to \ @@ -833,19 +833,19 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { err_mutbl => { let descr = match err.cmt.note { mc::NoteClosureEnv(_) | mc::NoteUpvarRef(_) => { - self.cmt_to_string(&*err.cmt) + self.cmt_to_string(&err.cmt) } _ => match opt_loan_path(&err.cmt) { None => { format!("{} {}", err.cmt.mutbl.to_user_str(), - self.cmt_to_string(&*err.cmt)) + self.cmt_to_string(&err.cmt)) } Some(lp) => { format!("{} {} `{}`", err.cmt.mutbl.to_user_str(), - self.cmt_to_string(&*err.cmt), - self.loan_path_to_string(&*lp)) + self.cmt_to_string(&err.cmt), + self.loan_path_to_string(&lp)) } } }; @@ -876,7 +876,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { let msg = match opt_loan_path(&err.cmt) { None => "borrowed value".to_string(), Some(lp) => { - format!("`{}`", self.loan_path_to_string(&*lp)) + format!("`{}`", self.loan_path_to_string(&lp)) } }; format!("{} does not live long enough", msg) @@ -1051,9 +1051,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { err_borrowed_pointer_too_short(loan_scope, ptr_scope) => { let descr = match opt_loan_path(&err.cmt) { Some(lp) => { - format!("`{}`", self.loan_path_to_string(&*lp)) + format!("`{}`", self.loan_path_to_string(&lp)) } - None => self.cmt_to_string(&*err.cmt), + None => self.cmt_to_string(&err.cmt), }; self.tcx.note_and_explain_region( db, @@ -1081,7 +1081,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { LpDowncast(ref lp_base, variant_def_id) => { out.push('('); - self.append_loan_path_to_string(&**lp_base, out); + self.append_loan_path_to_string(&lp_base, out); out.push_str(DOWNCAST_PRINTED_OPERATOR); out.push_str(&self.tcx.item_path_str(variant_def_id)); out.push(')'); @@ -1089,7 +1089,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { LpExtend(ref lp_base, _, LpInterior(_, InteriorField(fname))) => { - self.append_autoderefd_loan_path_to_string(&**lp_base, out); + self.append_autoderefd_loan_path_to_string(&lp_base, out); match fname { mc::NamedField(fname) => { out.push('.'); @@ -1103,13 +1103,13 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } LpExtend(ref lp_base, _, LpInterior(_, InteriorElement(..))) => { - self.append_autoderefd_loan_path_to_string(&**lp_base, out); + self.append_autoderefd_loan_path_to_string(&lp_base, out); out.push_str("[..]"); } LpExtend(ref lp_base, _, LpDeref(_)) => { out.push('*'); - self.append_loan_path_to_string(&**lp_base, out); + self.append_loan_path_to_string(&lp_base, out); } } } @@ -1122,12 +1122,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { // For a path like `(*x).f` or `(*x)[3]`, autoderef // rules would normally allow users to omit the `*x`. // So just serialize such paths to `x.f` or x[3]` respectively. - self.append_autoderefd_loan_path_to_string(&**lp_base, out) + self.append_autoderefd_loan_path_to_string(&lp_base, out) } LpDowncast(ref lp_base, variant_def_id) => { out.push('('); - self.append_autoderefd_loan_path_to_string(&**lp_base, out); + self.append_autoderefd_loan_path_to_string(&lp_base, out); out.push(':'); out.push_str(&self.tcx.item_path_str(variant_def_id)); out.push(')'); diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index 735e618cc732..cbec32e358d8 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -207,7 +207,7 @@ fn loan_path_is_precise(loan_path: &LoanPath) -> bool { } LpDowncast(ref lp_base, _) | LpExtend(ref lp_base, _, _) => { - loan_path_is_precise(&**lp_base) + loan_path_is_precise(&lp_base) } } } @@ -587,7 +587,7 @@ impl<'tcx> MoveData<'tcx> { // assignment referring to another location. let loan_path = self.path_loan_path(path); - if loan_path_is_precise(&*loan_path) { + if loan_path_is_precise(&loan_path) { self.each_applicable_move(path, |move_index| { debug!("kill_moves add_kill {:?} kill_id={} move_index={}", kill_kind, kill_id, move_index.get()); @@ -700,7 +700,7 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> { if base_indices.iter().any(|x| x == &moved_path) { // Scenario 1 or 2: `loan_path` or some base path of // `loan_path` was moved. - if !f(the_move, &*self.move_data.path_loan_path(moved_path)) { + if !f(the_move, &self.move_data.path_loan_path(moved_path)) { ret = false; } } else { @@ -710,7 +710,7 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> { // Scenario 3: some extension of `loan_path` // was moved f(the_move, - &*self.move_data.path_loan_path(moved_path)) + &self.move_data.path_loan_path(moved_path)) } else { true } diff --git a/src/librustc_borrowck/graphviz.rs b/src/librustc_borrowck/graphviz.rs index eb63f572649a..7a5491cdbe7f 100644 --- a/src/librustc_borrowck/graphviz.rs +++ b/src/librustc_borrowck/graphviz.rs @@ -87,7 +87,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> { if saw_some { set.push_str(", "); } - let loan_str = self.borrowck_ctxt.loan_path_to_string(&*lp); + let loan_str = self.borrowck_ctxt.loan_path_to_string(&lp); set.push_str(&loan_str[..]); saw_some = true; true