From 5fc61657c9d3eb5e8fe140149b05aa2ff8ec28cf Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 8 Feb 2016 22:50:21 +0100 Subject: [PATCH 01/15] Make more use of autoderef in librustc_front --- src/librustc_front/print/pprust.rs | 201 ++++++++++++++--------------- src/librustc_front/util.rs | 16 +-- 2 files changed, 108 insertions(+), 109 deletions(-) diff --git a/src/librustc_front/print/pprust.rs b/src/librustc_front/print/pprust.rs index cc43e3ae56eaf..1425fbe9511a3 100644 --- a/src/librustc_front/print/pprust.rs +++ b/src/librustc_front/print/pprust.rs @@ -456,7 +456,7 @@ impl<'a> State<'a> { } pub fn commasep_exprs(&mut self, b: Breaks, exprs: &[P]) -> io::Result<()> { - self.commasep_cmnt(b, exprs, |s, e| s.print_expr(&**e), |e| e.span) + self.commasep_cmnt(b, exprs, |s, e| s.print_expr(&e), |e| e.span) } pub fn print_mod(&mut self, _mod: &hir::Mod, attrs: &[ast::Attribute]) -> io::Result<()> { @@ -492,7 +492,7 @@ impl<'a> State<'a> { match ty.node { hir::TyVec(ref ty) => { try!(word(&mut self.s, "[")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(word(&mut self.s, "]")); } hir::TyPtr(ref mt) => { @@ -501,7 +501,7 @@ impl<'a> State<'a> { hir::MutMutable => try!(self.word_nbsp("mut")), hir::MutImmutable => try!(self.word_nbsp("const")), } - try!(self.print_type(&*mt.ty)); + try!(self.print_type(&mt.ty)); } hir::TyRptr(ref lifetime, ref mt) => { try!(word(&mut self.s, "&")); @@ -510,7 +510,7 @@ impl<'a> State<'a> { } hir::TyTup(ref elts) => { try!(self.popen()); - try!(self.commasep(Inconsistent, &elts[..], |s, ty| s.print_type(&**ty))); + try!(self.commasep(Inconsistent, &elts[..], |s, ty| s.print_type(&ty))); if elts.len() == 1 { try!(word(&mut self.s, ",")); } @@ -525,7 +525,7 @@ impl<'a> State<'a> { predicates: hir::HirVec::new(), }, }; - try!(self.print_ty_fn(f.abi, f.unsafety, &*f.decl, None, &generics, None)); + try!(self.print_ty_fn(f.abi, f.unsafety, &f.decl, None, &generics, None)); } hir::TyPath(None, ref path) => { try!(self.print_path(path, false, 0)); @@ -534,7 +534,7 @@ impl<'a> State<'a> { try!(self.print_qpath(path, qself, false)) } hir::TyObjectSum(ref ty, ref bounds) => { - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(self.print_bounds("+", &bounds[..])); } hir::TyPolyTraitRef(ref bounds) => { @@ -542,14 +542,14 @@ impl<'a> State<'a> { } hir::TyFixedLengthVec(ref ty, ref v) => { try!(word(&mut self.s, "[")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(word(&mut self.s, "; ")); - try!(self.print_expr(&**v)); + try!(self.print_expr(&v)); try!(word(&mut self.s, "]")); } hir::TyTypeof(ref e) => { try!(word(&mut self.s, "typeof(")); - try!(self.print_expr(&**e)); + try!(self.print_expr(&e)); try!(word(&mut self.s, ")")); } hir::TyInfer => { @@ -585,7 +585,7 @@ impl<'a> State<'a> { } try!(self.print_name(item.name)); try!(self.word_space(":")); - try!(self.print_type(&**t)); + try!(self.print_type(&t)); try!(word(&mut self.s, ";")); try!(self.end()); // end the head-ibox self.end() // end the outer cbox @@ -667,7 +667,7 @@ impl<'a> State<'a> { } hir::ItemUse(ref vp) => { try!(self.head(&visibility_qualified(item.vis, "use"))); - try!(self.print_view_path(&**vp)); + try!(self.print_view_path(&vp)); try!(word(&mut self.s, ";")); try!(self.end()); // end inner head-block try!(self.end()); // end outer head-block @@ -679,12 +679,12 @@ impl<'a> State<'a> { } try!(self.print_name(item.name)); try!(self.word_space(":")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(space(&mut self.s)); try!(self.end()); // end the head-ibox try!(self.word_space("=")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(word(&mut self.s, ";")); try!(self.end()); // end the outer cbox } @@ -692,12 +692,12 @@ impl<'a> State<'a> { try!(self.head(&visibility_qualified(item.vis, "const"))); try!(self.print_name(item.name)); try!(self.word_space(":")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(space(&mut self.s)); try!(self.end()); // end the head-ibox try!(self.word_space("=")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(word(&mut self.s, ";")); try!(self.end()); // end the outer cbox } @@ -712,7 +712,7 @@ impl<'a> State<'a> { None, item.vis)); try!(word(&mut self.s, " ")); - try!(self.print_block_with_attrs(&**body, &item.attrs)); + try!(self.print_block_with_attrs(&body, &item.attrs)); } hir::ItemMod(ref _mod) => { try!(self.head(&visibility_qualified(item.vis, "mod"))); @@ -740,7 +740,7 @@ impl<'a> State<'a> { try!(self.print_where_clause(¶ms.where_clause)); try!(space(&mut self.s)); try!(self.word_space("=")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(word(&mut self.s, ";")); try!(self.end()); // end the outer ibox } @@ -796,7 +796,7 @@ impl<'a> State<'a> { &None => {} } - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(self.print_where_clause(&generics.where_clause)); try!(space(&mut self.s)); @@ -920,7 +920,7 @@ impl<'a> State<'a> { hir::UnnamedField(vis) => { try!(s.print_visibility(vis)); try!(s.maybe_print_comment(field.span.lo)); - s.print_type(&*field.node.ty) + s.print_type(&field.node.ty) } } })); @@ -948,7 +948,7 @@ impl<'a> State<'a> { try!(self.print_visibility(visibility)); try!(self.print_name(name)); try!(self.word_nbsp(":")); - try!(self.print_type(&*field.node.ty)); + try!(self.print_type(&field.node.ty)); try!(word(&mut self.s, ",")); } } @@ -966,12 +966,11 @@ impl<'a> State<'a> { Some(ref d) => { try!(space(&mut self.s)); try!(self.word_space("=")); - self.print_expr(&**d) + self.print_expr(&d) } _ => Ok(()), } } - pub fn print_method_sig(&mut self, name: ast::Name, m: &hir::MethodSig, @@ -1046,15 +1045,15 @@ impl<'a> State<'a> { try!(self.maybe_print_comment(st.span.lo)); match st.node { hir::StmtDecl(ref decl, _) => { - try!(self.print_decl(&**decl)); + try!(self.print_decl(&decl)); } hir::StmtExpr(ref expr, _) => { try!(self.space_if_not_bol()); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); } hir::StmtSemi(ref expr, _) => { try!(self.space_if_not_bol()); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(word(&mut self.s, ";")); } } @@ -1112,7 +1111,7 @@ impl<'a> State<'a> { match blk.expr { Some(ref expr) => { try!(self.space_if_not_bol()); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(self.maybe_print_trailing_comment(expr.span, Some(blk.span.hi))); } _ => (), @@ -1130,9 +1129,9 @@ impl<'a> State<'a> { try!(self.cbox(indent_unit - 1)); try!(self.ibox(0)); try!(word(&mut self.s, " else if ")); - try!(self.print_expr(&**i)); + try!(self.print_expr(&i)); try!(space(&mut self.s)); - try!(self.print_block(&**then)); + try!(self.print_block(&then)); self.print_else(e.as_ref().map(|e| &**e)) } // "final else" @@ -1140,7 +1139,7 @@ impl<'a> State<'a> { try!(self.cbox(indent_unit - 1)); try!(self.ibox(0)); try!(word(&mut self.s, " else ")); - self.print_block(&**b) + self.print_block(&b) } // BLEAH, constraints would be great here _ => { @@ -1230,7 +1229,7 @@ impl<'a> State<'a> { try!(s.ibox(indent_unit)); try!(s.print_name(field.name.node)); try!(s.word_space(":")); - try!(s.print_expr(&*field.expr)); + try!(s.print_expr(&field.expr)); s.end() }, |f| f.span)); @@ -1242,7 +1241,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)); } try!(word(&mut self.s, "..")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(self.end()); } _ => if !fields.is_empty() { @@ -1273,12 +1272,12 @@ impl<'a> State<'a> { args: &[P]) -> io::Result<()> { let base_args = &args[1..]; - try!(self.print_expr(&*args[0])); + try!(self.print_expr(&args[0])); try!(word(&mut self.s, ".")); try!(self.print_name(name.node)); if !tys.is_empty() { try!(word(&mut self.s, "::<")); - try!(self.commasep(Inconsistent, tys, |s, ty| s.print_type(&**ty))); + try!(self.commasep(Inconsistent, tys, |s, ty| s.print_type(&ty))); try!(word(&mut self.s, ">")); } self.print_call_post(base_args) @@ -1322,7 +1321,7 @@ impl<'a> State<'a> { try!(self.print_expr_vec(&exprs[..])); } hir::ExprRepeat(ref element, ref count) => { - try!(self.print_expr_repeat(&**element, &**count)); + try!(self.print_expr_repeat(&element, &count)); } hir::ExprStruct(ref path, ref fields, ref wth) => { try!(self.print_expr_struct(path, &fields[..], wth)); @@ -1331,36 +1330,36 @@ impl<'a> State<'a> { try!(self.print_expr_tup(&exprs[..])); } hir::ExprCall(ref func, ref args) => { - try!(self.print_expr_call(&**func, &args[..])); + try!(self.print_expr_call(&func, &args[..])); } hir::ExprMethodCall(name, ref tys, ref args) => { try!(self.print_expr_method_call(name, &tys[..], &args[..])); } hir::ExprBinary(op, ref lhs, ref rhs) => { - try!(self.print_expr_binary(op, &**lhs, &**rhs)); + try!(self.print_expr_binary(op, &lhs, &rhs)); } hir::ExprUnary(op, ref expr) => { - try!(self.print_expr_unary(op, &**expr)); + try!(self.print_expr_unary(op, &expr)); } hir::ExprAddrOf(m, ref expr) => { - try!(self.print_expr_addr_of(m, &**expr)); + try!(self.print_expr_addr_of(m, &expr)); } hir::ExprLit(ref lit) => { - try!(self.print_literal(&**lit)); + try!(self.print_literal(&lit)); } hir::ExprCast(ref expr, ref ty) => { - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(space(&mut self.s)); try!(self.word_space("as")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); } hir::ExprType(ref expr, ref ty) => { - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(self.word_space(":")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); } hir::ExprIf(ref test, ref blk, ref elseopt) => { - try!(self.print_if(&**test, &**blk, elseopt.as_ref().map(|e| &**e))); + try!(self.print_if(&test, &blk, elseopt.as_ref().map(|e| &**e))); } hir::ExprWhile(ref test, ref blk, opt_ident) => { if let Some(ident) = opt_ident { @@ -1368,9 +1367,9 @@ impl<'a> State<'a> { try!(self.word_space(":")); } try!(self.head("while")); - try!(self.print_expr(&**test)); + try!(self.print_expr(&test)); try!(space(&mut self.s)); - try!(self.print_block(&**blk)); + try!(self.print_block(&blk)); } hir::ExprLoop(ref blk, opt_ident) => { if let Some(ident) = opt_ident { @@ -1379,13 +1378,13 @@ impl<'a> State<'a> { } try!(self.head("loop")); try!(space(&mut self.s)); - try!(self.print_block(&**blk)); + try!(self.print_block(&blk)); } hir::ExprMatch(ref expr, ref arms, _) => { try!(self.cbox(indent_unit)); try!(self.ibox(4)); try!(self.word_nbsp("match")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(space(&mut self.s)); try!(self.bopen()); for arm in arms { @@ -1396,7 +1395,7 @@ impl<'a> State<'a> { hir::ExprClosure(capture_clause, ref decl, ref body) => { try!(self.print_capture_clause(capture_clause)); - try!(self.print_fn_block_args(&**decl)); + try!(self.print_fn_block_args(&decl)); try!(space(&mut self.s)); let default_return = match decl.output { @@ -1405,12 +1404,12 @@ impl<'a> State<'a> { }; if !default_return || !body.stmts.is_empty() || body.expr.is_none() { - try!(self.print_block_unclosed(&**body)); + try!(self.print_block_unclosed(&body)); } else { // we extract the block, so as not to create another set of boxes match body.expr.as_ref().unwrap().node { hir::ExprBlock(ref blk) => { - try!(self.print_block_unclosed(&**blk)); + try!(self.print_block_unclosed(&blk)); } _ => { // this is a bare expression @@ -1429,44 +1428,44 @@ impl<'a> State<'a> { try!(self.cbox(indent_unit)); // head-box, will be closed by print-block after { try!(self.ibox(0)); - try!(self.print_block(&**blk)); + try!(self.print_block(&blk)); } hir::ExprAssign(ref lhs, ref rhs) => { - try!(self.print_expr(&**lhs)); + try!(self.print_expr(&lhs)); try!(space(&mut self.s)); try!(self.word_space("=")); - try!(self.print_expr(&**rhs)); + try!(self.print_expr(&rhs)); } hir::ExprAssignOp(op, ref lhs, ref rhs) => { - try!(self.print_expr(&**lhs)); + try!(self.print_expr(&lhs)); try!(space(&mut self.s)); try!(word(&mut self.s, ::util::binop_to_string(op.node))); try!(self.word_space("=")); - try!(self.print_expr(&**rhs)); + try!(self.print_expr(&rhs)); } hir::ExprField(ref expr, name) => { - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(word(&mut self.s, ".")); try!(self.print_name(name.node)); } hir::ExprTupField(ref expr, id) => { - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(word(&mut self.s, ".")); try!(self.print_usize(id.node)); } hir::ExprIndex(ref expr, ref index) => { - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(word(&mut self.s, "[")); - try!(self.print_expr(&**index)); + try!(self.print_expr(&index)); try!(word(&mut self.s, "]")); } hir::ExprRange(ref start, ref end) => { if let &Some(ref e) = start { - try!(self.print_expr(&**e)); + try!(self.print_expr(&e)); } try!(word(&mut self.s, "..")); if let &Some(ref e) = end { - try!(self.print_expr(&**e)); + try!(self.print_expr(&e)); } } hir::ExprPath(None, ref path) => { @@ -1496,7 +1495,7 @@ impl<'a> State<'a> { match *result { Some(ref expr) => { try!(word(&mut self.s, " ")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); } _ => (), } @@ -1515,7 +1514,7 @@ impl<'a> State<'a> { _ => try!(s.print_string(&out.constraint, ast::StrStyle::Cooked)), } try!(s.popen()); - try!(s.print_expr(&*out.expr)); + try!(s.print_expr(&out.expr)); try!(s.pclose()); Ok(()) })); @@ -1525,7 +1524,7 @@ impl<'a> State<'a> { try!(self.commasep(Inconsistent, &a.inputs, |s, &(ref co, ref o)| { try!(s.print_string(&co, ast::StrStyle::Cooked)); try!(s.popen()); - try!(s.print_expr(&**o)); + try!(s.print_expr(&o)); try!(s.pclose()); Ok(()) })); @@ -1551,7 +1550,7 @@ impl<'a> State<'a> { if !options.is_empty() { try!(space(&mut self.s)); try!(self.word_space(":")); - try!(self.commasep(Inconsistent, &*options, |s, &co| { + try!(self.commasep(Inconsistent, &options, |s, &co| { try!(s.print_string(co, ast::StrStyle::Cooked)); Ok(()) })); @@ -1565,10 +1564,10 @@ impl<'a> State<'a> { } pub fn print_local_decl(&mut self, loc: &hir::Local) -> io::Result<()> { - try!(self.print_pat(&*loc.pat)); + try!(self.print_pat(&loc.pat)); if let Some(ref ty) = loc.ty { try!(self.word_space(":")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); } Ok(()) } @@ -1582,12 +1581,12 @@ impl<'a> State<'a> { try!(self.word_nbsp("let")); try!(self.ibox(indent_unit)); - try!(self.print_local_decl(&**loc)); + try!(self.print_local_decl(&loc)); try!(self.end()); if let Some(ref init) = loc.init { try!(self.nbsp()); try!(self.word_space("=")); - try!(self.print_expr(&**init)); + try!(self.print_expr(&init)); } self.end() } @@ -1685,7 +1684,7 @@ impl<'a> State<'a> { if comma { try!(self.word_space(",")) } - try!(self.commasep(Inconsistent, &data.types, |s, ty| s.print_type(&**ty))); + try!(self.commasep(Inconsistent, &data.types, |s, ty| s.print_type(&ty))); comma = true; } @@ -1696,7 +1695,7 @@ impl<'a> State<'a> { try!(self.print_name(binding.name)); try!(space(&mut self.s)); try!(self.word_space("=")); - try!(self.print_type(&*binding.ty)); + try!(self.print_type(&binding.ty)); comma = true; } @@ -1705,7 +1704,7 @@ impl<'a> State<'a> { hir::ParenthesizedParameters(ref data) => { try!(word(&mut self.s, "(")); - try!(self.commasep(Inconsistent, &data.inputs, |s, ty| s.print_type(&**ty))); + try!(self.commasep(Inconsistent, &data.inputs, |s, ty| s.print_type(&ty))); try!(word(&mut self.s, ")")); match data.output { @@ -1713,7 +1712,7 @@ impl<'a> State<'a> { Some(ref ty) => { try!(self.space_if_not_bol()); try!(self.word_space("->")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); } } } @@ -1744,7 +1743,7 @@ impl<'a> State<'a> { match *sub { Some(ref p) => { try!(word(&mut self.s, "@")); - try!(self.print_pat(&**p)); + try!(self.print_pat(&p)); } None => (), } @@ -1756,7 +1755,7 @@ impl<'a> State<'a> { Some(ref args) => { if !args.is_empty() { try!(self.popen()); - try!(self.commasep(Inconsistent, &args[..], |s, p| s.print_pat(&**p))); + try!(self.commasep(Inconsistent, &args[..], |s, p| s.print_pat(&p))); try!(self.pclose()); } } @@ -1777,7 +1776,7 @@ impl<'a> State<'a> { try!(s.print_name(f.node.name)); try!(s.word_nbsp(":")); } - try!(s.print_pat(&*f.node.pat)); + try!(s.print_pat(&f.node.pat)); s.end() }, |f| f.node.pat.span)); @@ -1792,7 +1791,7 @@ impl<'a> State<'a> { } hir::PatTup(ref elts) => { try!(self.popen()); - try!(self.commasep(Inconsistent, &elts[..], |s, p| s.print_pat(&**p))); + try!(self.commasep(Inconsistent, &elts[..], |s, p| s.print_pat(&p))); if elts.len() == 1 { try!(word(&mut self.s, ",")); } @@ -1800,38 +1799,38 @@ impl<'a> State<'a> { } hir::PatBox(ref inner) => { try!(word(&mut self.s, "box ")); - try!(self.print_pat(&**inner)); + try!(self.print_pat(&inner)); } hir::PatRegion(ref inner, mutbl) => { try!(word(&mut self.s, "&")); if mutbl == hir::MutMutable { try!(word(&mut self.s, "mut ")); } - try!(self.print_pat(&**inner)); + try!(self.print_pat(&inner)); } - hir::PatLit(ref e) => try!(self.print_expr(&**e)), + hir::PatLit(ref e) => try!(self.print_expr(&e)), hir::PatRange(ref begin, ref end) => { - try!(self.print_expr(&**begin)); + try!(self.print_expr(&begin)); try!(space(&mut self.s)); try!(word(&mut self.s, "...")); - try!(self.print_expr(&**end)); + try!(self.print_expr(&end)); } hir::PatVec(ref before, ref slice, ref after) => { try!(word(&mut self.s, "[")); - try!(self.commasep(Inconsistent, &before[..], |s, p| s.print_pat(&**p))); + try!(self.commasep(Inconsistent, &before[..], |s, p| s.print_pat(&p))); if let Some(ref p) = *slice { if !before.is_empty() { try!(self.word_space(",")); } if p.node != hir::PatWild { - try!(self.print_pat(&**p)); + try!(self.print_pat(&p)); } try!(word(&mut self.s, "..")); if !after.is_empty() { try!(self.word_space(",")); } } - try!(self.commasep(Inconsistent, &after[..], |s, p| s.print_pat(&**p))); + try!(self.commasep(Inconsistent, &after[..], |s, p| s.print_pat(&p))); try!(word(&mut self.s, "]")); } } @@ -1855,12 +1854,12 @@ impl<'a> State<'a> { try!(space(&mut self.s)); try!(self.word_space("|")); } - try!(self.print_pat(&**p)); + try!(self.print_pat(&p)); } try!(space(&mut self.s)); if let Some(ref e) = arm.guard { try!(self.word_space("if")); - try!(self.print_expr(&**e)); + try!(self.print_expr(&e)); try!(space(&mut self.s)); } try!(self.word_space("=>")); @@ -1868,7 +1867,7 @@ impl<'a> State<'a> { match arm.body.node { hir::ExprBlock(ref blk) => { // the block will close the pattern's ibox - try!(self.print_block_unclosed_indent(&**blk, indent_unit)); + try!(self.print_block_unclosed_indent(&blk, indent_unit)); // If it is a user-provided unsafe block, print a comma after it if let hir::UnsafeBlock(hir::UserProvided) = blk.rules { @@ -1877,7 +1876,7 @@ impl<'a> State<'a> { } _ => { try!(self.end()); // close the ibox for the pattern - try!(self.print_expr(&*arm.body)); + try!(self.print_expr(&arm.body)); try!(word(&mut self.s, ",")); } } @@ -1906,7 +1905,7 @@ impl<'a> State<'a> { hir::SelfExplicit(ref typ, _) => { try!(word(&mut self.s, "self")); try!(self.word_space(":")); - try!(self.print_type(&**typ)); + try!(self.print_type(&typ)); } } return Ok(true); @@ -1999,7 +1998,7 @@ impl<'a> State<'a> { try!(self.word_space("->")); match decl.output { hir::Return(ref ty) => { - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); self.maybe_print_comment(ty.span.lo) } hir::DefaultReturn(..) => unreachable!(), @@ -2098,7 +2097,7 @@ impl<'a> State<'a> { Some(ref default) => { try!(space(&mut self.s)); try!(self.word_space("=")); - self.print_type(&**default) + self.print_type(&default) } _ => Ok(()), } @@ -2123,7 +2122,7 @@ impl<'a> State<'a> { ref bounds, ..}) => { try!(self.print_formal_lifetime_list(bound_lifetimes)); - try!(self.print_type(&**bounded_ty)); + try!(self.print_type(&bounded_ty)); try!(self.print_bounds(":", bounds)); } &hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate{ref lifetime, @@ -2144,7 +2143,7 @@ impl<'a> State<'a> { try!(self.print_path(path, false, 0)); try!(space(&mut self.s)); try!(self.word_space("=")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); } } } @@ -2202,13 +2201,13 @@ impl<'a> State<'a> { pub fn print_mt(&mut self, mt: &hir::MutTy) -> io::Result<()> { try!(self.print_mutability(mt.mutbl)); - self.print_type(&*mt.ty) + self.print_type(&mt.ty) } pub fn print_arg(&mut self, input: &hir::Arg, is_closure: bool) -> io::Result<()> { try!(self.ibox(indent_unit)); match input.ty.node { - hir::TyInfer if is_closure => try!(self.print_pat(&*input.pat)), + hir::TyInfer if is_closure => try!(self.print_pat(&input.pat)), _ => { match input.pat.node { hir::PatIdent(_, ref path1, _) if @@ -2217,12 +2216,12 @@ impl<'a> State<'a> { // Do nothing. } _ => { - try!(self.print_pat(&*input.pat)); + try!(self.print_pat(&input.pat)); try!(word(&mut self.s, ":")); try!(space(&mut self.s)); } } - try!(self.print_type(&*input.ty)); + try!(self.print_type(&input.ty)); } } self.end() @@ -2239,7 +2238,7 @@ impl<'a> State<'a> { match decl.output { hir::NoReturn(_) => try!(self.word_nbsp("!")), hir::DefaultReturn(..) => unreachable!(), - hir::Return(ref ty) => try!(self.print_type(&**ty)), + hir::Return(ref ty) => try!(self.print_type(&ty)), } try!(self.end()); @@ -2414,7 +2413,7 @@ fn stmt_ends_with_semi(stmt: &hir::Stmt_) -> bool { } } hir::StmtExpr(ref e, _) => { - expr_requires_semi_to_be_stmt(&**e) + expr_requires_semi_to_be_stmt(&e) } hir::StmtSemi(..) => { false diff --git a/src/librustc_front/util.rs b/src/librustc_front/util.rs index 57ffefd3be435..5d936fae6ec0a 100644 --- a/src/librustc_front/util.rs +++ b/src/librustc_front/util.rs @@ -23,25 +23,25 @@ pub fn walk_pat(pat: &Pat, mut it: F) -> bool fn walk_pat_(pat: &Pat, it: &mut G) -> bool where G: FnMut(&Pat) -> bool { - if !(*it)(pat) { + if !it(pat) { return false; } match pat.node { - PatIdent(_, _, Some(ref p)) => walk_pat_(&**p, it), + PatIdent(_, _, Some(ref p)) => walk_pat_(&p, it), PatStruct(_, ref fields, _) => { - fields.iter().all(|field| walk_pat_(&*field.node.pat, it)) + fields.iter().all(|field| walk_pat_(&field.node.pat, it)) } PatEnum(_, Some(ref s)) | PatTup(ref s) => { - s.iter().all(|p| walk_pat_(&**p, it)) + s.iter().all(|p| walk_pat_(&p, it)) } PatBox(ref s) | PatRegion(ref s, _) => { - walk_pat_(&**s, it) + walk_pat_(&s, it) } PatVec(ref before, ref slice, ref after) => { - before.iter().all(|p| walk_pat_(&**p, it)) && - slice.iter().all(|p| walk_pat_(&**p, it)) && - after.iter().all(|p| walk_pat_(&**p, it)) + before.iter().all(|p| walk_pat_(&p, it)) && + slice.iter().all(|p| walk_pat_(&p, it)) && + after.iter().all(|p| walk_pat_(&p, it)) } PatWild | PatLit(_) | From 2b69c989eeb5ceb30399a93ede049936a7bf0c5b Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 8 Feb 2016 23:42:39 +0100 Subject: [PATCH 02/15] Use more autoderef in rustc_driver --- src/librustc_driver/driver.rs | 2 +- src/librustc_driver/lib.rs | 2 +- src/librustc_driver/pretty.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 6c5b577e0d1a4..43871e7321836 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -567,7 +567,7 @@ pub fn phase_2_configure_and_expand(sess: &Session, // Lint plugins are registered; now we can process command line flags. if sess.opts.describe_lints { - super::describe_lints(&*sess.lint_store.borrow(), true); + super::describe_lints(&sess.lint_store.borrow(), true); return Err(0); } try!(sess.track_errors(|| sess.lint_store.borrow_mut().process_command_line(sess))); diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 25cef24c50d5e..faf11de53c43a 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1018,7 +1018,7 @@ pub fn diagnostics_registry() -> diagnostics::registry::Registry { all_errors.extend_from_slice(&rustc_privacy::DIAGNOSTICS); all_errors.extend_from_slice(&rustc_trans::DIAGNOSTICS); - Registry::new(&*all_errors) + Registry::new(&all_errors) } pub fn main() { diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 170ae65f91906..4a82aa7282599 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -870,8 +870,8 @@ fn print_flowgraph(variants: Vec, mut out: W) -> io::Result<()> { let cfg = match code { - blocks::BlockCode(block) => cfg::CFG::new(tcx, &*block), - blocks::FnLikeCode(fn_like) => cfg::CFG::new(tcx, &*fn_like.body()), + blocks::BlockCode(block) => cfg::CFG::new(tcx, &block), + blocks::FnLikeCode(fn_like) => cfg::CFG::new(tcx, &fn_like.body()), }; let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges; let lcfg = LabelledCFG { From db6e5d5ef946a2f8369e665f2b756c2465b77b68 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 8 Feb 2016 23:55:48 +0100 Subject: [PATCH 03/15] Use more autoderef in libsyntax_ext --- src/libsyntax_ext/deriving/generic/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 160d230f86be8..6088fdf940ac1 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -553,7 +553,7 @@ impl<'a> TraitDef<'a> { let mut processed_field_types = HashSet::new(); for field_ty in field_tys { - let tys = find_type_parameters(&*field_ty, &ty_param_names); + let tys = find_type_parameters(&field_ty, &ty_param_names); for ty in tys { // if we have already handled this type, skip it @@ -617,7 +617,7 @@ impl<'a> TraitDef<'a> { // Just mark it now since we know that it'll end up used downstream attr::mark_used(&attr); let opt_trait_ref = Some(trait_ref); - let ident = ast_util::impl_pretty_name(&opt_trait_ref, Some(&*self_type)); + let ident = ast_util::impl_pretty_name(&opt_trait_ref, Some(&self_type)); let unused_qual = cx.attribute( self.span, cx.meta_list(self.span, From c877d61b15bf0098d7dfbde3e74052a3559ad028 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 8 Feb 2016 23:55:55 +0100 Subject: [PATCH 04/15] Use more autoderef in libsyntax --- src/libsyntax/attr.rs | 8 +- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/feature_gate.rs | 2 +- src/libsyntax/fold.rs | 2 +- src/libsyntax/parse/mod.rs | 14 +- src/libsyntax/parse/parser.rs | 30 ++-- src/libsyntax/parse/token.rs | 2 +- src/libsyntax/print/pprust.rs | 266 +++++++++++++++++----------------- src/libsyntax/ptr.rs | 4 +- src/libsyntax/test.rs | 12 +- 10 files changed, 171 insertions(+), 171 deletions(-) diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 9953947eb52b7..dd414c463c7b1 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -143,7 +143,7 @@ pub trait AttributeMethods { impl AttributeMethods for Attribute { /// Extract the MetaItem from inside this Attribute. fn meta(&self) -> &MetaItem { - &*self.node.value + &self.node.value } /// Convert self to a normal #[doc="foo"] comment, if it is a @@ -370,9 +370,9 @@ pub fn cfg_matches(cfgs: &[P], diag: &mut T) -> bool { match cfg.node { ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "any" => - mis.iter().any(|mi| cfg_matches(cfgs, &**mi, diag)), + mis.iter().any(|mi| cfg_matches(cfgs, &mi, diag)), ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "all" => - mis.iter().all(|mi| cfg_matches(cfgs, &**mi, diag)), + mis.iter().all(|mi| cfg_matches(cfgs, &mi, diag)), ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "not" => { if mis.len() != 1 { diag.emit_error(|diagnostic| { @@ -380,7 +380,7 @@ pub fn cfg_matches(cfgs: &[P], }); return false; } - !cfg_matches(cfgs, &*mis[0], diag) + !cfg_matches(cfgs, &mis[0], diag) } ast::MetaItemKind::List(ref pred, _) => { diag.emit_error(|diagnostic| { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 1ee108217c6b6..123a21fb8f0c0 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1040,7 +1040,7 @@ fn expand_item_multi_modifier(mut it: Annotatable, allow_internal_unstable: true, } }); - it = mac.expand(fld.cx, attr.span, &*attr.node.value, it); + it = mac.expand(fld.cx, attr.span, &attr.node.value, it); fld.cx.bt_pop(); } _ => unreachable!() diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 9bf1dd49db572..5dfec8dafcf37 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -676,7 +676,7 @@ impl<'a> Context<'a> { } } for &(ref n, ref ty) in self.plugin_attributes { - if &*n == name { + if n == name { // Plugins can't gate attributes, so we don't check for it // unlike the code above; we only use this loop to // short-circuit to avoid the checks below diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index d347899ca2e7a..6df313177a08c 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1071,7 +1071,7 @@ pub fn noop_fold_item_simple(Item {id, ident, attrs, node, vis, span} let ident = match node { // The node may have changed, recompute the "pretty" impl name. ItemKind::Impl(_, _, _, ref maybe_trait, ref ty, _) => { - ast_util::impl_pretty_name(maybe_trait, Some(&**ty)) + ast_util::impl_pretty_name(maybe_trait, Some(&ty)) } _ => ident }; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 02844c35408df..aaa6f79cb188a 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -606,8 +606,8 @@ pub fn integer_lit(s: &str, 2 => sd.span_err(sp, "binary float literal is not supported"), _ => () } - let ident = token::intern_and_get_ident(&*s); - return filtered_float_lit(ident, Some(&**suf), sd, sp) + let ident = token::intern_and_get_ident(&s); + return filtered_float_lit(ident, Some(&suf), sd, sp) } } @@ -990,24 +990,24 @@ mod tests { #[test] fn parse_use() { let use_s = "use foo::bar::baz;"; let vitem = string_to_item(use_s.to_string()).unwrap(); - let vitem_s = item_to_string(&*vitem); + let vitem_s = item_to_string(&vitem); assert_eq!(&vitem_s[..], use_s); let use_s = "use foo::bar as baz;"; let vitem = string_to_item(use_s.to_string()).unwrap(); - let vitem_s = item_to_string(&*vitem); + let vitem_s = item_to_string(&vitem); assert_eq!(&vitem_s[..], use_s); } #[test] fn parse_extern_crate() { let ex_s = "extern crate foo;"; let vitem = string_to_item(ex_s.to_string()).unwrap(); - let vitem_s = item_to_string(&*vitem); + let vitem_s = item_to_string(&vitem); assert_eq!(&vitem_s[..], ex_s); let ex_s = "extern crate foo as bar;"; let vitem = string_to_item(ex_s.to_string()).unwrap(); - let vitem_s = item_to_string(&*vitem); + let vitem_s = item_to_string(&vitem); assert_eq!(&vitem_s[..], ex_s); } @@ -1030,7 +1030,7 @@ mod tests { } } let mut v = PatIdentVisitor { spans: Vec::new() }; - ::visit::walk_item(&mut v, &*item); + ::visit::walk_item(&mut v, &item); return v.spans; } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 0d5bdfbbc3bb8..1e1877ec6ae0a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -444,7 +444,7 @@ impl<'a> Parser<'a> { } else { b.push_str(", "); } - b.push_str(&*a.to_string()); + b.push_str(&a.to_string()); b }) } @@ -696,7 +696,7 @@ impl<'a> Parser<'a> { if text.is_empty() { self.span_bug(sp, "found empty literal suffix in Some") } - self.span_err(sp, &*format!("{} with a suffix is invalid", kind)); + self.span_err(sp, &format!("{} with a suffix is invalid", kind)); } } } @@ -1574,7 +1574,7 @@ impl<'a> Parser<'a> { if suffix_illegal { let sp = self.last_span; - self.expect_no_suffix(sp, &*format!("{} literal", lit.short_name()), suf) + self.expect_no_suffix(sp, &format!("{} literal", lit.short_name()), suf) } Ok(out) @@ -2083,7 +2083,7 @@ impl<'a> Parser<'a> { let mut trailing_comma = false; while self.token != token::CloseDelim(token::Paren) { es.push(try!(self.parse_expr())); - try!(self.commit_expr(&**es.last().unwrap(), &[], + try!(self.commit_expr(&es.last().unwrap(), &[], &[token::Comma, token::CloseDelim(token::Paren)])); if self.check(&token::Comma) { trailing_comma = true; @@ -2295,7 +2295,7 @@ impl<'a> Parser<'a> { } fields.push(try!(self.parse_field())); - try!(self.commit_expr(&*fields.last().unwrap().expr, + try!(self.commit_expr(&fields.last().unwrap().expr, &[token::Comma], &[token::CloseDelim(token::Brace)])); } @@ -2508,7 +2508,7 @@ impl<'a> Parser<'a> { } continue; } - if self.expr_is_complete(&*e) { break; } + if self.expr_is_complete(&e) { break; } match self.token { // expr(...) token::OpenDelim(token::Paren) => { @@ -2530,7 +2530,7 @@ impl<'a> Parser<'a> { self.bump(); let ix = try!(self.parse_expr()); hi = self.span.hi; - try!(self.commit_expr_expecting(&*ix, token::CloseDelim(token::Bracket))); + try!(self.commit_expr_expecting(&ix, token::CloseDelim(token::Bracket))); let index = self.mk_index(e, ix); e = self.mk_expr(lo, hi, index, None) } @@ -2820,7 +2820,7 @@ impl<'a> Parser<'a> { }; - if self.expr_is_complete(&*lhs) { + if self.expr_is_complete(&lhs) { // Semi-statement forms are odd. See https://github.com/rust-lang/rust/issues/29071 return Ok(lhs); } @@ -2844,7 +2844,7 @@ impl<'a> Parser<'a> { } self.bump(); if op.is_comparison() { - self.check_no_chained_comparison(&*lhs, &op); + self.check_no_chained_comparison(&lhs, &op); } // Special cases: if op == AssocOp::As { @@ -3152,7 +3152,7 @@ impl<'a> Parser<'a> { let lo = self.last_span.lo; let discriminant = try!(self.parse_expr_res( Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)); - if let Err(mut e) = self.commit_expr_expecting(&*discriminant, + if let Err(mut e) = self.commit_expr_expecting(&discriminant, token::OpenDelim(token::Brace)) { if self.token == token::Token::Semi { e.span_note(match_span, "did you mean to remove this `match` keyword?"); @@ -3183,11 +3183,11 @@ impl<'a> Parser<'a> { let expr = try!(self.parse_expr_res(Restrictions::RESTRICTION_STMT_EXPR, None)); let require_comma = - !classify::expr_is_simple_block(&*expr) + !classify::expr_is_simple_block(&expr) && self.token != token::CloseDelim(token::Brace); if require_comma { - try!(self.commit_expr(&*expr, &[token::Comma], &[token::CloseDelim(token::Brace)])); + try!(self.commit_expr(&expr, &[token::Comma], &[token::CloseDelim(token::Brace)])); } else { self.eat(&token::Comma); } @@ -3936,7 +3936,7 @@ impl<'a> Parser<'a> { stmts: &mut Vec, last_block_expr: &mut Option>) -> PResult<'a, ()> { // expression without semicolon - if classify::expr_requires_semi_to_be_stmt(&*e) { + if classify::expr_requires_semi_to_be_stmt(&e) { // Just check for errors and recover; do not eat semicolon yet. try!(self.commit_stmt(&[], &[token::Semi, token::CloseDelim(token::Brace)])); @@ -4861,7 +4861,7 @@ impl<'a> Parser<'a> { impl_items.push(try!(self.parse_impl_item())); } - Ok((ast_util::impl_pretty_name(&opt_trait, Some(&*ty)), + Ok((ast_util::impl_pretty_name(&opt_trait, Some(&ty)), ItemKind::Impl(unsafety, polarity, generics, opt_trait, ty, impl_items), Some(attrs))) } @@ -5075,7 +5075,7 @@ impl<'a> Parser<'a> { let ty = try!(self.parse_ty_sum()); try!(self.expect(&token::Eq)); let e = try!(self.parse_expr()); - try!(self.commit_expr_expecting(&*e, token::Semi)); + try!(self.commit_expr_expecting(&e, token::Semi)); let item = match m { Some(m) => ItemKind::Static(ty, m, e), None => ItemKind::Const(ty, e), diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 7d1b78b632f65..accbb54c629b2 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -666,7 +666,7 @@ impl InternedString { impl Deref for InternedString { type Target = str; - fn deref(&self) -> &str { &*self.string } + fn deref(&self) -> &str { &self.string } } impl fmt::Debug for InternedString { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 7e58fd9c3a1bf..2eb719627da50 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -286,22 +286,22 @@ pub fn token_to_string(tok: &Token) -> String { token::SpecialVarNt(var) => format!("${}", var.as_str()), token::Interpolated(ref nt) => match *nt { - token::NtExpr(ref e) => expr_to_string(&**e), - token::NtMeta(ref e) => meta_item_to_string(&**e), - token::NtTy(ref e) => ty_to_string(&**e), - token::NtPath(ref e) => path_to_string(&**e), - token::NtItem(ref e) => item_to_string(&**e), - token::NtBlock(ref e) => block_to_string(&**e), - token::NtStmt(ref e) => stmt_to_string(&**e), - token::NtPat(ref e) => pat_to_string(&**e), + token::NtExpr(ref e) => expr_to_string(&e), + token::NtMeta(ref e) => meta_item_to_string(&e), + token::NtTy(ref e) => ty_to_string(&e), + token::NtPath(ref e) => path_to_string(&e), + token::NtItem(ref e) => item_to_string(&e), + token::NtBlock(ref e) => block_to_string(&e), + token::NtStmt(ref e) => stmt_to_string(&e), + token::NtPat(ref e) => pat_to_string(&e), token::NtIdent(ref e, _) => ident_to_string(e.node), - token::NtTT(ref e) => tt_to_string(&**e), - token::NtArm(ref e) => arm_to_string(&*e), - token::NtImplItem(ref e) => impl_item_to_string(&**e), - token::NtTraitItem(ref e) => trait_item_to_string(&**e), - token::NtGenerics(ref e) => generics_to_string(&*e), - token::NtWhereClause(ref e) => where_clause_to_string(&*e), - token::NtArg(ref e) => arg_to_string(&*e), + token::NtTT(ref e) => tt_to_string(&e), + token::NtArm(ref e) => arm_to_string(&e), + token::NtImplItem(ref e) => impl_item_to_string(&e), + token::NtTraitItem(ref e) => trait_item_to_string(&e), + token::NtGenerics(ref e) => generics_to_string(&e), + token::NtWhereClause(ref e) => where_clause_to_string(&e), + token::NtArg(ref e) => arg_to_string(&e), } } } @@ -758,7 +758,7 @@ pub trait PrintState<'a> { ast::AttrStyle::Inner => try!(word(self.writer(), "#![")), ast::AttrStyle::Outer => try!(word(self.writer(), "#[")), } - try!(self.print_meta_item(&*attr.meta())); + try!(self.print_meta_item(&attr.meta())); word(self.writer(), "]") } } @@ -779,7 +779,7 @@ pub trait PrintState<'a> { try!(self.popen()); try!(self.commasep(Consistent, &items[..], - |s, i| s.print_meta_item(&**i))); + |s, i| s.print_meta_item(&i))); try!(self.pclose()); } } @@ -923,14 +923,14 @@ impl<'a> State<'a> { pub fn commasep_exprs(&mut self, b: Breaks, exprs: &[P]) -> io::Result<()> { - self.commasep_cmnt(b, exprs, |s, e| s.print_expr(&**e), |e| e.span) + self.commasep_cmnt(b, exprs, |s, e| s.print_expr(&e), |e| e.span) } pub fn print_mod(&mut self, _mod: &ast::Mod, attrs: &[ast::Attribute]) -> io::Result<()> { try!(self.print_inner_attributes(attrs)); for item in &_mod.items { - try!(self.print_item(&**item)); + try!(self.print_item(&item)); } Ok(()) } @@ -959,7 +959,7 @@ impl<'a> State<'a> { match ty.node { ast::TyKind::Vec(ref ty) => { try!(word(&mut self.s, "[")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(word(&mut self.s, "]")); } ast::TyKind::Ptr(ref mt) => { @@ -968,7 +968,7 @@ impl<'a> State<'a> { ast::Mutability::Mutable => try!(self.word_nbsp("mut")), ast::Mutability::Immutable => try!(self.word_nbsp("const")), } - try!(self.print_type(&*mt.ty)); + try!(self.print_type(&mt.ty)); } ast::TyKind::Rptr(ref lifetime, ref mt) => { try!(word(&mut self.s, "&")); @@ -978,7 +978,7 @@ impl<'a> State<'a> { ast::TyKind::Tup(ref elts) => { try!(self.popen()); try!(self.commasep(Inconsistent, &elts[..], - |s, ty| s.print_type(&**ty))); + |s, ty| s.print_type(&ty))); if elts.len() == 1 { try!(word(&mut self.s, ",")); } @@ -986,7 +986,7 @@ impl<'a> State<'a> { } ast::TyKind::Paren(ref typ) => { try!(self.popen()); - try!(self.print_type(&**typ)); + try!(self.print_type(&typ)); try!(self.pclose()); } ast::TyKind::BareFn(ref f) => { @@ -1000,7 +1000,7 @@ impl<'a> State<'a> { }; try!(self.print_ty_fn(f.abi, f.unsafety, - &*f.decl, + &f.decl, None, &generics, None)); @@ -1012,7 +1012,7 @@ impl<'a> State<'a> { try!(self.print_qpath(path, qself, false)) } ast::TyKind::ObjectSum(ref ty, ref bounds) => { - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(self.print_bounds("+", &bounds[..])); } ast::TyKind::PolyTraitRef(ref bounds) => { @@ -1020,14 +1020,14 @@ impl<'a> State<'a> { } ast::TyKind::FixedLengthVec(ref ty, ref v) => { try!(word(&mut self.s, "[")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(word(&mut self.s, "; ")); - try!(self.print_expr(&**v)); + try!(self.print_expr(&v)); try!(word(&mut self.s, "]")); } ast::TyKind::Typeof(ref e) => { try!(word(&mut self.s, "typeof(")); - try!(self.print_expr(&**e)); + try!(self.print_expr(&e)); try!(word(&mut self.s, ")")); } ast::TyKind::Infer => { @@ -1064,7 +1064,7 @@ impl<'a> State<'a> { } try!(self.print_ident(item.ident)); try!(self.word_space(":")); - try!(self.print_type(&**t)); + try!(self.print_type(&t)); try!(word(&mut self.s, ";")); try!(self.end()); // end the head-ibox self.end() // end the outer cbox @@ -1139,7 +1139,7 @@ impl<'a> State<'a> { ast::ItemKind::Use(ref vp) => { try!(self.head(&visibility_qualified(item.vis, "use"))); - try!(self.print_view_path(&**vp)); + try!(self.print_view_path(&vp)); try!(word(&mut self.s, ";")); try!(self.end()); // end inner head-block try!(self.end()); // end outer head-block @@ -1152,12 +1152,12 @@ impl<'a> State<'a> { } try!(self.print_ident(item.ident)); try!(self.word_space(":")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(space(&mut self.s)); try!(self.end()); // end the head-ibox try!(self.word_space("=")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(word(&mut self.s, ";")); try!(self.end()); // end the outer cbox } @@ -1166,12 +1166,12 @@ impl<'a> State<'a> { "const"))); try!(self.print_ident(item.ident)); try!(self.word_space(":")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(space(&mut self.s)); try!(self.end()); // end the head-ibox try!(self.word_space("=")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(word(&mut self.s, ";")); try!(self.end()); // end the outer cbox } @@ -1188,7 +1188,7 @@ impl<'a> State<'a> { item.vis )); try!(word(&mut self.s, " ")); - try!(self.print_block_with_attrs(&**body, &item.attrs)); + try!(self.print_block_with_attrs(&body, &item.attrs)); } ast::ItemKind::Mod(ref _mod) => { try!(self.head(&visibility_qualified(item.vis, @@ -1217,7 +1217,7 @@ impl<'a> State<'a> { try!(self.print_where_clause(¶ms.where_clause)); try!(space(&mut self.s)); try!(self.word_space("=")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(word(&mut self.s, ";")); try!(self.end()); // end the outer ibox } @@ -1279,7 +1279,7 @@ impl<'a> State<'a> { None => {} } - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); try!(self.print_where_clause(&generics.where_clause)); try!(space(&mut self.s)); @@ -1412,7 +1412,7 @@ impl<'a> State<'a> { ast::UnnamedField(vis) => { try!(s.print_visibility(vis)); try!(s.maybe_print_comment(field.span.lo)); - s.print_type(&*field.node.ty) + s.print_type(&field.node.ty) } } } @@ -1441,7 +1441,7 @@ impl<'a> State<'a> { try!(self.print_visibility(visibility)); try!(self.print_ident(ident)); try!(self.word_nbsp(":")); - try!(self.print_type(&*field.node.ty)); + try!(self.print_type(&field.node.ty)); try!(word(&mut self.s, ",")); } } @@ -1524,7 +1524,7 @@ impl<'a> State<'a> { Some(ref d) => { try!(space(&mut self.s)); try!(self.word_space("=")); - self.print_expr(&**d) + self.print_expr(&d) } _ => Ok(()) } @@ -1614,15 +1614,15 @@ impl<'a> State<'a> { try!(self.maybe_print_comment(st.span.lo)); match st.node { ast::StmtKind::Decl(ref decl, _) => { - try!(self.print_decl(&**decl)); + try!(self.print_decl(&decl)); } ast::StmtKind::Expr(ref expr, _) => { try!(self.space_if_not_bol()); - try!(self.print_expr_outer_attr_style(&**expr, false)); + try!(self.print_expr_outer_attr_style(&expr, false)); } ast::StmtKind::Semi(ref expr, _) => { try!(self.space_if_not_bol()); - try!(self.print_expr_outer_attr_style(&**expr, false)); + try!(self.print_expr_outer_attr_style(&expr, false)); try!(word(&mut self.s, ";")); } ast::StmtKind::Mac(ref mac, style, ref attrs) => { @@ -1632,7 +1632,7 @@ impl<'a> State<'a> { ast::MacStmtStyle::Braces => token::Brace, _ => token::Paren }; - try!(self.print_mac(&**mac, delim)); + try!(self.print_mac(&mac, delim)); match style { ast::MacStmtStyle::Braces => {} _ => try!(word(&mut self.s, ";")), @@ -1691,7 +1691,7 @@ impl<'a> State<'a> { match blk.expr { Some(ref expr) => { try!(self.space_if_not_bol()); - try!(self.print_expr_outer_attr_style(&**expr, false)); + try!(self.print_expr_outer_attr_style(&expr, false)); try!(self.maybe_print_trailing_comment(expr.span, Some(blk.span.hi))); } _ => () @@ -1709,9 +1709,9 @@ impl<'a> State<'a> { try!(self.cbox(INDENT_UNIT - 1)); try!(self.ibox(0)); try!(word(&mut self.s, " else if ")); - try!(self.print_expr(&**i)); + try!(self.print_expr(&i)); try!(space(&mut self.s)); - try!(self.print_block(&**then)); + try!(self.print_block(&then)); self.print_else(e.as_ref().map(|e| &**e)) } // "another else-if-let" @@ -1719,12 +1719,12 @@ impl<'a> State<'a> { try!(self.cbox(INDENT_UNIT - 1)); try!(self.ibox(0)); try!(word(&mut self.s, " else if let ")); - try!(self.print_pat(&**pat)); + try!(self.print_pat(&pat)); try!(space(&mut self.s)); try!(self.word_space("=")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(space(&mut self.s)); - try!(self.print_block(&**then)); + try!(self.print_block(&then)); self.print_else(e.as_ref().map(|e| &**e)) } // "final else" @@ -1732,7 +1732,7 @@ impl<'a> State<'a> { try!(self.cbox(INDENT_UNIT - 1)); try!(self.ibox(0)); try!(word(&mut self.s, " else ")); - self.print_block(&**b) + self.print_block(&b) } // BLEAH, constraints would be great here _ => { @@ -1867,7 +1867,7 @@ impl<'a> State<'a> { try!(s.ibox(INDENT_UNIT)); try!(s.print_ident(field.ident.node)); try!(s.word_space(":")); - try!(s.print_expr(&*field.expr)); + try!(s.print_expr(&field.expr)); s.end() }, |f| f.span)); @@ -1879,7 +1879,7 @@ impl<'a> State<'a> { try!(space(&mut self.s)); } try!(word(&mut self.s, "..")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(self.end()); } _ => if !fields.is_empty() { @@ -1913,13 +1913,13 @@ impl<'a> State<'a> { tys: &[P], args: &[P]) -> io::Result<()> { let base_args = &args[1..]; - try!(self.print_expr(&*args[0])); + try!(self.print_expr(&args[0])); try!(word(&mut self.s, ".")); try!(self.print_ident(ident.node)); if !tys.is_empty() { try!(word(&mut self.s, "::<")); try!(self.commasep(Inconsistent, tys, - |s, ty| s.print_type(&**ty))); + |s, ty| s.print_type(&ty))); try!(word(&mut self.s, ">")); } self.print_call_post(base_args) @@ -1988,7 +1988,7 @@ impl<'a> State<'a> { try!(self.print_expr_vec(&exprs[..], attrs)); } ast::ExprKind::Repeat(ref element, ref count) => { - try!(self.print_expr_repeat(&**element, &**count, attrs)); + try!(self.print_expr_repeat(&element, &count, attrs)); } ast::ExprKind::Struct(ref path, ref fields, ref wth) => { try!(self.print_expr_struct(path, &fields[..], wth, attrs)); @@ -1997,43 +1997,43 @@ impl<'a> State<'a> { try!(self.print_expr_tup(&exprs[..], attrs)); } ast::ExprKind::Call(ref func, ref args) => { - try!(self.print_expr_call(&**func, &args[..])); + try!(self.print_expr_call(&func, &args[..])); } ast::ExprKind::MethodCall(ident, ref tys, ref args) => { try!(self.print_expr_method_call(ident, &tys[..], &args[..])); } ast::ExprKind::Binary(op, ref lhs, ref rhs) => { - try!(self.print_expr_binary(op, &**lhs, &**rhs)); + try!(self.print_expr_binary(op, &lhs, &rhs)); } ast::ExprKind::Unary(op, ref expr) => { - try!(self.print_expr_unary(op, &**expr)); + try!(self.print_expr_unary(op, &expr)); } ast::ExprKind::AddrOf(m, ref expr) => { - try!(self.print_expr_addr_of(m, &**expr)); + try!(self.print_expr_addr_of(m, &expr)); } ast::ExprKind::Lit(ref lit) => { - try!(self.print_literal(&**lit)); + try!(self.print_literal(&lit)); } ast::ExprKind::Cast(ref expr, ref ty) => { if let ast::ExprKind::Cast(..) = expr.node { - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); } else { - try!(self.print_expr_maybe_paren(&**expr)); + try!(self.print_expr_maybe_paren(&expr)); } try!(space(&mut self.s)); try!(self.word_space("as")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); } ast::ExprKind::Type(ref expr, ref ty) => { - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(self.word_space(":")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); } ast::ExprKind::If(ref test, ref blk, ref elseopt) => { - try!(self.print_if(&**test, &**blk, elseopt.as_ref().map(|e| &**e))); + try!(self.print_if(&test, &blk, elseopt.as_ref().map(|e| &**e))); } ast::ExprKind::IfLet(ref pat, ref expr, ref blk, ref elseopt) => { - try!(self.print_if_let(&**pat, &**expr, &** blk, elseopt.as_ref().map(|e| &**e))); + try!(self.print_if_let(&pat, &expr, &blk, elseopt.as_ref().map(|e| &**e))); } ast::ExprKind::While(ref test, ref blk, opt_ident) => { if let Some(ident) = opt_ident { @@ -2041,9 +2041,9 @@ impl<'a> State<'a> { try!(self.word_space(":")); } try!(self.head("while")); - try!(self.print_expr(&**test)); + try!(self.print_expr(&test)); try!(space(&mut self.s)); - try!(self.print_block_with_attrs(&**blk, attrs)); + try!(self.print_block_with_attrs(&blk, attrs)); } ast::ExprKind::WhileLet(ref pat, ref expr, ref blk, opt_ident) => { if let Some(ident) = opt_ident { @@ -2051,12 +2051,12 @@ impl<'a> State<'a> { try!(self.word_space(":")); } try!(self.head("while let")); - try!(self.print_pat(&**pat)); + try!(self.print_pat(&pat)); try!(space(&mut self.s)); try!(self.word_space("=")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(space(&mut self.s)); - try!(self.print_block_with_attrs(&**blk, attrs)); + try!(self.print_block_with_attrs(&blk, attrs)); } ast::ExprKind::ForLoop(ref pat, ref iter, ref blk, opt_ident) => { if let Some(ident) = opt_ident { @@ -2064,12 +2064,12 @@ impl<'a> State<'a> { try!(self.word_space(":")); } try!(self.head("for")); - try!(self.print_pat(&**pat)); + try!(self.print_pat(&pat)); try!(space(&mut self.s)); try!(self.word_space("in")); - try!(self.print_expr(&**iter)); + try!(self.print_expr(&iter)); try!(space(&mut self.s)); - try!(self.print_block_with_attrs(&**blk, attrs)); + try!(self.print_block_with_attrs(&blk, attrs)); } ast::ExprKind::Loop(ref blk, opt_ident) => { if let Some(ident) = opt_ident { @@ -2078,13 +2078,13 @@ impl<'a> State<'a> { } try!(self.head("loop")); try!(space(&mut self.s)); - try!(self.print_block_with_attrs(&**blk, attrs)); + try!(self.print_block_with_attrs(&blk, attrs)); } ast::ExprKind::Match(ref expr, ref arms) => { try!(self.cbox(INDENT_UNIT)); try!(self.ibox(4)); try!(self.word_nbsp("match")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(space(&mut self.s)); try!(self.bopen()); try!(self.print_inner_attributes_no_trailing_hardbreak(attrs)); @@ -2096,7 +2096,7 @@ impl<'a> State<'a> { ast::ExprKind::Closure(capture_clause, ref decl, ref body) => { try!(self.print_capture_clause(capture_clause)); - try!(self.print_fn_block_args(&**decl)); + try!(self.print_fn_block_args(&decl)); try!(space(&mut self.s)); let default_return = match decl.output { @@ -2105,19 +2105,19 @@ impl<'a> State<'a> { }; if !default_return || !body.stmts.is_empty() || body.expr.is_none() { - try!(self.print_block_unclosed(&**body)); + try!(self.print_block_unclosed(&body)); } else { // we extract the block, so as not to create another set of boxes let i_expr = body.expr.as_ref().unwrap(); match i_expr.node { ast::ExprKind::Block(ref blk) => { try!(self.print_block_unclosed_with_attrs( - &**blk, + &blk, i_expr.attrs.as_attr_slice())); } _ => { // this is a bare expression - try!(self.print_expr(&**i_expr)); + try!(self.print_expr(&i_expr)); try!(self.end()); // need to close a box } } @@ -2132,44 +2132,44 @@ impl<'a> State<'a> { try!(self.cbox(INDENT_UNIT)); // head-box, will be closed by print-block after { try!(self.ibox(0)); - try!(self.print_block_with_attrs(&**blk, attrs)); + try!(self.print_block_with_attrs(&blk, attrs)); } ast::ExprKind::Assign(ref lhs, ref rhs) => { - try!(self.print_expr(&**lhs)); + try!(self.print_expr(&lhs)); try!(space(&mut self.s)); try!(self.word_space("=")); - try!(self.print_expr(&**rhs)); + try!(self.print_expr(&rhs)); } ast::ExprKind::AssignOp(op, ref lhs, ref rhs) => { - try!(self.print_expr(&**lhs)); + try!(self.print_expr(&lhs)); try!(space(&mut self.s)); try!(word(&mut self.s, op.node.to_string())); try!(self.word_space("=")); - try!(self.print_expr(&**rhs)); + try!(self.print_expr(&rhs)); } ast::ExprKind::Field(ref expr, id) => { - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(word(&mut self.s, ".")); try!(self.print_ident(id.node)); } ast::ExprKind::TupField(ref expr, id) => { - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(word(&mut self.s, ".")); try!(self.print_usize(id.node)); } ast::ExprKind::Index(ref expr, ref index) => { - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); try!(word(&mut self.s, "[")); - try!(self.print_expr(&**index)); + try!(self.print_expr(&index)); try!(word(&mut self.s, "]")); } ast::ExprKind::Range(ref start, ref end) => { if let &Some(ref e) = start { - try!(self.print_expr(&**e)); + try!(self.print_expr(&e)); } try!(word(&mut self.s, "..")); if let &Some(ref e) = end { - try!(self.print_expr(&**e)); + try!(self.print_expr(&e)); } } ast::ExprKind::Path(None, ref path) => { @@ -2199,7 +2199,7 @@ impl<'a> State<'a> { match *result { Some(ref expr) => { try!(word(&mut self.s, " ")); - try!(self.print_expr(&**expr)); + try!(self.print_expr(&expr)); } _ => () } @@ -2220,7 +2220,7 @@ impl<'a> State<'a> { _ => try!(s.print_string(&out.constraint, ast::StrStyle::Cooked)) } try!(s.popen()); - try!(s.print_expr(&*out.expr)); + try!(s.print_expr(&out.expr)); try!(s.pclose()); Ok(()) })); @@ -2231,7 +2231,7 @@ impl<'a> State<'a> { |s, &(ref co, ref o)| { try!(s.print_string(&co, ast::StrStyle::Cooked)); try!(s.popen()); - try!(s.print_expr(&**o)); + try!(s.print_expr(&o)); try!(s.pclose()); Ok(()) })); @@ -2258,7 +2258,7 @@ impl<'a> State<'a> { if !options.is_empty() { try!(space(&mut self.s)); try!(self.word_space(":")); - try!(self.commasep(Inconsistent, &*options, + try!(self.commasep(Inconsistent, &options, |s, &co| { try!(s.print_string(co, ast::StrStyle::Cooked)); Ok(()) @@ -2271,7 +2271,7 @@ impl<'a> State<'a> { ast::ExprKind::Paren(ref e) => { try!(self.popen()); try!(self.print_inner_attributes_inline(attrs)); - try!(self.print_expr(&**e)); + try!(self.print_expr(&e)); try!(self.pclose()); } } @@ -2280,10 +2280,10 @@ impl<'a> State<'a> { } pub fn print_local_decl(&mut self, loc: &ast::Local) -> io::Result<()> { - try!(self.print_pat(&*loc.pat)); + try!(self.print_pat(&loc.pat)); if let Some(ref ty) = loc.ty { try!(self.word_space(":")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); } Ok(()) } @@ -2298,16 +2298,16 @@ impl<'a> State<'a> { try!(self.word_nbsp("let")); try!(self.ibox(INDENT_UNIT)); - try!(self.print_local_decl(&**loc)); + try!(self.print_local_decl(&loc)); try!(self.end()); if let Some(ref init) = loc.init { try!(self.nbsp()); try!(self.word_space("=")); - try!(self.print_expr(&**init)); + try!(self.print_expr(&init)); } self.end() } - ast::DeclKind::Item(ref item) => self.print_item(&**item) + ast::DeclKind::Item(ref item) => self.print_item(&item) } } @@ -2411,7 +2411,7 @@ impl<'a> State<'a> { try!(self.commasep( Inconsistent, &data.types, - |s, ty| s.print_type(&**ty))); + |s, ty| s.print_type(&ty))); comma = true; } @@ -2422,7 +2422,7 @@ impl<'a> State<'a> { try!(self.print_ident(binding.ident)); try!(space(&mut self.s)); try!(self.word_space("=")); - try!(self.print_type(&*binding.ty)); + try!(self.print_type(&binding.ty)); comma = true; } @@ -2434,7 +2434,7 @@ impl<'a> State<'a> { try!(self.commasep( Inconsistent, &data.inputs, - |s, ty| s.print_type(&**ty))); + |s, ty| s.print_type(&ty))); try!(word(&mut self.s, ")")); match data.output { @@ -2442,7 +2442,7 @@ impl<'a> State<'a> { Some(ref ty) => { try!(self.space_if_not_bol()); try!(self.word_space("->")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); } } } @@ -2473,7 +2473,7 @@ impl<'a> State<'a> { match *sub { Some(ref p) => { try!(word(&mut self.s, "@")); - try!(self.print_pat(&**p)); + try!(self.print_pat(&p)); } None => () } @@ -2486,7 +2486,7 @@ impl<'a> State<'a> { if !args.is_empty() { try!(self.popen()); try!(self.commasep(Inconsistent, &args[..], - |s, p| s.print_pat(&**p))); + |s, p| s.print_pat(&p))); try!(self.pclose()); } } @@ -2507,7 +2507,7 @@ impl<'a> State<'a> { try!(s.print_ident(f.node.ident)); try!(s.word_nbsp(":")); } - try!(s.print_pat(&*f.node.pat)); + try!(s.print_pat(&f.node.pat)); s.end() }, |f| f.node.pat.span)); @@ -2522,7 +2522,7 @@ impl<'a> State<'a> { try!(self.popen()); try!(self.commasep(Inconsistent, &elts[..], - |s, p| s.print_pat(&**p))); + |s, p| s.print_pat(&p))); if elts.len() == 1 { try!(word(&mut self.s, ",")); } @@ -2530,38 +2530,38 @@ impl<'a> State<'a> { } ast::PatBox(ref inner) => { try!(word(&mut self.s, "box ")); - try!(self.print_pat(&**inner)); + try!(self.print_pat(&inner)); } ast::PatRegion(ref inner, mutbl) => { try!(word(&mut self.s, "&")); if mutbl == ast::Mutability::Mutable { try!(word(&mut self.s, "mut ")); } - try!(self.print_pat(&**inner)); + try!(self.print_pat(&inner)); } - ast::PatLit(ref e) => try!(self.print_expr(&**e)), + ast::PatLit(ref e) => try!(self.print_expr(&e)), ast::PatRange(ref begin, ref end) => { - try!(self.print_expr(&**begin)); + try!(self.print_expr(&begin)); try!(space(&mut self.s)); try!(word(&mut self.s, "...")); - try!(self.print_expr(&**end)); + try!(self.print_expr(&end)); } ast::PatVec(ref before, ref slice, ref after) => { try!(word(&mut self.s, "[")); try!(self.commasep(Inconsistent, &before[..], - |s, p| s.print_pat(&**p))); + |s, p| s.print_pat(&p))); if let Some(ref p) = *slice { if !before.is_empty() { try!(self.word_space(",")); } if p.node != ast::PatWild { - try!(self.print_pat(&**p)); + try!(self.print_pat(&p)); } try!(word(&mut self.s, "..")); if !after.is_empty() { try!(self.word_space(",")); } } try!(self.commasep(Inconsistent, &after[..], - |s, p| s.print_pat(&**p))); + |s, p| s.print_pat(&p))); try!(word(&mut self.s, "]")); } ast::PatMac(ref m) => try!(self.print_mac(m, token::Paren)), @@ -2586,12 +2586,12 @@ impl<'a> State<'a> { try!(space(&mut self.s)); try!(self.word_space("|")); } - try!(self.print_pat(&**p)); + try!(self.print_pat(&p)); } try!(space(&mut self.s)); if let Some(ref e) = arm.guard { try!(self.word_space("if")); - try!(self.print_expr(&**e)); + try!(self.print_expr(&e)); try!(space(&mut self.s)); } try!(self.word_space("=>")); @@ -2599,7 +2599,7 @@ impl<'a> State<'a> { match arm.body.node { ast::ExprKind::Block(ref blk) => { // the block will close the pattern's ibox - try!(self.print_block_unclosed_indent(&**blk, INDENT_UNIT)); + try!(self.print_block_unclosed_indent(&blk, INDENT_UNIT)); // If it is a user-provided unsafe block, print a comma after it if let BlockCheckMode::Unsafe(ast::UserProvided) = blk.rules { @@ -2608,7 +2608,7 @@ impl<'a> State<'a> { } _ => { try!(self.end()); // close the ibox for the pattern - try!(self.print_expr(&*arm.body)); + try!(self.print_expr(&arm.body)); try!(word(&mut self.s, ",")); } } @@ -2634,7 +2634,7 @@ impl<'a> State<'a> { ast::SelfKind::Explicit(ref typ, _) => { try!(word(&mut self.s, "self")); try!(self.word_space(":")); - try!(self.print_type(&**typ)); + try!(self.print_type(&typ)); } } return Ok(true); @@ -2722,7 +2722,7 @@ impl<'a> State<'a> { try!(self.word_space("->")); match decl.output { ast::FunctionRetTy::Ty(ref ty) => { - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); self.maybe_print_comment(ty.span.lo) } ast::FunctionRetTy::Default(..) => unreachable!(), @@ -2834,7 +2834,7 @@ impl<'a> State<'a> { Some(ref default) => { try!(space(&mut self.s)); try!(self.word_space("=")); - self.print_type(&**default) + self.print_type(&default) } _ => Ok(()) } @@ -2860,7 +2860,7 @@ impl<'a> State<'a> { ref bounds, ..}) => { try!(self.print_formal_lifetime_list(bound_lifetimes)); - try!(self.print_type(&**bounded_ty)); + try!(self.print_type(&bounded_ty)); try!(self.print_bounds(":", bounds)); } ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime, @@ -2881,7 +2881,7 @@ impl<'a> State<'a> { try!(self.print_path(path, false, 0)); try!(space(&mut self.s)); try!(self.word_space("=")); - try!(self.print_type(&**ty)); + try!(self.print_type(&ty)); } } } @@ -2953,13 +2953,13 @@ impl<'a> State<'a> { pub fn print_mt(&mut self, mt: &ast::MutTy) -> io::Result<()> { try!(self.print_mutability(mt.mutbl)); - self.print_type(&*mt.ty) + self.print_type(&mt.ty) } pub fn print_arg(&mut self, input: &ast::Arg, is_closure: bool) -> io::Result<()> { try!(self.ibox(INDENT_UNIT)); match input.ty.node { - ast::TyKind::Infer if is_closure => try!(self.print_pat(&*input.pat)), + ast::TyKind::Infer if is_closure => try!(self.print_pat(&input.pat)), _ => { match input.pat.node { ast::PatIdent(_, ref path1, _) if @@ -2968,12 +2968,12 @@ impl<'a> State<'a> { // Do nothing. } _ => { - try!(self.print_pat(&*input.pat)); + try!(self.print_pat(&input.pat)); try!(word(&mut self.s, ":")); try!(space(&mut self.s)); } } - try!(self.print_type(&*input.ty)); + try!(self.print_type(&input.ty)); } } self.end() @@ -2992,7 +2992,7 @@ impl<'a> State<'a> { try!(self.word_nbsp("!")), ast::FunctionRetTy::Default(..) => unreachable!(), ast::FunctionRetTy::Ty(ref ty) => - try!(self.print_type(&**ty)) + try!(self.print_type(&ty)) } try!(self.end()); diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index 27f5700cad58a..fda9741d35c41 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -87,7 +87,7 @@ impl Deref for P { type Target = T; fn deref<'a>(&'a self) -> &'a T { - &*self.ptr + &self.ptr } } @@ -153,7 +153,7 @@ impl P<[T]> { } pub fn as_slice<'a>(&'a self) -> &'a [T] { - &*self.ptr + &self.ptr } pub fn move_iter(self) -> vec::IntoIter { diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 6b4f946419061..81b702e794d77 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -123,7 +123,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { debug!("current path: {}", ast_util::path_name_i(&self.cx.path)); - let i = if is_test_fn(&self.cx, &*i) || is_bench_fn(&self.cx, &*i) { + let i = if is_test_fn(&self.cx, &i) || is_bench_fn(&self.cx, &i) { match i.node { ast::ItemKind::Fn(_, ast::Unsafety::Unsafe, _, _, _, _) => { let diag = self.cx.span_diagnostic; @@ -134,9 +134,9 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { let test = Test { span: i.span, path: self.cx.path.clone(), - bench: is_bench_fn(&self.cx, &*i), - ignore: is_ignored(&*i), - should_panic: should_panic(&*i) + bench: is_bench_fn(&self.cx, &i), + ignore: is_ignored(&i), + should_panic: should_panic(&i) }; self.cx.testfns.push(test); self.tests.push(i.ident); @@ -205,7 +205,7 @@ impl fold::Folder for EntryPointCleaner { // Remove any #[main] or #[start] from the AST so it doesn't // clash with the one we're going to add, but mark it as // #[allow(dead_code)] to avoid printing warnings. - let folded = match entry::entry_point_type(&*folded, self.depth) { + let folded = match entry::entry_point_type(&folded, self.depth) { EntryPointType::MainNamed | EntryPointType::MainAttr | EntryPointType::Start => @@ -556,7 +556,7 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P, Option>) { }) }); - debug!("Synthetic test module:\n{}\n", pprust::item_to_string(&*item)); + debug!("Synthetic test module:\n{}\n", pprust::item_to_string(&item)); (item, reexport) } From f831d98ba2167ac19966618bfb218856e1eedc63 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Feb 2016 21:09:37 +0100 Subject: [PATCH 05/15] Autoderef in librustc_typeck --- src/librustc_typeck/astconv.rs | 30 +-- src/librustc_typeck/check/_match.rs | 48 ++--- src/librustc_typeck/check/callee.rs | 8 +- src/librustc_typeck/check/closure.rs | 2 +- src/librustc_typeck/check/method/confirm.rs | 16 +- src/librustc_typeck/check/method/suggest.rs | 4 +- src/librustc_typeck/check/mod.rs | 200 ++++++++++---------- src/librustc_typeck/check/regionck.rs | 48 ++--- src/librustc_typeck/check/upvar.rs | 2 +- src/librustc_typeck/check/writeback.rs | 6 +- src/librustc_typeck/collect.rs | 26 +-- 11 files changed, 195 insertions(+), 195 deletions(-) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index d67f5f9db5ee4..4061d3a2028c7 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -562,7 +562,7 @@ fn convert_angle_bracketed_parameters<'tcx>(this: &AstConv<'tcx>, let assoc_bindings: Vec<_> = data.bindings.iter() .map(|b| ConvertedBinding { item_name: b.name, - ty: ast_ty_to_ty(this, rscope, &*b.ty), + ty: ast_ty_to_ty(this, rscope, &b.ty), span: b.span }) .collect(); @@ -1064,7 +1064,7 @@ fn ast_ty_to_trait_ref<'tcx>(this: &AstConv<'tcx>, err.span_suggestion(full_span, "try adding parentheses (per RFC 438):", format!("&{}({} +{})", mutbl_str, - pprust::ty_to_string(&*mut_ty.ty), + pprust::ty_to_string(&mut_ty.ty), pprust::bounds_to_string(bounds))); } (&hir::TyRptr(Some(ref lt), ref mut_ty), Some(full_span)) => { @@ -1073,7 +1073,7 @@ fn ast_ty_to_trait_ref<'tcx>(this: &AstConv<'tcx>, format!("&{} {}({} +{})", pprust::lifetime_to_string(lt), mutbl_str, - pprust::ty_to_string(&*mut_ty.ty), + pprust::ty_to_string(&mut_ty.ty), pprust::bounds_to_string(bounds))); } @@ -1596,10 +1596,10 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, let typ = match ast_ty.node { hir::TyVec(ref ty) => { - tcx.mk_slice(ast_ty_to_ty(this, rscope, &**ty)) + tcx.mk_slice(ast_ty_to_ty(this, rscope, &ty)) } hir::TyObjectSum(ref ty, ref bounds) => { - match ast_ty_to_trait_ref(this, rscope, &**ty, bounds) { + match ast_ty_to_trait_ref(this, rscope, &ty, bounds) { Ok((trait_ref, projection_bounds)) => { trait_ref_to_object_type(this, rscope, @@ -1615,7 +1615,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, } hir::TyPtr(ref mt) => { tcx.mk_ptr(ty::TypeAndMut { - ty: ast_ty_to_ty(this, rscope, &*mt.ty), + ty: ast_ty_to_ty(this, rscope, &mt.ty), mutbl: mt.mutbl }) } @@ -1626,18 +1626,18 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, &ObjectLifetimeDefaultRscope::new( rscope, ty::ObjectLifetimeDefault::Specific(r)); - let t = ast_ty_to_ty(this, rscope1, &*mt.ty); + let t = ast_ty_to_ty(this, rscope1, &mt.ty); tcx.mk_ref(tcx.mk_region(r), ty::TypeAndMut {ty: t, mutbl: mt.mutbl}) } hir::TyTup(ref fields) => { let flds = fields.iter() - .map(|t| ast_ty_to_ty(this, rscope, &**t)) + .map(|t| ast_ty_to_ty(this, rscope, &t)) .collect(); tcx.mk_tup(flds) } hir::TyBareFn(ref bf) => { require_c_abi_if_variadic(tcx, &bf.decl, bf.abi, ast_ty.span); - let bare_fn = ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl); + let bare_fn = ty_of_bare_fn(this, bf.unsafety, bf.abi, &bf.decl); tcx.mk_fn(None, tcx.mk_bare_fn(bare_fn)) } hir::TyPolyTraitRef(ref bounds) => { @@ -1687,10 +1687,10 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, Ok(r) => { match r { ConstVal::Int(i) => - tcx.mk_array(ast_ty_to_ty(this, rscope, &**ty), + tcx.mk_array(ast_ty_to_ty(this, rscope, &ty), i as usize), ConstVal::Uint(i) => - tcx.mk_array(ast_ty_to_ty(this, rscope, &**ty), + tcx.mk_array(ast_ty_to_ty(this, rscope, &ty), i as usize), _ => { span_err!(tcx.sess, ast_ty.span, E0249, @@ -1740,7 +1740,7 @@ pub fn ty_of_arg<'tcx>(this: &AstConv<'tcx>, match a.ty.node { hir::TyInfer if expected_ty.is_some() => expected_ty.unwrap(), hir::TyInfer => this.ty_infer(None, None, None, a.ty.span), - _ => ast_ty_to_ty(this, rscope, &*a.ty), + _ => ast_ty_to_ty(this, rscope, &a.ty), } } @@ -1804,7 +1804,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>, let arg_tys: Vec = arg_params.iter().map(|a| ty_of_arg(this, &rb, a, None)).collect(); let arg_pats: Vec = - arg_params.iter().map(|a| pprust::pat_to_string(&*a.pat)).collect(); + arg_params.iter().map(|a| pprust::pat_to_string(&a.pat)).collect(); // Second, if there was exactly one lifetime (either a substitution or a // reference) in the arguments, then any anonymous regions in the output @@ -1860,7 +1860,7 @@ fn determine_self_type<'a, 'tcx>(this: &AstConv<'tcx>, Some(ty::ExplicitSelfCategory::ByReference(region, mutability))) } hir::SelfExplicit(ref ast_type, _) => { - let explicit_type = ast_ty_to_ty(this, rscope, &**ast_type); + let explicit_type = ast_ty_to_ty(this, rscope, &ast_type); // We wish to (for now) categorize an explicit self // declaration like `self: SomeType` into either `self`, @@ -1967,7 +1967,7 @@ pub fn ty_of_closure<'tcx>( _ if is_infer => ty::FnConverging(this.ty_infer(None, None, None, decl.output.span())), hir::Return(ref output) => - ty::FnConverging(ast_ty_to_ty(this, &rb, &**output)), + ty::FnConverging(ast_ty_to_ty(this, &rb, &output)), hir::DefaultReturn(..) => unreachable!(), hir::NoReturn(..) => ty::FnDiverging }; diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index f0436eee42009..6ca48f2d8d484 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -50,8 +50,8 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, fcx.write_ty(pat.id, expected); } hir::PatLit(ref lt) => { - check_expr(fcx, &**lt); - let expr_ty = fcx.expr_ty(&**lt); + check_expr(fcx, <); + let expr_ty = fcx.expr_ty(<); // Byte string patterns behave the same way as array patterns // They can denote both statically and dynamically sized byte arrays @@ -198,7 +198,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, } if let Some(ref p) = *sub { - check_pat(pcx, &**p, expected); + check_pat(pcx, &p, expected); } } } @@ -259,28 +259,28 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, fcx.write_ty(pat.id, pat_ty); demand::eqtype(fcx, pat.span, expected, pat_ty); for (element_pat, element_ty) in elements.iter().zip(element_tys) { - check_pat(pcx, &**element_pat, element_ty); + check_pat(pcx, &element_pat, element_ty); } } hir::PatBox(ref inner) => { let inner_ty = fcx.infcx().next_ty_var(); let uniq_ty = tcx.mk_box(inner_ty); - if check_dereferencable(pcx, pat.span, expected, &**inner) { + if check_dereferencable(pcx, pat.span, expected, &inner) { // Here, `demand::subtype` is good enough, but I don't // think any errors can be introduced by using // `demand::eqtype`. demand::eqtype(fcx, pat.span, expected, uniq_ty); fcx.write_ty(pat.id, uniq_ty); - check_pat(pcx, &**inner, inner_ty); + check_pat(pcx, &inner, inner_ty); } else { fcx.write_error(pat.id); - check_pat(pcx, &**inner, tcx.types.err); + check_pat(pcx, &inner, tcx.types.err); } } hir::PatRegion(ref inner, mutbl) => { let expected = fcx.infcx().shallow_resolve(expected); - if check_dereferencable(pcx, pat.span, expected, &**inner) { + if check_dereferencable(pcx, pat.span, expected, &inner) { // `demand::subtype` would be good enough, but using // `eqtype` turns out to be equally general. See (*) // below for details. @@ -304,10 +304,10 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, }; fcx.write_ty(pat.id, rptr_ty); - check_pat(pcx, &**inner, inner_ty); + check_pat(pcx, &inner, inner_ty); } else { fcx.write_error(pat.id); - check_pat(pcx, &**inner, tcx.types.err); + check_pat(pcx, &inner, tcx.types.err); } } hir::PatVec(ref before, ref slice, ref after) => { @@ -339,7 +339,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, demand::eqtype(fcx, pat.span, expected, pat_ty); for elt in before { - check_pat(pcx, &**elt, inner_ty); + check_pat(pcx, &elt, inner_ty); } if let Some(ref slice) = *slice { let region = fcx.infcx().next_region_var(infer::PatternRegion(pat.span)); @@ -350,10 +350,10 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, ty: tcx.mk_slice(inner_ty), mutbl: mutbl }); - check_pat(pcx, &**slice, slice_ty); + check_pat(pcx, &slice, slice_ty); } for elt in after { - check_pat(pcx, &**elt, inner_ty); + check_pat(pcx, &elt, inner_ty); } } } @@ -482,10 +482,10 @@ pub fn check_match<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, for arm in arms { let mut pcx = pat_ctxt { fcx: fcx, - map: pat_id_map(&tcx.def_map, &*arm.pats[0]), + map: pat_id_map(&tcx.def_map, &arm.pats[0]), }; for p in &arm.pats { - check_pat(&mut pcx, &**p, discrim_ty); + check_pat(&mut pcx, &p, discrim_ty); } } @@ -507,17 +507,17 @@ pub fn check_match<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, // arm for inconsistent arms or to the whole match when a `()` type // is required). Expectation::ExpectHasType(ety) if ety != fcx.tcx().mk_nil() => { - check_expr_coercable_to_type(fcx, &*arm.body, ety); + check_expr_coercable_to_type(fcx, &arm.body, ety); ety } _ => { - check_expr_with_expectation(fcx, &*arm.body, expected); + check_expr_with_expectation(fcx, &arm.body, expected); fcx.node_ty(arm.body.id) } }; if let Some(ref e) = arm.guard { - check_expr_has_type(fcx, &**e, tcx.types.bool); + check_expr_has_type(fcx, &e, tcx.types.bool); } if result_ty.references_error() || bty.references_error() { @@ -622,7 +622,7 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, if let Some(subpats) = subpats { for pat in subpats { - check_pat(pcx, &**pat, tcx.types.err); + check_pat(pcx, &pat, tcx.types.err); } } @@ -670,7 +670,7 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, fcx.write_error(pat.id); if let Some(subpats) = subpats { for pat in subpats { - check_pat(pcx, &**pat, tcx.types.err); + check_pat(pcx, &pat, tcx.types.err); } } }; @@ -742,7 +742,7 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, if let Some(subpats) = subpats { if subpats.len() == arg_tys.len() { for (subpat, arg_ty) in subpats.iter().zip(arg_tys) { - check_pat(pcx, &**subpat, arg_ty); + check_pat(pcx, &subpat, arg_ty); } } else if arg_tys.is_empty() { span_err!(tcx.sess, pat.span, E0024, @@ -750,7 +750,7 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, subpats.len(), if subpats.len() == 1 {""} else {"s"}, kind_name); for pat in subpats { - check_pat(pcx, &**pat, tcx.types.err); + check_pat(pcx, &pat, tcx.types.err); } } else { span_err!(tcx.sess, pat.span, E0023, @@ -760,7 +760,7 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, arg_tys.len(), if arg_tys.len() == 1 {""} else {"s"}); for pat in subpats { - check_pat(pcx, &**pat, tcx.types.err); + check_pat(pcx, &pat, tcx.types.err); } } } @@ -815,7 +815,7 @@ pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, } }; - check_pat(pcx, &*field.pat, field_ty); + check_pat(pcx, &field.pat, field_ty); } // Report an error if not all the fields were specified. diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 84c436c59c1d2..42ea3cc2aaa7b 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -199,7 +199,7 @@ fn try_overloaded_call_traits<'a,'tcx>(fcx: &FnCtxt<'a, 'tcx>, match method::lookup_in_trait_adjusted(fcx, call_expr.span, - Some(&*callee_expr), + Some(&callee_expr), method_name, trait_def_id, autoderefs, @@ -304,12 +304,12 @@ fn confirm_deferred_closure_call<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, call_expr.span, expected, fn_sig.output.clone(), - &*fn_sig.inputs); + &fn_sig.inputs); check_argument_types(fcx, call_expr.span, - &*fn_sig.inputs, - &*expected_arg_tys, + &fn_sig.inputs, + &expected_arg_tys, arg_exprs, fn_sig.variadic, TupleArgumentsFlag::TupleArguments); diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 7fd35cf159ff9..d3e66bde4f4c3 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -83,7 +83,7 @@ fn check_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, &fn_sig, decl, expr.id, - &*body, + &body, fcx.inh); // Tuple up the arguments and insert the resulting function type into diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 1d8f6f005cddc..bf08989bc0a12 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -269,7 +269,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { probe::WhereClausePick(ref poly_trait_ref) => { // Where clauses can have bound regions in them. We need to instantiate // those to convert from a poly-trait-ref to a trait-ref. - self.replace_late_bound_regions_with_fresh_var(&*poly_trait_ref).substs.clone() + self.replace_late_bound_regions_with_fresh_var(&poly_trait_ref).substs.clone() } } } @@ -290,7 +290,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { NoPreference, |ty, _| { match ty.sty { - ty::TyTrait(ref data) => Some(closure(self, ty, &**data)), + ty::TyTrait(ref data) => Some(closure(self, ty, &data)), _ => None, } }); @@ -478,7 +478,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { hir::ExprField(ref expr, _) | hir::ExprTupField(ref expr, _) | hir::ExprIndex(ref expr, _) | - hir::ExprUnary(hir::UnDeref, ref expr) => exprs.push(&**expr), + hir::ExprUnary(hir::UnDeref, ref expr) => exprs.push(&expr), _ => break, } } @@ -570,13 +570,13 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { unsize: None }))), false) }; - let index_expr_ty = self.fcx.expr_ty(&**index_expr); + let index_expr_ty = self.fcx.expr_ty(&index_expr); let result = check::try_index_step( self.fcx, ty::MethodCall::expr(expr.id), expr, - &**base_expr, + &base_expr, adjusted_base_ty, autoderefs, unsize, @@ -586,7 +586,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { if let Some((input_ty, return_ty)) = result { demand::suptype(self.fcx, index_expr.span, input_ty, index_expr_ty); - let expr_ty = self.fcx.expr_ty(&*expr); + let expr_ty = self.fcx.expr_ty(&expr); demand::suptype(self.fcx, expr.span, expr_ty, return_ty); } } @@ -599,8 +599,8 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { self.fcx, expr.span, Some(method_call), - Some(&**base_expr), - self.fcx.expr_ty(&**base_expr), + Some(&base_expr), + self.fcx.expr_ty(&base_expr), PreferMutLvalue); } } diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 064259c171d91..1367db16314e2 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -271,7 +271,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, for (i, trait_did) in candidates.iter().enumerate() { err.fileline_help(span, - &*format!("candidate #{}: use `{}`", + &format!("candidate #{}: use `{}`", i + 1, fcx.tcx().item_path_str(*trait_did))); } @@ -316,7 +316,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, for (i, trait_info) in candidates.iter().enumerate() { err.fileline_help(span, - &*format!("candidate #{}: `{}`", + &format!("candidate #{}: `{}`", i + 1, fcx.tcx().item_path_str(trait_info.def_id))); } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index f61316f1dfe71..e485bdd66fc9f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -368,7 +368,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> { fn visit_ty(&mut self, t: &'tcx hir::Ty) { match t.node { hir::TyFixedLengthVec(_, ref expr) => { - check_const_in_type(self.ccx, &**expr, self.ccx.tcx.types.usize); + check_const_in_type(self.ccx, &expr, self.ccx.tcx.types.usize); } _ => {} } @@ -491,7 +491,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { // Add explicitly-declared locals. fn visit_local(&mut self, local: &'tcx hir::Local) { let o_ty = match local.ty { - Some(ref ty) => Some(self.fcx.to_ty(&**ty)), + Some(ref ty) => Some(self.fcx.to_ty(&ty)), None => None }; self.assign(local.span, local.id, o_ty); @@ -533,8 +533,8 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { fn visit_ty(&mut self, t: &'tcx hir::Ty) { match t.node { hir::TyFixedLengthVec(ref ty, ref count_expr) => { - self.visit_ty(&**ty); - check_expr_with_hint(self.fcx, &**count_expr, self.fcx.tcx().types.usize); + self.visit_ty(&ty); + check_expr_with_hint(self.fcx, &count_expr, self.fcx.tcx().types.usize); } hir::TyBareFn(ref function_declaration) => { intravisit::walk_fn_decl_nopat(self, &function_declaration.decl); @@ -612,7 +612,7 @@ fn check_fn<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>, // Create type variables for each argument. pat_util::pat_bindings( &tcx.def_map, - &*input.pat, + &input.pat, |_bm, pat_id, sp, _path| { let var_ty = visit.assign(sp, pat_id, None); fcx.require_type_is_sized(var_ty, sp, @@ -622,9 +622,9 @@ fn check_fn<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>, // Check the pattern. let pcx = pat_ctxt { fcx: &fcx, - map: pat_id_map(&tcx.def_map, &*input.pat), + map: pat_id_map(&tcx.def_map, &input.pat), }; - _match::check_pat(&pcx, &*input.pat, *arg_ty); + _match::check_pat(&pcx, &input.pat, *arg_ty); } visit.visit_block(body); @@ -660,7 +660,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) { match it.node { // Consts can play a role in type-checking, so they are included here. hir::ItemStatic(_, _, ref e) | - hir::ItemConst(_, ref e) => check_const(ccx, it.span, &**e, it.id), + hir::ItemConst(_, ref e) => check_const(ccx, it.span, &e, it.id), hir::ItemEnum(ref enum_definition, _) => { check_enum_variants(ccx, it.span, @@ -730,7 +730,7 @@ pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) { hir::ItemFn(ref decl, _, _, _, _, ref body) => { let fn_pty = ccx.tcx.lookup_item_type(ccx.tcx.map.local_def_id(it.id)); let param_env = ParameterEnvironment::for_item(ccx.tcx, it.id); - check_bare_fn(ccx, &**decl, &**body, it.id, it.span, fn_pty.ty, param_env); + check_bare_fn(ccx, &decl, &body, it.id, it.span, fn_pty.ty, param_env); } hir::ItemImpl(_, _, _, _, _, ref impl_items) => { debug!("ItemImpl {} with id {}", it.name, it.id); @@ -740,7 +740,7 @@ pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) { for impl_item in impl_items { match impl_item.node { hir::ImplItemKind::Const(_, ref expr) => { - check_const(ccx, impl_item.span, &*expr, impl_item.id) + check_const(ccx, impl_item.span, &expr, impl_item.id) } hir::ImplItemKind::Method(ref sig, ref body) => { check_method_body(ccx, &impl_pty.generics, sig, body, @@ -757,7 +757,7 @@ pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) { for trait_item in trait_items { match trait_item.node { hir::ConstTraitItem(_, Some(ref expr)) => { - check_const(ccx, trait_item.span, &*expr, trait_item.id) + check_const(ccx, trait_item.span, &expr, trait_item.id) } hir::MethodTraitItem(ref sig, Some(ref body)) => { check_trait_fn_not_const(ccx, trait_item.span, sig.constness); @@ -801,7 +801,7 @@ fn check_trait_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, }) { if let Some(ref istring) = attr.value_str() { let parser = Parser::new(&istring); - let types = &*generics.ty_params; + let types = &generics.ty_params; for token in parser { match token { Piece::String(_) => (), // Normal string, no need to check it @@ -890,7 +890,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, &impl_const, impl_item.span, trait_const, - &*impl_trait_ref); + &impl_trait_ref); } else { span_err!(tcx.sess, impl_item.span, E0323, "item `{}` is an associated const, \ @@ -2279,7 +2279,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, (PreferMutLvalue, Some(trait_did)) => { method::lookup_in_trait_adjusted(fcx, expr.span, - Some(&*base_expr), + Some(&base_expr), token::intern("index_mut"), trait_did, autoderefs, @@ -2295,7 +2295,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, (None, Some(trait_did)) => { method::lookup_in_trait_adjusted(fcx, expr.span, - Some(&*base_expr), + Some(&base_expr), token::intern("index"), trait_did, autoderefs, @@ -2409,7 +2409,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, } else { expected_arg_tys = match expected_arg_tys.get(0) { Some(&ty) => match ty.sty { - ty::TyTuple(ref tys) => &**tys, + ty::TyTuple(ref tys) => &tys, _ => &[] }, None => &[] @@ -2512,14 +2512,14 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, }); check_expr_with_unifier(fcx, - &**arg, + &arg, expected.unwrap_or(ExpectHasType(formal_ty)), NoPreference, || { // 2. Coerce to the most detailed type that could be coerced // to, which is `expected_ty` if `rvalue_hint` returns an // `ExprHasType(expected_ty)`, or the `formal_ty` otherwise. let coerce_ty = expected.and_then(|e| e.only_has_type(fcx)); - demand::coerce(fcx, arg.span, coerce_ty.unwrap_or(formal_ty), &**arg); + demand::coerce(fcx, arg.span, coerce_ty.unwrap_or(formal_ty), &arg); // 3. Relate the expected type and the formal one, // if the expected type was used for the coercion. @@ -2549,12 +2549,12 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, // arguments which we skipped above. if variadic { for arg in args.iter().skip(expected_arg_count) { - check_expr(fcx, &**arg); + check_expr(fcx, &arg); // There are a few types which get autopromoted when passed via varargs // in C but we just error out instead and require explicit casts. let arg_ty = structurally_resolved_type(fcx, arg.span, - fcx.expr_ty(&**arg)); + fcx.expr_ty(&arg)); match arg_ty.sty { ty::TyFloat(ast::FloatTy::F32) => { fcx.type_error_message(arg.span, @@ -2816,15 +2816,15 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, tps: &[P], expected: Expectation<'tcx>, lvalue_pref: LvaluePreference) { - let rcvr = &*args[0]; - check_expr_with_lvalue_pref(fcx, &*rcvr, lvalue_pref); + let rcvr = &args[0]; + check_expr_with_lvalue_pref(fcx, &rcvr, lvalue_pref); // no need to check for bot/err -- callee does that let expr_t = structurally_resolved_type(fcx, expr.span, - fcx.expr_ty(&*rcvr)); + fcx.expr_ty(&rcvr)); - let tps = tps.iter().map(|ast_ty| fcx.to_ty(&**ast_ty)).collect::>(); + let tps = tps.iter().map(|ast_ty| fcx.to_ty(&ast_ty)).collect::>(); let fn_ty = match method::lookup(fcx, method_name.span, method_name.node, @@ -2877,8 +2877,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, let branches_ty = match opt_else_expr { Some(ref else_expr) => { - check_expr_with_expectation(fcx, &**else_expr, expected); - let else_ty = fcx.expr_ty(&**else_expr); + check_expr_with_expectation(fcx, &else_expr, expected); + let else_ty = fcx.expr_ty(&else_expr); infer::common_supertype(fcx.infcx(), TypeOrigin::IfExpression(sp), true, @@ -3128,7 +3128,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, // Make sure to give a type to the field even if there's // an error, so we can continue typechecking - check_expr_coercable_to_type(fcx, &*field.expr, expected_field_type); + check_expr_coercable_to_type(fcx, &field.expr, expected_field_type); } // Make sure the programmer specified all the fields. @@ -3156,10 +3156,10 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, // otherwise we might ICE fcx.write_error(id); for field in fields { - check_expr(fcx, &*field.expr); + check_expr(fcx, &field.expr); } match *base_expr { - Some(ref base) => check_expr(fcx, &**base), + Some(ref base) => check_expr(fcx, &base), None => {} } } @@ -3217,12 +3217,12 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, } }); check_expr_with_expectation(fcx, subexpr, expected_inner); - let referent_ty = fcx.expr_ty(&**subexpr); + let referent_ty = fcx.expr_ty(&subexpr); fcx.write_ty(id, tcx.mk_box(referent_ty)); } hir::ExprLit(ref lit) => { - let typ = check_lit(fcx, &**lit, expected); + let typ = check_lit(fcx, &lit, expected); fcx.write_ty(id, typ); } hir::ExprBinary(op, ref lhs, ref rhs) => { @@ -3245,8 +3245,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, _ => NoPreference }; check_expr_with_expectation_and_lvalue_pref( - fcx, &**oprnd, expected_inner, lvalue_pref); - let mut oprnd_t = fcx.expr_ty(&**oprnd); + fcx, &oprnd, expected_inner, lvalue_pref); + let mut oprnd_t = fcx.expr_ty(&oprnd); if !oprnd_t.references_error() { match unop { @@ -3256,7 +3256,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, Some(mt) => mt.ty, None => match try_overloaded_deref(fcx, expr.span, Some(MethodCall::expr(expr.id)), - Some(&**oprnd), oprnd_t, lvalue_pref) { + Some(&oprnd), oprnd_t, lvalue_pref) { Some(mt) => mt.ty, None => { fcx.type_error_message(expr.span, |actual| { @@ -3274,7 +3274,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, if !(oprnd_t.is_integral() || oprnd_t.sty == ty::TyBool) { oprnd_t = op::check_user_unop(fcx, "!", "not", tcx.lang_items.not_trait(), - expr, &**oprnd, oprnd_t, unop); + expr, &oprnd, oprnd_t, unop); } } hir::UnNeg => { @@ -3283,7 +3283,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, if !(oprnd_t.is_integral() || oprnd_t.is_fp()) { oprnd_t = op::check_user_unop(fcx, "-", "neg", tcx.lang_items.neg_trait(), - expr, &**oprnd, oprnd_t, unop); + expr, &oprnd, oprnd_t, unop); } } } @@ -3294,7 +3294,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, let hint = expected.only_has_type(fcx).map_or(NoExpectation, |ty| { match ty.sty { ty::TyRef(_, ref mt) | ty::TyRawPtr(ref mt) => { - if fcx.tcx().expr_is_lval(&**oprnd) { + if fcx.tcx().expr_is_lval(&oprnd) { // Lvalues may legitimately have unsized types. // For example, dereferences of a fat pointer and // the last field of a struct can be unsized. @@ -3308,11 +3308,11 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, }); let lvalue_pref = LvaluePreference::from_mutbl(mutbl); check_expr_with_expectation_and_lvalue_pref(fcx, - &**oprnd, + &oprnd, hint, lvalue_pref); - let tm = ty::TypeAndMut { ty: fcx.expr_ty(&**oprnd), mutbl: mutbl }; + let tm = ty::TypeAndMut { ty: fcx.expr_ty(&oprnd), mutbl: mutbl }; let oprnd_t = if tm.ty.references_error() { tcx.types.err } else { @@ -3381,10 +3381,10 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, } hir::ExprInlineAsm(ref ia) => { for &(_, ref input) in &ia.inputs { - check_expr(fcx, &**input); + check_expr(fcx, &input); } for out in &ia.outputs { - check_expr(fcx, &*out.expr); + check_expr(fcx, &out.expr); } fcx.write_nil(id); } @@ -3402,13 +3402,13 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, not `()`"); }, Some(ref e) => { - check_expr_coercable_to_type(fcx, &**e, result_type); + check_expr_coercable_to_type(fcx, &e, result_type); } } } ty::FnDiverging => { if let Some(ref e) = *expr_opt { - check_expr(fcx, &**e); + check_expr(fcx, &e); } span_err!(tcx.sess, expr.span, E0166, "`return` in a function declared as diverging"); @@ -3417,19 +3417,19 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, fcx.write_ty(id, fcx.infcx().next_diverging_ty_var()); } hir::ExprAssign(ref lhs, ref rhs) => { - check_expr_with_lvalue_pref(fcx, &**lhs, PreferMutLvalue); + check_expr_with_lvalue_pref(fcx, &lhs, PreferMutLvalue); let tcx = fcx.tcx(); - if !tcx.expr_is_lval(&**lhs) { + if !tcx.expr_is_lval(&lhs) { span_err!(tcx.sess, expr.span, E0070, "invalid left-hand side expression"); } - let lhs_ty = fcx.expr_ty(&**lhs); - check_expr_coercable_to_type(fcx, &**rhs, lhs_ty); - let rhs_ty = fcx.expr_ty(&**rhs); + let lhs_ty = fcx.expr_ty(&lhs); + check_expr_coercable_to_type(fcx, &rhs, lhs_ty); + let rhs_ty = fcx.expr_ty(&rhs); - fcx.require_expr_have_sized_type(&**lhs, traits::AssignmentLhsSized); + fcx.require_expr_have_sized_type(&lhs, traits::AssignmentLhsSized); if lhs_ty.references_error() || rhs_ty.references_error() { fcx.write_error(id); @@ -3438,13 +3438,13 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, } } hir::ExprIf(ref cond, ref then_blk, ref opt_else_expr) => { - check_then_else(fcx, &**cond, &**then_blk, opt_else_expr.as_ref().map(|e| &**e), + check_then_else(fcx, &cond, &then_blk, opt_else_expr.as_ref().map(|e| &**e), id, expr.span, expected); } hir::ExprWhile(ref cond, ref body, _) => { - check_expr_has_type(fcx, &**cond, tcx.types.bool); - check_block_no_value(fcx, &**body); - let cond_ty = fcx.expr_ty(&**cond); + check_expr_has_type(fcx, &cond, tcx.types.bool); + check_block_no_value(fcx, &body); + let cond_ty = fcx.expr_ty(&cond); let body_ty = fcx.node_ty(body.id); if cond_ty.references_error() || body_ty.references_error() { fcx.write_error(id); @@ -3454,25 +3454,25 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, } } hir::ExprLoop(ref body, _) => { - check_block_no_value(fcx, &**body); - if !may_break(tcx, expr.id, &**body) { + check_block_no_value(fcx, &body); + if !may_break(tcx, expr.id, &body) { fcx.write_ty(id, fcx.infcx().next_diverging_ty_var()); } else { fcx.write_nil(id); } } hir::ExprMatch(ref discrim, ref arms, match_src) => { - _match::check_match(fcx, expr, &**discrim, arms, expected, match_src); + _match::check_match(fcx, expr, &discrim, arms, expected, match_src); } hir::ExprClosure(capture, ref decl, ref body) => { - closure::check_expr_closure(fcx, expr, capture, &**decl, &**body, expected); + closure::check_expr_closure(fcx, expr, capture, &decl, &body, expected); } hir::ExprBlock(ref b) => { - check_block_with_expected(fcx, &**b, expected); + check_block_with_expected(fcx, &b, expected); fcx.write_ty(id, fcx.node_ty(b.id)); } hir::ExprCall(ref callee, ref args) => { - callee::check_call(fcx, expr, &**callee, &args[..], expected); + callee::check_call(fcx, expr, &callee, &args[..], expected); // we must check that return type of called functions is WF: let ret_ty = fcx.expr_ty(expr); @@ -3480,7 +3480,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, } hir::ExprMethodCall(name, ref tps, ref args) => { check_method_call(fcx, expr, name, &args[..], &tps[..], expected, lvalue_pref); - let arg_tys = args.iter().map(|a| fcx.expr_ty(&**a)); + let arg_tys = args.iter().map(|a| fcx.expr_ty(&a)); let args_err = arg_tys.fold(false, |rest_err, a| rest_err || a.references_error()); if args_err { fcx.write_error(id); @@ -3488,7 +3488,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, } hir::ExprCast(ref e, ref t) => { if let hir::TyFixedLengthVec(_, ref count_expr) = t.node { - check_expr_with_hint(fcx, &**count_expr, tcx.types.usize); + check_expr_with_hint(fcx, &count_expr, tcx.types.usize); } // Find the type of `e`. Supply hints based on the type we are casting to, @@ -3516,8 +3516,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, } } hir::ExprType(ref e, ref t) => { - let typ = fcx.to_ty(&**t); - check_expr_eq_type(fcx, &**e, typ); + let typ = fcx.to_ty(&t); + check_expr_eq_type(fcx, &e, typ); fcx.write_ty(id, typ); } hir::ExprVec(ref args) => { @@ -3531,14 +3531,14 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, let typ = match uty { Some(uty) => { for e in args { - check_expr_coercable_to_type(fcx, &**e, uty); + check_expr_coercable_to_type(fcx, &e, uty); } uty } None => { let t: Ty = fcx.infcx().next_ty_var(); for e in args { - check_expr_has_type(fcx, &**e, t); + check_expr_has_type(fcx, &e, t); } t } @@ -3547,8 +3547,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, fcx.write_ty(id, typ); } hir::ExprRepeat(ref element, ref count_expr) => { - check_expr_has_type(fcx, &**count_expr, tcx.types.usize); - let count = fcx.tcx().eval_repeat_count(&**count_expr); + check_expr_has_type(fcx, &count_expr, tcx.types.usize); + let count = fcx.tcx().eval_repeat_count(&count_expr); let uty = match expected { ExpectHasType(uty) => { @@ -3562,13 +3562,13 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, let (element_ty, t) = match uty { Some(uty) => { - check_expr_coercable_to_type(fcx, &**element, uty); + check_expr_coercable_to_type(fcx, &element, uty); (uty, uty) } None => { let t: Ty = fcx.infcx().next_ty_var(); - check_expr_has_type(fcx, &**element, t); - (fcx.expr_ty(&**element), t) + check_expr_has_type(fcx, &element, t); + (fcx.expr_ty(&element), t) } }; @@ -3602,12 +3602,12 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, let t = match flds { Some(ref fs) if i < fs.len() => { let ety = fs[i]; - check_expr_coercable_to_type(fcx, &**e, ety); + check_expr_coercable_to_type(fcx, &e, ety); ety } _ => { - check_expr_with_expectation(fcx, &**e, NoExpectation); - fcx.expr_ty(&**e) + check_expr_with_expectation(fcx, &e, NoExpectation); + fcx.expr_ty(&e) } }; err_field = err_field || t.references_error(); @@ -3626,17 +3626,17 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, fcx.require_expr_have_sized_type(expr, traits::StructInitializerSized); } hir::ExprField(ref base, ref field) => { - check_field(fcx, expr, lvalue_pref, &**base, field); + check_field(fcx, expr, lvalue_pref, &base, field); } hir::ExprTupField(ref base, idx) => { - check_tup_field(fcx, expr, lvalue_pref, &**base, idx); + check_tup_field(fcx, expr, lvalue_pref, &base, idx); } hir::ExprIndex(ref base, ref idx) => { - check_expr_with_lvalue_pref(fcx, &**base, lvalue_pref); - check_expr(fcx, &**idx); + check_expr_with_lvalue_pref(fcx, &base, lvalue_pref); + check_expr(fcx, &idx); - let base_t = fcx.expr_ty(&**base); - let idx_t = fcx.expr_ty(&**idx); + let base_t = fcx.expr_ty(&base); + let idx_t = fcx.expr_ty(&idx); if base_t.references_error() { fcx.write_ty(id, base_t); @@ -3651,7 +3651,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, fcx.write_ty(id, element_ty); } None => { - check_expr_has_type(fcx, &**idx, fcx.tcx().types.err); + check_expr_has_type(fcx, &idx, fcx.tcx().types.err); fcx.type_error_message( expr.span, |actual| { @@ -3667,12 +3667,12 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, } hir::ExprRange(ref start, ref end) => { let t_start = start.as_ref().map(|e| { - check_expr(fcx, &**e); - fcx.expr_ty(&**e) + check_expr(fcx, &e); + fcx.expr_ty(&e) }); let t_end = end.as_ref().map(|e| { - check_expr(fcx, &**e); - fcx.expr_ty(&**e) + check_expr(fcx, &e); + fcx.expr_ty(&e) }); let idx_type = match (t_start, t_end) { @@ -3905,8 +3905,8 @@ pub fn check_decl_local<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, local: &'tcx hir::Local) fcx.write_ty(local.id, t); if let Some(ref init) = local.init { - check_decl_initializer(fcx, local, &**init); - let init_ty = fcx.expr_ty(&**init); + check_decl_initializer(fcx, local, &init); + let init_ty = fcx.expr_ty(&init); if init_ty.references_error() { fcx.write_ty(local.id, init_ty); } @@ -3914,9 +3914,9 @@ pub fn check_decl_local<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, local: &'tcx hir::Local) let pcx = pat_ctxt { fcx: fcx, - map: pat_id_map(&tcx.def_map, &*local.pat), + map: pat_id_map(&tcx.def_map, &local.pat), }; - _match::check_pat(&pcx, &*local.pat, t); + _match::check_pat(&pcx, &local.pat, t); let pat_ty = fcx.node_ty(local.pat.id); if pat_ty.references_error() { fcx.write_ty(local.id, pat_ty); @@ -3932,7 +3932,7 @@ pub fn check_stmt<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, stmt: &'tcx hir::Stmt) { node_id = id; match decl.node { hir::DeclLocal(ref l) => { - check_decl_local(fcx, &**l); + check_decl_local(fcx, &l); let l_t = fcx.node_ty(l.id); saw_bot = saw_bot || fcx.infcx().type_var_diverges(l_t); saw_err = saw_err || l_t.references_error(); @@ -3943,15 +3943,15 @@ pub fn check_stmt<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, stmt: &'tcx hir::Stmt) { hir::StmtExpr(ref expr, id) => { node_id = id; // Check with expected type of () - check_expr_has_type(fcx, &**expr, fcx.tcx().mk_nil()); - let expr_ty = fcx.expr_ty(&**expr); + check_expr_has_type(fcx, &expr, fcx.tcx().mk_nil()); + let expr_ty = fcx.expr_ty(&expr); saw_bot = saw_bot || fcx.infcx().type_var_diverges(expr_ty); saw_err = saw_err || expr_ty.references_error(); } hir::StmtSemi(ref expr, id) => { node_id = id; - check_expr(fcx, &**expr); - let expr_ty = fcx.expr_ty(&**expr); + check_expr(fcx, &expr); + let expr_ty = fcx.expr_ty(&expr); saw_bot |= fcx.infcx().type_var_diverges(expr_ty); saw_err |= expr_ty.references_error(); } @@ -4035,12 +4035,12 @@ fn check_block_with_expected<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, } let ety = match expected { ExpectHasType(ety) => { - check_expr_coercable_to_type(fcx, &**e, ety); + check_expr_coercable_to_type(fcx, &e, ety); ety } _ => { - check_expr_with_expectation(fcx, &**e, expected); - fcx.expr_ty(&**e) + check_expr_with_expectation(fcx, &e, expected); + fcx.expr_ty(&e) } }; @@ -4608,7 +4608,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, let type_count = type_defs.len(space); assert_eq!(substs.types.len(space), 0); for (i, typ) in data.types.iter().enumerate() { - let t = fcx.to_ty(&**typ); + let t = fcx.to_ty(&typ); if i < type_count { substs.types.push(space, t); } else if i == type_count { @@ -4677,7 +4677,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, } let input_tys: Vec = - data.inputs.iter().map(|ty| fcx.to_ty(&**ty)).collect(); + data.inputs.iter().map(|ty| fcx.to_ty(&ty)).collect(); let tuple_ty = fcx.tcx().mk_tup(input_tys); @@ -4686,7 +4686,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, } let output_ty: Option = - data.output.as_ref().map(|ty| fcx.to_ty(&**ty)); + data.output.as_ref().map(|ty| fcx.to_ty(&ty)); let output_ty = output_ty.unwrap_or(fcx.tcx().mk_nil()); @@ -4848,7 +4848,7 @@ pub fn structurally_resolved_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &hir::Block) -> bool { // First: is there an unlabeled break immediately // inside the loop? - (loop_query(&*b, |e| { + (loop_query(&b, |e| { match *e { hir::ExprBreak(None) => true, _ => false diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 56b02412c31b2..1ee0542f63337 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -489,7 +489,7 @@ fn visit_block(rcx: &mut Rcx, b: &hir::Block) { fn visit_arm(rcx: &mut Rcx, arm: &hir::Arm) { // see above for p in &arm.pats { - constrain_bindings_in_pat(&**p, rcx); + constrain_bindings_in_pat(&p, rcx); } intravisit::walk_arm(rcx, arm); @@ -497,7 +497,7 @@ fn visit_arm(rcx: &mut Rcx, arm: &hir::Arm) { fn visit_local(rcx: &mut Rcx, l: &hir::Local) { // see above - constrain_bindings_in_pat(&*l.pat, rcx); + constrain_bindings_in_pat(&l.pat, rcx); link_local(rcx, l); intravisit::walk_local(rcx, l); } @@ -656,10 +656,10 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { hir::ExprCall(ref callee, ref args) => { if has_method_map { - constrain_call(rcx, expr, Some(&**callee), + constrain_call(rcx, expr, Some(&callee), args.iter().map(|e| &**e), false); } else { - constrain_callee(rcx, callee.id, expr, &**callee); + constrain_callee(rcx, callee.id, expr, &callee); constrain_call(rcx, expr, None, args.iter().map(|e| &**e), false); } @@ -668,7 +668,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { } hir::ExprMethodCall(_, _, ref args) => { - constrain_call(rcx, expr, Some(&*args[0]), + constrain_call(rcx, expr, Some(&args[0]), args[1..].iter().map(|e| &**e), false); intravisit::walk_expr(rcx, expr); @@ -676,7 +676,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { hir::ExprAssignOp(_, ref lhs, ref rhs) => { if has_method_map { - constrain_call(rcx, expr, Some(&**lhs), + constrain_call(rcx, expr, Some(&lhs), Some(&**rhs).into_iter(), false); } @@ -684,7 +684,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { } hir::ExprIndex(ref lhs, ref rhs) if has_method_map => { - constrain_call(rcx, expr, Some(&**lhs), + constrain_call(rcx, expr, Some(&lhs), Some(&**rhs).into_iter(), true); intravisit::walk_expr(rcx, expr); @@ -697,7 +697,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { // overloaded op. Note that we (sadly) currently use an // implicit "by ref" sort of passing style here. This // should be converted to an adjustment! - constrain_call(rcx, expr, Some(&**lhs), + constrain_call(rcx, expr, Some(&lhs), Some(&**rhs).into_iter(), implicitly_ref_args); intravisit::walk_expr(rcx, expr); @@ -706,8 +706,8 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { hir::ExprBinary(_, ref lhs, ref rhs) => { // If you do `x OP y`, then the types of `x` and `y` must // outlive the operation you are performing. - let lhs_ty = rcx.resolve_expr_type_adjusted(&**lhs); - let rhs_ty = rcx.resolve_expr_type_adjusted(&**rhs); + let lhs_ty = rcx.resolve_expr_type_adjusted(&lhs); + let rhs_ty = rcx.resolve_expr_type_adjusted(&rhs); for &ty in &[lhs_ty, rhs_ty] { type_must_outlive(rcx, infer::Operand(expr.span), @@ -721,7 +721,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { let implicitly_ref_args = !hir_util::is_by_value_unop(op); // As above. - constrain_call(rcx, expr, Some(&**lhs), + constrain_call(rcx, expr, Some(&lhs), None::.iter(), implicitly_ref_args); intravisit::walk_expr(rcx, expr); @@ -732,7 +732,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { let method_call = MethodCall::expr(expr.id); let base_ty = match rcx.fcx.inh.tables.borrow().method_map.get(&method_call) { Some(method) => { - constrain_call(rcx, expr, Some(&**base), + constrain_call(rcx, expr, Some(&base), None::.iter(), true); let fn_ret = // late-bound regions in overloaded method calls are instantiated rcx.tcx().no_late_bound_regions(&method.ty.fn_ret()).unwrap(); @@ -750,7 +750,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { hir::ExprIndex(ref vec_expr, _) => { // For a[b], the lifetime of a must enclose the deref - let vec_type = rcx.resolve_expr_type_adjusted(&**vec_expr); + let vec_type = rcx.resolve_expr_type_adjusted(&vec_expr); constrain_index(rcx, expr, vec_type); intravisit::walk_expr(rcx, expr); @@ -760,12 +760,12 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { // Determine if we are casting `source` to a trait // instance. If so, we have to be sure that the type of // the source obeys the trait's region bound. - constrain_cast(rcx, expr, &**source); + constrain_cast(rcx, expr, &source); intravisit::walk_expr(rcx, expr); } hir::ExprAddrOf(m, ref base) => { - link_addr_of(rcx, expr, m, &**base); + link_addr_of(rcx, expr, m, &base); // Require that when you write a `&expr` expression, the // resulting pointer has a lifetime that encompasses the @@ -780,13 +780,13 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { } hir::ExprMatch(ref discr, ref arms, _) => { - link_match(rcx, &**discr, &arms[..]); + link_match(rcx, &discr, &arms[..]); intravisit::walk_expr(rcx, expr); } hir::ExprClosure(_, _, ref body) => { - check_expr_fn_block(rcx, expr, &**body); + check_expr_fn_block(rcx, expr, &body); } hir::ExprLoop(ref body, _) => { @@ -797,10 +797,10 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) { hir::ExprWhile(ref cond, ref body, _) => { let repeating_scope = rcx.set_repeating_scope(cond.id); - rcx.visit_expr(&**cond); + rcx.visit_expr(&cond); rcx.set_repeating_scope(body.id); - rcx.visit_block(&**body); + rcx.visit_block(&body); rcx.set_repeating_scope(repeating_scope); } @@ -945,7 +945,7 @@ fn constrain_call<'a, I: Iterator>(rcx: &mut Rcx, rcx, infer::CallRcvr(r.span), r.id, callee_region); if implicitly_ref_args { - link_by_ref(rcx, &*r, callee_scope); + link_by_ref(rcx, &r, callee_scope); } } } @@ -1143,7 +1143,7 @@ fn link_local(rcx: &Rcx, local: &hir::Local) { }; let mc = mc::MemCategorizationContext::new(rcx.fcx.infcx()); let discr_cmt = ignore_err!(mc.cat_expr(init_expr)); - link_pattern(rcx, mc, discr_cmt, &*local.pat); + link_pattern(rcx, mc, discr_cmt, &local.pat); } /// Computes the guarantors for any ref bindings in a match and @@ -1156,7 +1156,7 @@ fn link_match(rcx: &Rcx, discr: &hir::Expr, arms: &[hir::Arm]) { debug!("discr_cmt={:?}", discr_cmt); for arm in arms { for root_pat in &arm.pats { - link_pattern(rcx, mc, discr_cmt.clone(), &**root_pat); + link_pattern(rcx, mc, discr_cmt.clone(), &root_pat); } } } @@ -1175,7 +1175,7 @@ fn link_fn_args(rcx: &Rcx, body_scope: CodeExtent, args: &[hir::Arg]) { arg_ty, arg_cmt, arg); - link_pattern(rcx, mc, arg_cmt, &*arg.pat); + link_pattern(rcx, mc, arg_cmt, &arg.pat); } } @@ -1199,7 +1199,7 @@ fn link_pattern<'t, 'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, // `[_, ..slice, _]` pattern hir::PatVec(_, Some(ref slice_pat), _) => { - match mc.cat_slice_pattern(sub_cmt, &**slice_pat) { + match mc.cat_slice_pattern(sub_cmt, &slice_pat) { Ok((slice_cmt, slice_mutbl, slice_r)) => { link_region(rcx, sub_pat.span, &slice_r, ty::BorrowKind::from_mutbl(slice_mutbl), diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 0b77935771e44..bc4ec3adbc185 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -99,7 +99,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for SeedBorrowKind<'a, 'tcx> { fn visit_expr(&mut self, expr: &hir::Expr) { match expr.node { hir::ExprClosure(cc, _, ref body) => { - self.check_closure(expr, cc, &**body); + self.check_closure(expr, cc, &body); } _ => { } diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index c2abb074efa13..e663e449cfc4a 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -53,10 +53,10 @@ pub fn resolve_type_vars_in_fn(fcx: &FnCtxt, wbcx.visit_block(blk); for arg in &decl.inputs { wbcx.visit_node_id(ResolvingPattern(arg.pat.span), arg.id); - wbcx.visit_pat(&*arg.pat); + wbcx.visit_pat(&arg.pat); // Privacy needs the type for the whole pattern, not just each binding - if !pat_util::pat_is_binding(&fcx.tcx().def_map.borrow(), &*arg.pat) { + if !pat_util::pat_is_binding(&fcx.tcx().def_map.borrow(), &arg.pat) { wbcx.visit_node_id(ResolvingPattern(arg.pat.span), arg.pat.id); } @@ -221,7 +221,7 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> { fn visit_ty(&mut self, t: &hir::Ty) { match t.node { hir::TyFixedLengthVec(ref ty, ref count_expr) => { - self.visit_ty(&**ty); + self.visit_ty(&ty); write_ty_to_tcx(self.tcx(), count_expr.id, self.tcx().types.usize); } hir::TyBareFn(ref function_declaration) => { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 035be02b0c30a..cae2d9d890d79 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -273,7 +273,7 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> { _ => tcx.sess.bug(&format!("get_trait_def({:?}): not an item", trait_id)) }; - trait_def_of_item(self, &*item) + trait_def_of_item(self, &item) } else { tcx.lookup_trait_def(trait_id) } @@ -577,7 +577,7 @@ fn convert_field<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, v: &hir::StructField, ty_f: ty::FieldDefMaster<'tcx>) { - let tt = ccx.icx(struct_predicates).to_ty(&ExplicitRscope, &*v.node.ty); + let tt = ccx.icx(struct_predicates).to_ty(&ExplicitRscope, &v.node.ty); ty_f.fulfill_ty(tt); write_ty_to_tcx(ccx.tcx, v.node.id, tt); @@ -709,7 +709,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { debug!("convert: impl_bounds={:?}", ty_predicates); - let selfty = ccx.icx(&ty_predicates).to_ty(&ExplicitRscope, &**selfty); + let selfty = ccx.icx(&ty_predicates).to_ty(&ExplicitRscope, &selfty); write_ty_to_tcx(tcx, it.id, selfty); tcx.register_item_type(def_id, @@ -768,7 +768,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { if let hir::ImplItemKind::Const(ref ty, _) = impl_item.node { let ty = ccx.icx(&ty_predicates) - .to_ty(&ExplicitRscope, &*ty); + .to_ty(&ExplicitRscope, &ty); tcx.register_item_type(ccx.tcx.map.local_def_id(impl_item.id), TypeScheme { generics: ty_generics.clone(), @@ -1399,11 +1399,11 @@ fn type_scheme_of_def_id<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, if let Some(node_id) = ccx.tcx.map.as_local_node_id(def_id) { match ccx.tcx.map.find(node_id) { Some(hir_map::NodeItem(item)) => { - type_scheme_of_item(ccx, &*item) + type_scheme_of_item(ccx, &item) } Some(hir_map::NodeForeignItem(foreign_item)) => { let abi = ccx.tcx.map.get_foreign_abi(node_id); - type_scheme_of_foreign_item(ccx, &*foreign_item, abi) + type_scheme_of_foreign_item(ccx, &foreign_item, abi) } x => { ccx.tcx.sess.bug(&format!("unexpected sort of node \ @@ -1437,18 +1437,18 @@ fn compute_type_scheme_of_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, let tcx = ccx.tcx; match it.node { hir::ItemStatic(ref t, _, _) | hir::ItemConst(ref t, _) => { - let ty = ccx.icx(&()).to_ty(&ExplicitRscope, &**t); + let ty = ccx.icx(&()).to_ty(&ExplicitRscope, &t); ty::TypeScheme { ty: ty, generics: ty::Generics::empty() } } hir::ItemFn(ref decl, unsafety, _, abi, ref generics, _) => { let ty_generics = ty_generics_for_fn(ccx, generics, &ty::Generics::empty()); - let tofd = astconv::ty_of_bare_fn(&ccx.icx(generics), unsafety, abi, &**decl); + let tofd = astconv::ty_of_bare_fn(&ccx.icx(generics), unsafety, abi, &decl); let ty = tcx.mk_fn(Some(ccx.tcx.map.local_def_id(it.id)), tcx.mk_bare_fn(tofd)); ty::TypeScheme { ty: ty, generics: ty_generics } } hir::ItemTy(ref t, ref generics) => { let ty_generics = ty_generics_for_type_or_impl(ccx, generics); - let ty = ccx.icx(generics).to_ty(&ExplicitRscope, &**t); + let ty = ccx.icx(generics).to_ty(&ExplicitRscope, &t); ty::TypeScheme { ty: ty, generics: ty_generics } } hir::ItemEnum(ref ei, ref generics) => { @@ -1777,7 +1777,7 @@ fn ty_generic_predicates<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, &hir::WherePredicate::BoundPredicate(ref bound_pred) => { let ty = ast_ty_to_ty(&ccx.icx(&(base_predicates, ast_generics)), &ExplicitRscope, - &*bound_pred.bounded_ty); + &bound_pred.bounded_ty); for bound in bound_pred.bounds.iter() { match bound { @@ -2120,11 +2120,11 @@ fn compute_type_scheme_of_foreign_fn_decl<'a, 'tcx>( -> ty::TypeScheme<'tcx> { for i in &decl.inputs { - match (*i).pat.node { + match i.pat.node { hir::PatIdent(_, _, _) => (), hir::PatWild => (), _ => { - span_err!(ccx.tcx.sess, (*i).pat.span, E0130, + span_err!(ccx.tcx.sess, i.pat.span, E0130, "patterns aren't allowed in foreign function declarations"); } } @@ -2140,7 +2140,7 @@ fn compute_type_scheme_of_foreign_fn_decl<'a, 'tcx>( let output = match decl.output { hir::Return(ref ty) => - ty::FnConverging(ast_ty_to_ty(&ccx.icx(ast_generics), &rb, &**ty)), + ty::FnConverging(ast_ty_to_ty(&ccx.icx(ast_generics), &rb, &ty)), hir::DefaultReturn(..) => ty::FnConverging(ccx.tcx.mk_nil()), hir::NoReturn(..) => From 93e58cc28fdc978cbc967b131a7ec04bc2a90bb1 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Feb 2016 21:24:11 +0100 Subject: [PATCH 06/15] Autoderef in librustc_trans --- src/librustc_trans/back/link.rs | 2 +- src/librustc_trans/back/write.rs | 2 +- src/librustc_trans/save/dump_csv.rs | 24 ++--- src/librustc_trans/save/mod.rs | 2 +- src/librustc_trans/trans/_match.rs | 78 +++++++------- src/librustc_trans/trans/asm.rs | 11 +- src/librustc_trans/trans/base.rs | 36 +++---- src/librustc_trans/trans/callee.rs | 12 +-- src/librustc_trans/trans/closure.rs | 4 +- src/librustc_trans/trans/collector.rs | 2 +- src/librustc_trans/trans/consts.rs | 58 +++++----- src/librustc_trans/trans/controlflow.rs | 20 ++-- .../trans/debuginfo/create_scope_map.rs | 96 ++++++++--------- .../trans/debuginfo/metadata.rs | 4 +- src/librustc_trans/trans/debuginfo/mod.rs | 2 +- .../trans/debuginfo/namespace.rs | 2 +- src/librustc_trans/trans/debuginfo/utils.rs | 2 +- src/librustc_trans/trans/expr.rs | 102 +++++++++--------- src/librustc_trans/trans/foreign.rs | 6 +- src/librustc_trans/trans/glue.rs | 4 +- src/librustc_trans/trans/inline.rs | 2 +- src/librustc_trans/trans/intrinsic.rs | 10 +- src/librustc_trans/trans/mir/block.rs | 2 +- src/librustc_trans/trans/mir/rvalue.rs | 8 +- src/librustc_trans/trans/monomorphize.rs | 6 +- src/librustc_trans/trans/tvec.rs | 16 +-- src/librustc_trans/trans/type_of.rs | 14 +-- 27 files changed, 263 insertions(+), 264 deletions(-) diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index d3131f209e8a7..69a70cdf144b3 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -916,7 +916,7 @@ fn link_natively(sess: &Session, dylib: bool, pname, prog.status)) .note(&format!("{:?}", &cmd)) - .note(&*escape_string(&output[..])) + .note(&escape_string(&output[..])) .emit(); sess.abort_if_errors(); } diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 75d8e44989bf4..92d8b928ef428 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -380,7 +380,7 @@ unsafe extern "C" fn diagnostic_handler(info: DiagnosticInfoRef, user: *mut c_vo match llvm::diagnostic::Diagnostic::unpack(info) { llvm::diagnostic::InlineAsm(inline) => { report_inline_asm(cgcx, - &*llvm::twine_to_string(inline.message), + &llvm::twine_to_string(inline.message), inline.cookie); } diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index 72b65f2e45fb0..2b3899ac03ecf 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -468,7 +468,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { &name.as_str(), &qualname, &self.span.snippet(expr.span), - &ty_to_string(&*typ), + &ty_to_string(&typ), self.cur_scope); // walk type and init value @@ -550,7 +550,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { for field in variant.node.data.fields() { self.process_struct_field_def(field, variant.node.data.id()); - self.visit_ty(&*field.node.ty); + self.visit_ty(&field.node.ty); } } self.process_generic_params(ty_params, item.span, &enum_data.qualname, enum_data.id); @@ -970,7 +970,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { self.cur_scope); } Fn(ref decl, _, _, _, ref ty_params, ref body) => - self.process_fn(item, &**decl, ty_params, &**body), + self.process_fn(item, &decl, ty_params, &body), Static(ref typ, _, ref expr) => self.process_static_or_const_item(item, typ, expr), Const(ref typ, ref expr) => @@ -992,11 +992,11 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { } Ty(ref ty, ref ty_params) => { let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); - let value = ty_to_string(&**ty); + let value = ty_to_string(&ty); let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Type); self.fmt.typedef_str(item.span, sub_span, item.id, &qualname, &value); - self.visit_ty(&**ty); + self.visit_ty(&ty); self.process_generic_params(ty_params, item.span, &qualname, item.id); } Mac(_) => (), @@ -1012,7 +1012,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { } } if let Some(ref ty) = param.default { - self.visit_ty(&**ty); + self.visit_ty(&ty); } } } @@ -1024,8 +1024,8 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { self.process_const(trait_item.id, trait_item.ident.name, trait_item.span, - &*ty, - &*expr); + &ty, + &expr); } ast::TraitItemKind::Method(ref sig, ref body) => { self.process_method(sig, @@ -1113,7 +1113,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { } } ast::ExprKind::TupField(ref sub_ex, idx) => { - self.visit_expr(&**sub_ex); + self.visit_expr(&sub_ex); let hir_node = lower_expr(self.save_ctxt.lcx, sub_ex); let ty = &self.tcx.expr_ty_adjusted(&hir_node).sty; @@ -1139,15 +1139,15 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { // walk arg and return types for arg in &decl.inputs { - self.visit_ty(&*arg.ty); + self.visit_ty(&arg.ty); } if let ast::FunctionRetTy::Ty(ref ret_ty) = decl.output { - self.visit_ty(&**ret_ty); + self.visit_ty(&ret_ty); } // walk the body - self.nest(ex.id, |v| v.visit_block(&**body)); + self.nest(ex.id, |v| v.visit_block(&body)); } ast::ExprKind::ForLoop(ref pattern, ref subexpression, ref block, _) | ast::ExprKind::WhileLet(ref pattern, ref subexpression, ref block, _) => { diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index ff19640d64507..d336ab21962de 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -389,7 +389,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { match item.node { hir::ItemImpl(_, _, _, _, ref ty, _) => { let mut result = String::from("<"); - result.push_str(&rustc_front::print::pprust::ty_to_string(&**ty)); + result.push_str(&rustc_front::print::pprust::ty_to_string(&ty)); match self.tcx.trait_of_item(self.tcx.map.local_def_id(id)) { Some(def_id) => { diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index 28731aa950b52..70f8e268f1745 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -284,7 +284,7 @@ impl<'a, 'tcx> Opt<'a, 'tcx> { match *self { ConstantValue(ConstantExpr(lit_expr), _) => { let lit_ty = bcx.tcx().node_id_to_type(lit_expr.id); - let expr = consts::const_expr(ccx, &*lit_expr, bcx.fcx.param_substs, None, Yes); + let expr = consts::const_expr(ccx, &lit_expr, bcx.fcx.param_substs, None, Yes); let llval = match expr { Ok((llval, _)) => llval, Err(err) => bcx.ccx().sess().span_fatal(lit_expr.span, &err.description()), @@ -294,18 +294,18 @@ impl<'a, 'tcx> Opt<'a, 'tcx> { SingleResult(Result::new(bcx, lit_datum.val)) } ConstantRange(ConstantExpr(ref l1), ConstantExpr(ref l2), _) => { - let l1 = match consts::const_expr(ccx, &**l1, bcx.fcx.param_substs, None, Yes) { + let l1 = match consts::const_expr(ccx, &l1, bcx.fcx.param_substs, None, Yes) { Ok((l1, _)) => l1, Err(err) => bcx.ccx().sess().span_fatal(l1.span, &err.description()), }; - let l2 = match consts::const_expr(ccx, &**l2, bcx.fcx.param_substs, None, Yes) { + let l2 = match consts::const_expr(ccx, &l2, bcx.fcx.param_substs, None, Yes) { Ok((l2, _)) => l2, Err(err) => bcx.ccx().sess().span_fatal(l2.span, &err.description()), }; RangeResult(Result::new(bcx, l1), Result::new(bcx, l2)) } Variant(disr_val, ref repr, _, _) => { - SingleResult(Result::new(bcx, adt::trans_case(bcx, &**repr, disr_val))) + SingleResult(Result::new(bcx, adt::trans_case(bcx, &repr, disr_val))) } SliceLengthEqual(length, _) => { SingleResult(Result::new(bcx, C_uint(ccx, length))) @@ -479,7 +479,7 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat = match pat.node { hir::PatIdent(_, ref path, Some(ref inner)) => { bound_ptrs.push((path.node.name, val.val)); - &**inner + &inner }, _ => break } @@ -489,7 +489,7 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pats[col] = pat; Match { pats: pats, - data: &*br.data, + data: &br.data, bound_ptrs: bound_ptrs, pat_renaming_map: br.pat_renaming_map, } @@ -518,7 +518,7 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, let mut bound_ptrs = br.bound_ptrs.clone(); match this.node { hir::PatIdent(_, ref path, None) => { - if pat_is_binding(&dm.borrow(), &*this) { + if pat_is_binding(&dm.borrow(), &this) { bound_ptrs.push((path.node.name, val.val)); } } @@ -557,7 +557,7 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // Collect all of the matches that can match against anything. enter_match(bcx, dm, m, col, val, |pats| { - if pat_is_binding_or_wild(&dm.borrow(), &*pats[col]) { + if pat_is_binding_or_wild(&dm.borrow(), &pats[col]) { let mut r = pats[..col].to_vec(); r.extend_from_slice(&pats[col + 1..]); Some(r) @@ -615,11 +615,11 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>( let ctor = match opt { &ConstantValue(ConstantExpr(expr), _) => check_match::ConstantValue( - const_eval::eval_const_expr(bcx.tcx(), &*expr) + const_eval::eval_const_expr(bcx.tcx(), &expr) ), &ConstantRange(ConstantExpr(lo), ConstantExpr(hi), _) => check_match::ConstantRange( - const_eval::eval_const_expr(bcx.tcx(), &*lo), - const_eval::eval_const_expr(bcx.tcx(), &*hi) + const_eval::eval_const_expr(bcx.tcx(), &lo), + const_eval::eval_const_expr(bcx.tcx(), &hi) ), &SliceLengthEqual(n, _) => check_match::Slice(n), @@ -663,7 +663,7 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let opt = match cur.node { hir::PatLit(ref l) => { - ConstantValue(ConstantExpr(&**l), debug_loc) + ConstantValue(ConstantExpr(&l), debug_loc) } hir::PatIdent(..) | hir::PatEnum(..) | hir::PatStruct(..) => { // This is either an enum variant or a variable binding. @@ -680,7 +680,7 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } hir::PatRange(ref l1, ref l2) => { - ConstantRange(ConstantExpr(&**l1), ConstantExpr(&**l2), debug_loc) + ConstantRange(ConstantExpr(&l1), ConstantExpr(&l2), debug_loc) } hir::PatVec(ref before, None, ref after) => { SliceLengthEqual(before.len() + after.len(), debug_loc) @@ -849,7 +849,7 @@ impl FailureHandler { fn pick_column_to_specialize(def_map: &RefCell, m: &[Match]) -> Option { fn pat_score(def_map: &RefCell, pat: &hir::Pat) -> usize { match pat.node { - hir::PatIdent(_, _, Some(ref inner)) => pat_score(def_map, &**inner), + hir::PatIdent(_, _, Some(ref inner)) => pat_score(def_map, &inner), _ if pat_is_refutable(&def_map.borrow(), pat) => 1, _ => 0 } @@ -1143,7 +1143,7 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match data.arm.guard { Some(ref guard_expr) => { bcx = compile_guard(bcx, - &**guard_expr, + &guard_expr, m[0].data, &m[1..m.len()], vals, @@ -1190,7 +1190,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, }; let adt_vals = if any_irrefutable_adt_pat(bcx.tcx(), m, col) { let repr = adt::represent_type(bcx.ccx(), left_ty); - let arg_count = adt::num_args(&*repr, Disr(0)); + let arg_count = adt::num_args(&repr, Disr(0)); let (arg_count, struct_val) = if type_is_sized(bcx.tcx(), left_ty) { (arg_count, val.val) } else { @@ -1202,7 +1202,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, }; let mut field_vals: Vec = (0..arg_count).map(|ix| // By definition, these are all sized - adt::trans_field_ptr(bcx, &*repr, adt::MaybeSizedValue::sized(struct_val), Disr(0), ix) + adt::trans_field_ptr(bcx, &repr, adt::MaybeSizedValue::sized(struct_val), Disr(0), ix) ).collect(); match left_ty.sty { @@ -1218,7 +1218,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, let meta = Load(bcx, expr::get_meta(bcx, val.val)); let struct_val = adt::MaybeSizedValue::unsized_(struct_val, meta); - let data = adt::trans_field_ptr(bcx, &*repr, struct_val, Disr(0), arg_count); + let data = adt::trans_field_ptr(bcx, &repr, struct_val, Disr(0), arg_count); Store(bcx, data, expr::get_dataptr(bcx, scratch)); Store(bcx, meta, expr::get_meta(bcx, scratch)); field_vals.push(scratch); @@ -1385,7 +1385,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, match *opt { Variant(disr_val, ref repr, _, _) => { let ExtractedBlock {vals: argvals, bcx: new_bcx} = - extract_variant_args(opt_cx, &**repr, disr_val, val); + extract_variant_args(opt_cx, &repr, disr_val, val); size = argvals.len(); unpacked = argvals; opt_cx = new_bcx; @@ -1534,7 +1534,7 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &hir::Pat, let tcx = bcx.tcx(); let reassigned = is_discr_reassigned(bcx, discr, body); let mut bindings_map = FnvHashMap(); - pat_bindings(&tcx.def_map, &*pat, |bm, p_id, span, path1| { + pat_bindings(&tcx.def_map, &pat, |bm, p_id, span, path1| { let name = path1.node; let variable_ty = node_id_type(bcx, p_id); let llvariable_ty = type_of::type_of(ccx, variable_ty); @@ -1604,7 +1604,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>, let arm_datas: Vec = arms.iter().map(|arm| ArmData { bodycx: fcx.new_id_block("case_body", arm.body.id), arm: arm, - bindings_map: create_bindings_map(bcx, &*arm.pats[0], discr_expr, &*arm.body) + bindings_map: create_bindings_map(bcx, &arm.pats[0], discr_expr, &arm.body) }).collect(); let mut pat_renaming_map = if scope_cx.sess().opts.debuginfo != NoDebugInfo { @@ -1624,7 +1624,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>, let mut matches = Vec::new(); for (arm_data, pats) in arm_datas.iter().zip(&arm_pats) { matches.extend(pats.iter().map(|p| Match { - pats: vec![&**p], + pats: vec![&p], data: arm_data, bound_ptrs: Vec::new(), pat_renaming_map: pat_renaming_map.as_ref() @@ -1651,7 +1651,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>, // insert bindings into the lllocals map and add cleanups let cs = fcx.push_custom_cleanup_scope(); bcx = insert_lllocals(bcx, &arm_data.bindings_map, Some(cleanup::CustomScope(cs))); - bcx = expr::trans_into(bcx, &*arm_data.arm.body, dest); + bcx = expr::trans_into(bcx, &arm_data.arm.body, dest); bcx = fcx.pop_and_trans_custom_cleanup_scope(bcx, cs); arm_cxs.push(bcx); } @@ -1668,7 +1668,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let _icx = push_ctxt("match::store_local"); let mut bcx = bcx; let tcx = bcx.tcx(); - let pat = &*local.pat; + let pat = &local.pat; fn create_dummy_locals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, pat: &hir::Pat) @@ -1723,7 +1723,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, return mk_binding_alloca( bcx, pat.id, name, var_scope, (), "_match::store_local", - |(), bcx, Datum { val: v, .. }| expr::trans_into(bcx, &**init_expr, + |(), bcx, Datum { val: v, .. }| expr::trans_into(bcx, &init_expr, expr::SaveIn(v))); } @@ -1732,7 +1732,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // General path. let init_datum = - unpack_datum!(bcx, expr::trans_to_lvalue(bcx, &**init_expr, "let")); + unpack_datum!(bcx, expr::trans_to_lvalue(bcx, &init_expr, "let")); if bcx.sess().asm_comments() { add_comment(bcx, "creating zeroable ref llval"); } @@ -1813,7 +1813,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let ccx = bcx.ccx(); match pat.node { hir::PatIdent(pat_binding_mode, ref path1, ref inner) => { - if pat_is_binding(&tcx.def_map.borrow(), &*pat) { + if pat_is_binding(&tcx.def_map.borrow(), &pat) { // Allocate the stack slot where the value of this // binding will live and place it into the appropriate // map. @@ -1846,7 +1846,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } if let Some(ref inner_pat) = *inner { - bcx = bind_irrefutable_pat(bcx, &**inner_pat, val, cleanup_scope); + bcx = bind_irrefutable_pat(bcx, &inner_pat, val, cleanup_scope); } } hir::PatEnum(_, ref sub_pats) => { @@ -1856,14 +1856,14 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let repr = adt::represent_node(bcx, pat.id); let vinfo = ccx.tcx().lookup_adt_def(enum_id).variant_with_id(var_id); let args = extract_variant_args(bcx, - &*repr, + &repr, Disr::from(vinfo.disr_val), val); if let Some(ref sub_pat) = *sub_pats { for (i, &argval) in args.vals.iter().enumerate() { bcx = bind_irrefutable_pat( bcx, - &*sub_pat[i], + &sub_pat[i], MatchInput::from_val(argval), cleanup_scope); } @@ -1879,11 +1879,11 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let repr = adt::represent_node(bcx, pat.id); let val = adt::MaybeSizedValue::sized(val.val); for (i, elem) in elems.iter().enumerate() { - let fldptr = adt::trans_field_ptr(bcx, &*repr, + let fldptr = adt::trans_field_ptr(bcx, &repr, val, Disr(0), i); bcx = bind_irrefutable_pat( bcx, - &**elem, + &elem, MatchInput::from_val(fldptr), cleanup_scope); } @@ -1914,7 +1914,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let field_idx = pat_v.field_index(name); let mut fldptr = adt::trans_field_ptr( bcx, - &*pat_repr, + &pat_repr, val, pat_v.discr, field_idx); @@ -1930,7 +1930,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, fldptr = scratch; } bcx = bind_irrefutable_pat(bcx, - &*f.node.pat, + &f.node.pat, MatchInput::from_val(fldptr), cleanup_scope); } @@ -1939,10 +1939,10 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let repr = adt::represent_node(bcx, pat.id); let val = adt::MaybeSizedValue::sized(val.val); for (i, elem) in elems.iter().enumerate() { - let fldptr = adt::trans_field_ptr(bcx, &*repr, val, Disr(0), i); + let fldptr = adt::trans_field_ptr(bcx, &repr, val, Disr(0), i); bcx = bind_irrefutable_pat( bcx, - &**elem, + &elem, MatchInput::from_val(fldptr), cleanup_scope); } @@ -1964,7 +1964,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, val.val }; bcx = bind_irrefutable_pat( - bcx, &**inner, MatchInput::from_val(val), cleanup_scope); + bcx, &inner, MatchInput::from_val(val), cleanup_scope); } hir::PatRegion(ref inner, _) => { let pat_ty = node_id_type(bcx, inner.id); @@ -1984,7 +1984,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, }; bcx = bind_irrefutable_pat( bcx, - &**inner, + &inner, MatchInput::from_val(val), cleanup_scope); } @@ -2008,7 +2008,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, .fold(bcx, |bcx, (inner, elem)| { bind_irrefutable_pat( bcx, - &**inner, + &inner, MatchInput::from_val(elem), cleanup_scope) }); diff --git a/src/librustc_trans/trans/asm.rs b/src/librustc_trans/trans/asm.rs index 69a8a84229d47..33370abc3fcc1 100644 --- a/src/librustc_trans/trans/asm.rs +++ b/src/librustc_trans/trans/asm.rs @@ -44,10 +44,10 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) for (i, out) in ia.outputs.iter().enumerate() { constraints.push(out.constraint.clone()); - let out_datum = unpack_datum!(bcx, expr::trans(bcx, &*out.expr)); + let out_datum = unpack_datum!(bcx, expr::trans(bcx, &out.expr)); if out.is_indirect { bcx = callee::trans_arg_datum(bcx, - expr_ty(bcx, &*out.expr), + expr_ty(bcx, &out.expr), out_datum, cleanup::CustomScope(temp_scope), callee::DontAutorefArg, @@ -61,7 +61,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) outputs.push(out_datum.val); if out.is_rw { bcx = callee::trans_arg_datum(bcx, - expr_ty(bcx, &*out.expr), + expr_ty(bcx, &out.expr), out_datum, cleanup::CustomScope(temp_scope), callee::DontAutorefArg, @@ -75,9 +75,9 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) for &(ref c, ref input) in &ia.inputs { constraints.push((*c).clone()); - let in_datum = unpack_datum!(bcx, expr::trans(bcx, &**input)); + let in_datum = unpack_datum!(bcx, expr::trans(bcx, &input)); bcx = callee::trans_arg_datum(bcx, - expr_ty(bcx, &**input), + expr_ty(bcx, &input), in_datum, cleanup::CustomScope(temp_scope), callee::DontAutorefArg, @@ -159,4 +159,3 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) return bcx; } - diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 4748c62921de6..e36905c6d90ea 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -513,7 +513,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>, let repr = adt::represent_type(cx.ccx(), t); let VariantInfo { fields, discr } = VariantInfo::from_ty(cx.tcx(), t, None); for (i, &Field(_, field_ty)) in fields.iter().enumerate() { - let llfld_a = adt::trans_field_ptr(cx, &*repr, value, Disr::from(discr), i); + let llfld_a = adt::trans_field_ptr(cx, &repr, value, Disr::from(discr), i); let val = if common::type_is_sized(cx.tcx(), field_ty) { llfld_a @@ -529,7 +529,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>, ty::TyClosure(_, ref substs) => { let repr = adt::represent_type(cx.ccx(), t); for (i, upvar_ty) in substs.upvar_tys.iter().enumerate() { - let llupvar = adt::trans_field_ptr(cx, &*repr, value, Disr(0), i); + let llupvar = adt::trans_field_ptr(cx, &repr, value, Disr(0), i); cx = f(cx, llupvar, upvar_ty); } } @@ -545,7 +545,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>, ty::TyTuple(ref args) => { let repr = adt::represent_type(cx.ccx(), t); for (i, arg) in args.iter().enumerate() { - let llfld_a = adt::trans_field_ptr(cx, &*repr, value, Disr(0), i); + let llfld_a = adt::trans_field_ptr(cx, &repr, value, Disr(0), i); cx = f(cx, llfld_a, *arg); } } @@ -559,11 +559,11 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>, // NB: we must hit the discriminant first so that structural // comparison know not to proceed when the discriminants differ. - match adt::trans_switch(cx, &*repr, av, false) { + match adt::trans_switch(cx, &repr, av, false) { (_match::Single, None) => { if n_variants != 0 { assert!(n_variants == 1); - cx = iter_variant(cx, &*repr, adt::MaybeSizedValue::sized(av), + cx = iter_variant(cx, &repr, adt::MaybeSizedValue::sized(av), &en.variants[0], substs, &mut f); } } @@ -592,10 +592,10 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>, let variant_cx = fcx.new_temp_block(&format!("enum-iter-variant-{}", &variant.disr_val .to_string())); - let case_val = adt::trans_case(cx, &*repr, Disr::from(variant.disr_val)); + let case_val = adt::trans_case(cx, &repr, Disr::from(variant.disr_val)); AddCase(llswitch, case_val, variant_cx.llbb); let variant_cx = iter_variant(variant_cx, - &*repr, + &repr, value, variant, substs, @@ -1530,7 +1530,7 @@ fn has_nested_returns(tcx: &ty::ctxt, cfg: &cfg::CFG, blk_id: ast::NodeId) -> bo Some(hir_map::NodeExpr(ex)) => { if let hir::ExprRet(Some(ref ret_expr)) = ex.node { let mut visitor = FindNestedReturn::new(); - intravisit::walk_expr(&mut visitor, &**ret_expr); + intravisit::walk_expr(&mut visitor, &ret_expr); if visitor.found { return true; } @@ -2272,7 +2272,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx let repr = adt::represent_type(ccx, result_ty.unwrap()); let mut llarg_idx = fcx.arg_offset() as c_uint; for (i, arg_ty) in arg_tys.into_iter().enumerate() { - let lldestptr = adt::trans_field_ptr(bcx, &*repr, dest_val, Disr::from(disr), i); + let lldestptr = adt::trans_field_ptr(bcx, &repr, dest_val, Disr::from(disr), i); if common::type_is_fat_ptr(bcx.tcx(), arg_ty) { Store(bcx, get_param(fcx.llfn, llarg_idx), @@ -2292,7 +2292,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx } } } - adt::trans_set_discr(bcx, &*repr, dest, disr); + adt::trans_set_discr(bcx, &repr, dest, disr); } finish_fn(&fcx, bcx, result_ty, DebugLoc::None); @@ -2346,14 +2346,14 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &hir::EnumDef, sp: Span, let sess = &ccx.tcx().sess; sess.span_note_without_error(sp, - &*format!("total size: {} bytes", llsize_of_real(ccx, llty))); + &format!("total size: {} bytes", llsize_of_real(ccx, llty))); match *avar { adt::General(..) => { for (i, var) in enum_def.variants.iter().enumerate() { ccx.tcx() .sess .span_note_without_error(var.span, - &*format!("variant data: {} bytes", sizes[i])); + &format!("variant data: {} bytes", sizes[i])); } } _ => {} @@ -2505,8 +2505,8 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) { let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty()); if abi != Abi::Rust { foreign::trans_rust_fn_with_foreign_abi(ccx, - &**decl, - &**body, + &decl, + &body, &item.attrs, llfn, empty_substs, @@ -2514,8 +2514,8 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) { None); } else { trans_fn(ccx, - &**decl, - &**body, + &decl, + &body, llfn, empty_substs, item.id, @@ -2837,11 +2837,11 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { hir::ForeignItemFn(..) => { let abi = ccx.tcx().map.get_foreign_abi(id); let ty = ccx.tcx().node_id_to_type(ni.id); - let name = foreign::link_name(&*ni); + let name = foreign::link_name(&ni); foreign::register_foreign_item_fn(ccx, abi, ty, &name, &ni.attrs) } hir::ForeignItemStatic(..) => { - foreign::register_static(ccx, &*ni) + foreign::register_static(ccx, &ni) } } } diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index 29821384ae936..e8dd9840fc005 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -755,7 +755,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, let mut llargs = Vec::new(); let arg_tys = match args { - ArgExprs(a) => a.iter().map(|x| common::expr_ty_adjusted(bcx, &**x)).collect(), + ArgExprs(a) => a.iter().map(|x| common::expr_ty_adjusted(bcx, &x)).collect(), _ => panic!("expected arg exprs.") }; bcx = trans_args(bcx, @@ -835,7 +835,7 @@ fn trans_args_under_call_abi<'blk, 'tcx>( // Translate the `self` argument first. if !ignore_self { - let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &*arg_exprs[0])); + let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &arg_exprs[0])); bcx = trans_arg_datum(bcx, args[0], arg_datum, @@ -851,14 +851,14 @@ fn trans_args_under_call_abi<'blk, 'tcx>( match tuple_type.sty { ty::TyTuple(ref field_types) => { let tuple_datum = unpack_datum!(bcx, - expr::trans(bcx, &**tuple_expr)); + expr::trans(bcx, &tuple_expr)); let tuple_lvalue_datum = unpack_datum!(bcx, tuple_datum.to_lvalue_datum(bcx, "args", tuple_expr.id)); let repr = adt::represent_type(bcx.ccx(), tuple_type); - let repr_ptr = &*repr; + let repr_ptr = &repr; for (i, field_type) in field_types.iter().enumerate() { let arg_datum = tuple_lvalue_datum.get_element( bcx, @@ -971,12 +971,12 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>, } let arg_ty = if i >= num_formal_args { assert!(variadic); - common::expr_ty_adjusted(cx, &**arg_expr) + common::expr_ty_adjusted(cx, &arg_expr) } else { arg_tys[i] }; - let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &**arg_expr)); + let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &arg_expr)); bcx = trans_arg_datum(bcx, arg_ty, arg_datum, arg_cleanup_scope, DontAutorefArg, diff --git a/src/librustc_trans/trans/closure.rs b/src/librustc_trans/trans/closure.rs index 7c978cb275e25..b1db196ecef0c 100644 --- a/src/librustc_trans/trans/closure.rs +++ b/src/librustc_trans/trans/closure.rs @@ -243,7 +243,7 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>, for (i, freevar) in freevars.iter().enumerate() { let datum = expr::trans_local_var(bcx, freevar.def); let upvar_slot_dest = adt::trans_field_ptr( - bcx, &*repr, adt::MaybeSizedValue::sized(dest_addr), Disr(0), i); + bcx, &repr, adt::MaybeSizedValue::sized(dest_addr), Disr(0), i); let upvar_id = ty::UpvarId { var_id: freevar.def.var_id(), closure_expr_id: id }; match tcx.upvar_capture(upvar_id).unwrap() { @@ -255,7 +255,7 @@ pub fn trans_closure_expr<'a, 'tcx>(dest: Dest<'a, 'tcx>, } } } - adt::trans_set_discr(bcx, &*repr, dest_addr, Disr(0)); + adt::trans_set_discr(bcx, &repr, dest_addr, Disr(0)); Some(bcx) } diff --git a/src/librustc_trans/trans/collector.rs b/src/librustc_trans/trans/collector.rs index 8a4adf7414017..21cb082f0660c 100644 --- a/src/librustc_trans/trans/collector.rs +++ b/src/librustc_trans/trans/collector.rs @@ -329,7 +329,7 @@ impl<'mir, 'tcx: 'mir> CachedMir<'mir, 'tcx> { fn get_ref<'a>(&'a self) -> &'a mir::Mir<'tcx> { match *self { CachedMir::Ref(r) => r, - CachedMir::Owned(ref rc) => &**rc, + CachedMir::Owned(ref rc) => &rc, } } } diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index e1cff76cb0fb3..4f25091d343c8 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -212,7 +212,7 @@ fn const_fn_call<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let substs = ccx.tcx().mk_substs(node_id_substs(ccx, node, param_substs)); match fn_like.body().expr { Some(ref expr) => { - const_expr(ccx, &**expr, substs, Some(&fn_args), trueconst).map(|(res, _)| res) + const_expr(ccx, &expr, substs, Some(&fn_args), trueconst).map(|(res, _)| res) }, None => Ok(C_nil(ccx)), } @@ -570,7 +570,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let map_list = |exprs: &[P]| -> Result, ConstEvalFailure> { exprs.iter() - .map(|e| const_expr(cx, &**e, param_substs, fn_args, trueconst).map(|(l, _)| l)) + .map(|e| const_expr(cx, &e, param_substs, fn_args, trueconst).map(|(l, _)| l)) .collect::>>() .into_iter() .collect() @@ -578,11 +578,11 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, }; let _icx = push_ctxt("const_expr"); Ok(match e.node { - hir::ExprLit(ref lit) => const_lit(cx, e, &**lit), + hir::ExprLit(ref lit) => const_lit(cx, e, &lit), hir::ExprBinary(b, ref e1, ref e2) => { /* Neither type is bottom, and we expect them to be unified * already, so the following is safe. */ - let (te1, ty) = try!(const_expr(cx, &**e1, param_substs, fn_args, trueconst)); + let (te1, ty) = try!(const_expr(cx, &e1, param_substs, fn_args, trueconst)); debug!("const_expr_unadjusted: te1={}, ty={:?}", cx.tn().val_to_string(te1), ty); @@ -590,7 +590,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let is_float = ty.is_fp(); let signed = ty.is_signed(); - let (te2, _) = try!(const_expr(cx, &**e2, param_substs, fn_args, trueconst)); + let (te2, _) = try!(const_expr(cx, &e2, param_substs, fn_args, trueconst)); try!(check_binary_expr_validity(cx, e, ty, te1, te2, trueconst)); @@ -638,7 +638,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } } // unsafe { match b.node { }, hir::ExprUnary(u, ref inner_e) => { - let (te, ty) = try!(const_expr(cx, &**inner_e, param_substs, fn_args, trueconst)); + let (te, ty) = try!(const_expr(cx, &inner_e, param_substs, fn_args, trueconst)); try!(check_unary_expr_validity(cx, e, ty, te, trueconst)); @@ -651,20 +651,20 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } } }, hir::ExprField(ref base, field) => { - let (bv, bt) = try!(const_expr(cx, &**base, param_substs, fn_args, trueconst)); + let (bv, bt) = try!(const_expr(cx, &base, param_substs, fn_args, trueconst)); let brepr = adt::represent_type(cx, bt); let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None); let ix = vinfo.field_index(field.node); - adt::const_get_field(cx, &*brepr, bv, vinfo.discr, ix) + adt::const_get_field(cx, &brepr, bv, vinfo.discr, ix) }, hir::ExprTupField(ref base, idx) => { - let (bv, bt) = try!(const_expr(cx, &**base, param_substs, fn_args, trueconst)); + let (bv, bt) = try!(const_expr(cx, &base, param_substs, fn_args, trueconst)); let brepr = adt::represent_type(cx, bt); let vinfo = VariantInfo::from_ty(cx.tcx(), bt, None); - adt::const_get_field(cx, &*brepr, bv, vinfo.discr, idx.node) + adt::const_get_field(cx, &brepr, bv, vinfo.discr, idx.node) }, hir::ExprIndex(ref base, ref index) => { - let (bv, bt) = try!(const_expr(cx, &**base, param_substs, fn_args, trueconst)); + let (bv, bt) = try!(const_expr(cx, &base, param_substs, fn_args, trueconst)); let iv = match eval_const_expr_partial(cx.tcx(), &index, ExprTypeChecked, None) { Ok(ConstVal::Int(i)) => i as u64, Ok(ConstVal::Uint(u)) => u, @@ -716,7 +716,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, hir::ExprCast(ref base, _) => { let t_cast = ety; let llty = type_of::type_of(cx, t_cast); - let (v, t_expr) = try!(const_expr(cx, &**base, param_substs, fn_args, trueconst)); + let (v, t_expr) = try!(const_expr(cx, &base, param_substs, fn_args, trueconst)); debug!("trans_const_cast({:?} as {:?})", t_expr, t_cast); if expr::cast_is_noop(cx.tcx(), base, t_expr, t_cast) { return Ok(v); @@ -741,9 +741,9 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ) { (CastTy::Int(IntTy::CEnum), CastTy::Int(_)) => { let repr = adt::represent_type(cx, t_expr); - let discr = adt::const_get_discrim(cx, &*repr, v); + let discr = adt::const_get_discrim(cx, &repr, v); let iv = C_integral(cx.int_type(), discr.0, false); - let s = adt::is_discr_signed(&*repr) as Bool; + let s = adt::is_discr_signed(&repr) as Bool; llvm::LLVMConstIntCast(iv, llty.to_ref(), s) }, (CastTy::Int(_), CastTy::Int(_)) => { @@ -798,18 +798,18 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } else { // If this isn't the address of a static, then keep going through // normal constant evaluation. - let (v, ty) = try!(const_expr(cx, &**sub, param_substs, fn_args, trueconst)); + let (v, ty) = try!(const_expr(cx, &sub, param_substs, fn_args, trueconst)); addr_of(cx, v, type_of::align_of(cx, ty), "ref") } }, hir::ExprAddrOf(hir::MutMutable, ref sub) => { - let (v, ty) = try!(const_expr(cx, &**sub, param_substs, fn_args, trueconst)); + let (v, ty) = try!(const_expr(cx, &sub, param_substs, fn_args, trueconst)); addr_of_mut(cx, v, type_of::align_of(cx, ty), "ref_mut_slice") }, hir::ExprTup(ref es) => { let repr = adt::represent_type(cx, ety); let vals = try!(map_list(&es[..])); - adt::trans_const(cx, &*repr, Disr(0), &vals[..]) + adt::trans_const(cx, &repr, Disr(0), &vals[..]) }, hir::ExprStruct(_, ref fs, ref base_opt) => { let repr = adt::represent_type(cx, ety); @@ -817,7 +817,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let base_val = match *base_opt { Some(ref base) => Some(try!(const_expr( cx, - &**base, + &base, param_substs, fn_args, trueconst, @@ -829,9 +829,9 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let cs = fields.iter().enumerate().map(|(ix, &Field(f_name, _))| { match (fs.iter().find(|f| f_name == f.name.node), base_val) { (Some(ref f), _) => { - const_expr(cx, &*f.expr, param_substs, fn_args, trueconst).map(|(l, _)| l) + const_expr(cx, &f.expr, param_substs, fn_args, trueconst).map(|(l, _)| l) }, - (_, Some((bv, _))) => Ok(adt::const_get_field(cx, &*repr, bv, discr, ix)), + (_, Some((bv, _))) => Ok(adt::const_get_field(cx, &repr, bv, discr, ix)), (_, None) => cx.sess().span_bug(e.span, "missing struct field"), } }) @@ -842,7 +842,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, if ety.is_simd() { C_vector(&cs[..]) } else { - adt::trans_const(cx, &*repr, discr, &cs[..]) + adt::trans_const(cx, &repr, discr, &cs[..]) } }, hir::ExprVec(ref es) => { @@ -851,7 +851,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let vs = es.iter() .map(|e| const_expr( cx, - &**e, + &e, param_substs, fn_args, trueconst, @@ -871,7 +871,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let unit_ty = ety.sequence_element_type(cx.tcx()); let llunitty = type_of::type_of(cx, unit_ty); let n = cx.tcx().eval_repeat_count(count); - let unit_val = try!(const_expr(cx, &**elem, param_substs, fn_args, trueconst)).0; + let unit_val = try!(const_expr(cx, &elem, param_substs, fn_args, trueconst)).0; let vs = vec![unit_val; n]; if val_ty(unit_val) != llunitty { C_struct(cx, &vs[..], false) @@ -900,7 +900,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, match vinfo.kind() { ty::VariantKind::Unit => { let repr = adt::represent_type(cx, ety); - adt::trans_const(cx, &*repr, Disr::from(vinfo.disr_val), &[]) + adt::trans_const(cx, &repr, Disr::from(vinfo.disr_val), &[]) } ty::VariantKind::Tuple => { expr::trans_def_fn_unadjusted(cx, e, def, param_substs).val @@ -930,7 +930,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, loop { callee = match callee.node { hir::ExprBlock(ref block) => match block.expr { - Some(ref tail) => &**tail, + Some(ref tail) => &tail, None => break, }, _ => break, @@ -954,14 +954,14 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, C_vector(&arg_vals[..]) } else { let repr = adt::represent_type(cx, ety); - adt::trans_const(cx, &*repr, Disr(0), &arg_vals[..]) + adt::trans_const(cx, &repr, Disr(0), &arg_vals[..]) } } Def::Variant(enum_did, variant_did) => { let repr = adt::represent_type(cx, ety); let vinfo = cx.tcx().lookup_adt_def(enum_did).variant_with_id(variant_did); adt::trans_const(cx, - &*repr, + &repr, Disr::from(vinfo.disr_val), &arg_vals[..]) } @@ -975,12 +975,12 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, try!(const_fn_call(cx, MethodCallKey(method_call), method_did, &arg_vals, param_substs, trueconst)) }, - hir::ExprType(ref e, _) => try!(const_expr(cx, &**e, param_substs, fn_args, trueconst)).0, + hir::ExprType(ref e, _) => try!(const_expr(cx, &e, param_substs, fn_args, trueconst)).0, hir::ExprBlock(ref block) => { match block.expr { Some(ref expr) => try!(const_expr( cx, - &**expr, + &expr, param_substs, fn_args, trueconst, diff --git a/src/librustc_trans/trans/controlflow.rs b/src/librustc_trans/trans/controlflow.rs index fc3bd4f4d0233..e84e1b45cedcd 100644 --- a/src/librustc_trans/trans/controlflow.rs +++ b/src/librustc_trans/trans/controlflow.rs @@ -57,13 +57,13 @@ pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>, match s.node { hir::StmtExpr(ref e, _) | hir::StmtSemi(ref e, _) => { - bcx = trans_stmt_semi(bcx, &**e); + bcx = trans_stmt_semi(bcx, &e); } hir::StmtDecl(ref d, _) => { match d.node { hir::DeclLocal(ref local) => { - bcx = init_local(bcx, &**local); - debuginfo::create_local_var_metadata(bcx, &**local); + bcx = init_local(bcx, &local); + debuginfo::create_local_var_metadata(bcx, &local); } // Inner items are visited by `trans_item`/`trans_meth`. hir::DeclItem(_) => {}, @@ -132,7 +132,7 @@ pub fn trans_block<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match b.expr { Some(ref e) => { if !bcx.unreachable.get() { - bcx = expr::trans_into(bcx, &**e, dest); + bcx = expr::trans_into(bcx, &e, dest); } } None => { @@ -169,11 +169,11 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, if let Some(cv) = const_to_opt_uint(cond_val) { if cv == 1 { // if true { .. } [else { .. }] - bcx = trans_block(bcx, &*thn, dest); + bcx = trans_block(bcx, &thn, dest); trans::debuginfo::clear_source_location(bcx.fcx); } else { if let Some(elexpr) = els { - bcx = expr::trans_into(bcx, &*elexpr, dest); + bcx = expr::trans_into(bcx, &elexpr, dest); trans::debuginfo::clear_source_location(bcx.fcx); } } @@ -183,7 +183,7 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let name = format!("then-block-{}-", thn.id); let then_bcx_in = bcx.fcx.new_id_block(&name[..], thn.id); - let then_bcx_out = trans_block(then_bcx_in, &*thn, dest); + let then_bcx_out = trans_block(then_bcx_in, &thn, dest); trans::debuginfo::clear_source_location(bcx.fcx); let cond_source_loc = cond.debug_loc(); @@ -192,7 +192,7 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match els { Some(elexpr) => { let else_bcx_in = bcx.fcx.new_id_block("else-block", elexpr.id); - let else_bcx_out = expr::trans_into(else_bcx_in, &*elexpr, dest); + let else_bcx_out = expr::trans_into(else_bcx_in, &elexpr, dest); next_bcx = bcx.fcx.join_blocks(if_id, &[then_bcx_out, else_bcx_out]); CondBr(bcx, cond_val, then_bcx_in.llbb, else_bcx_in.llbb, cond_source_loc); @@ -365,13 +365,13 @@ pub fn trans_ret<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let mut bcx = bcx; let dest = match (fcx.llretslotptr.get(), retval_expr) { (Some(_), Some(retval_expr)) => { - let ret_ty = expr_ty_adjusted(bcx, &*retval_expr); + let ret_ty = expr_ty_adjusted(bcx, &retval_expr); expr::SaveIn(fcx.get_ret_slot(bcx, ty::FnConverging(ret_ty), "ret_slot")) } _ => expr::Ignore, }; if let Some(x) = retval_expr { - bcx = expr::trans_into(bcx, &*x, dest); + bcx = expr::trans_into(bcx, &x, dest); match dest { expr::SaveIn(slot) if fcx.needs_ret_allocas => { Store(bcx, slot, fcx.llretslotptr.get().unwrap()); diff --git a/src/librustc_trans/trans/debuginfo/create_scope_map.rs b/src/librustc_trans/trans/debuginfo/create_scope_map.rs index 237d31c47783d..bbbc9c4eda468 100644 --- a/src/librustc_trans/trans/debuginfo/create_scope_map.rs +++ b/src/librustc_trans/trans/debuginfo/create_scope_map.rs @@ -47,7 +47,7 @@ pub fn create_scope_map(cx: &CrateContext, // Push argument identifiers onto the stack so arguments integrate nicely // with variable shadowing. for arg in args { - pat_util::pat_bindings_ident(def_map, &*arg.pat, |_, node_id, _, path1| { + pat_util::pat_bindings_ident(def_map, &arg.pat, |_, node_id, _, path1| { scope_stack.push(ScopeStackEntry { scope_metadata: fn_metadata, name: Some(path1.node.unhygienic_name) }); scope_map.insert(node_id, fn_metadata); @@ -122,15 +122,15 @@ fn walk_block(cx: &CrateContext, match statement.node { hir::StmtDecl(ref decl, _) => - walk_decl(cx, &**decl, scope_stack, scope_map), + walk_decl(cx, &decl, scope_stack, scope_map), hir::StmtExpr(ref exp, _) | hir::StmtSemi(ref exp, _) => - walk_expr(cx, &**exp, scope_stack, scope_map), + walk_expr(cx, &exp, scope_stack, scope_map), } } if let Some(ref exp) = block.expr { - walk_expr(cx, &**exp, scope_stack, scope_map); + walk_expr(cx, &exp, scope_stack, scope_map); } } @@ -142,10 +142,10 @@ fn walk_decl(cx: &CrateContext, codemap::Spanned { node: hir::DeclLocal(ref local), .. } => { scope_map.insert(local.id, scope_stack.last().unwrap().scope_metadata); - walk_pattern(cx, &*local.pat, scope_stack, scope_map); + walk_pattern(cx, &local.pat, scope_stack, scope_map); if let Some(ref exp) = local.init { - walk_expr(cx, &**exp, scope_stack, scope_map); + walk_expr(cx, &exp, scope_stack, scope_map); } } _ => () @@ -167,7 +167,7 @@ fn walk_pattern(cx: &CrateContext, // Check if this is a binding. If so we need to put it on the // scope stack and maybe introduce an artificial scope - if pat_util::pat_is_binding(&def_map.borrow(), &*pat) { + if pat_util::pat_is_binding(&def_map.borrow(), &pat) { let name = path1.node.unhygienic_name; @@ -231,7 +231,7 @@ fn walk_pattern(cx: &CrateContext, scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata); if let Some(ref sub_pat) = *sub_pat_opt { - walk_pattern(cx, &**sub_pat, scope_stack, scope_map); + walk_pattern(cx, &sub_pat, scope_stack, scope_map); } } @@ -244,7 +244,7 @@ fn walk_pattern(cx: &CrateContext, if let Some(ref sub_pats) = *sub_pats_opt { for p in sub_pats { - walk_pattern(cx, &**p, scope_stack, scope_map); + walk_pattern(cx, &p, scope_stack, scope_map); } } } @@ -260,7 +260,7 @@ fn walk_pattern(cx: &CrateContext, node: hir::FieldPat { pat: ref sub_pat, .. }, .. } in field_pats { - walk_pattern(cx, &**sub_pat, scope_stack, scope_map); + walk_pattern(cx, &sub_pat, scope_stack, scope_map); } } @@ -268,39 +268,39 @@ fn walk_pattern(cx: &CrateContext, scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata); for sub_pat in sub_pats { - walk_pattern(cx, &**sub_pat, scope_stack, scope_map); + walk_pattern(cx, &sub_pat, scope_stack, scope_map); } } hir::PatBox(ref sub_pat) | hir::PatRegion(ref sub_pat, _) => { scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata); - walk_pattern(cx, &**sub_pat, scope_stack, scope_map); + walk_pattern(cx, &sub_pat, scope_stack, scope_map); } hir::PatLit(ref exp) => { scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata); - walk_expr(cx, &**exp, scope_stack, scope_map); + walk_expr(cx, &exp, scope_stack, scope_map); } hir::PatRange(ref exp1, ref exp2) => { scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata); - walk_expr(cx, &**exp1, scope_stack, scope_map); - walk_expr(cx, &**exp2, scope_stack, scope_map); + walk_expr(cx, &exp1, scope_stack, scope_map); + walk_expr(cx, &exp2, scope_stack, scope_map); } hir::PatVec(ref front_sub_pats, ref middle_sub_pats, ref back_sub_pats) => { scope_map.insert(pat.id, scope_stack.last().unwrap().scope_metadata); for sub_pat in front_sub_pats { - walk_pattern(cx, &**sub_pat, scope_stack, scope_map); + walk_pattern(cx, &sub_pat, scope_stack, scope_map); } if let Some(ref sub_pat) = *middle_sub_pats { - walk_pattern(cx, &**sub_pat, scope_stack, scope_map); + walk_pattern(cx, &sub_pat, scope_stack, scope_map); } for sub_pat in back_sub_pats { - walk_pattern(cx, &**sub_pat, scope_stack, scope_map); + walk_pattern(cx, &sub_pat, scope_stack, scope_map); } } } @@ -324,73 +324,73 @@ fn walk_expr(cx: &CrateContext, hir::ExprAddrOf(_, ref sub_exp) | hir::ExprField(ref sub_exp, _) | hir::ExprTupField(ref sub_exp, _) => - walk_expr(cx, &**sub_exp, scope_stack, scope_map), + walk_expr(cx, &sub_exp, scope_stack, scope_map), hir::ExprBox(ref sub_expr) => { - walk_expr(cx, &**sub_expr, scope_stack, scope_map); + walk_expr(cx, &sub_expr, scope_stack, scope_map); } hir::ExprRet(ref exp_opt) => match *exp_opt { - Some(ref sub_exp) => walk_expr(cx, &**sub_exp, scope_stack, scope_map), + Some(ref sub_exp) => walk_expr(cx, &sub_exp, scope_stack, scope_map), None => () }, hir::ExprUnary(_, ref sub_exp) => { - walk_expr(cx, &**sub_exp, scope_stack, scope_map); + walk_expr(cx, &sub_exp, scope_stack, scope_map); } hir::ExprAssignOp(_, ref lhs, ref rhs) | hir::ExprIndex(ref lhs, ref rhs) | hir::ExprBinary(_, ref lhs, ref rhs) => { - walk_expr(cx, &**lhs, scope_stack, scope_map); - walk_expr(cx, &**rhs, scope_stack, scope_map); + walk_expr(cx, &lhs, scope_stack, scope_map); + walk_expr(cx, &rhs, scope_stack, scope_map); } hir::ExprRange(ref start, ref end) => { - start.as_ref().map(|e| walk_expr(cx, &**e, scope_stack, scope_map)); - end.as_ref().map(|e| walk_expr(cx, &**e, scope_stack, scope_map)); + start.as_ref().map(|e| walk_expr(cx, &e, scope_stack, scope_map)); + end.as_ref().map(|e| walk_expr(cx, &e, scope_stack, scope_map)); } hir::ExprVec(ref init_expressions) | hir::ExprTup(ref init_expressions) => { for ie in init_expressions { - walk_expr(cx, &**ie, scope_stack, scope_map); + walk_expr(cx, &ie, scope_stack, scope_map); } } hir::ExprAssign(ref sub_exp1, ref sub_exp2) | hir::ExprRepeat(ref sub_exp1, ref sub_exp2) => { - walk_expr(cx, &**sub_exp1, scope_stack, scope_map); - walk_expr(cx, &**sub_exp2, scope_stack, scope_map); + walk_expr(cx, &sub_exp1, scope_stack, scope_map); + walk_expr(cx, &sub_exp2, scope_stack, scope_map); } hir::ExprIf(ref cond_exp, ref then_block, ref opt_else_exp) => { - walk_expr(cx, &**cond_exp, scope_stack, scope_map); + walk_expr(cx, &cond_exp, scope_stack, scope_map); with_new_scope(cx, then_block.span, scope_stack, scope_map, |cx, scope_stack, scope_map| { - walk_block(cx, &**then_block, scope_stack, scope_map); + walk_block(cx, &then_block, scope_stack, scope_map); }); match *opt_else_exp { Some(ref else_exp) => - walk_expr(cx, &**else_exp, scope_stack, scope_map), + walk_expr(cx, &else_exp, scope_stack, scope_map), _ => () } } hir::ExprWhile(ref cond_exp, ref loop_body, _) => { - walk_expr(cx, &**cond_exp, scope_stack, scope_map); + walk_expr(cx, &cond_exp, scope_stack, scope_map); with_new_scope(cx, loop_body.span, scope_stack, scope_map, |cx, scope_stack, scope_map| { - walk_block(cx, &**loop_body, scope_stack, scope_map); + walk_block(cx, &loop_body, scope_stack, scope_map); }) } @@ -401,7 +401,7 @@ fn walk_expr(cx: &CrateContext, scope_stack, scope_map, |cx, scope_stack, scope_map| { - walk_block(cx, &**block, scope_stack, scope_map); + walk_block(cx, &block, scope_stack, scope_map); }) } @@ -412,29 +412,29 @@ fn walk_expr(cx: &CrateContext, scope_map, |cx, scope_stack, scope_map| { for &hir::Arg { pat: ref pattern, .. } in &decl.inputs { - walk_pattern(cx, &**pattern, scope_stack, scope_map); + walk_pattern(cx, &pattern, scope_stack, scope_map); } - walk_block(cx, &**block, scope_stack, scope_map); + walk_block(cx, &block, scope_stack, scope_map); }) } hir::ExprCall(ref fn_exp, ref args) => { - walk_expr(cx, &**fn_exp, scope_stack, scope_map); + walk_expr(cx, &fn_exp, scope_stack, scope_map); for arg_exp in args { - walk_expr(cx, &**arg_exp, scope_stack, scope_map); + walk_expr(cx, &arg_exp, scope_stack, scope_map); } } hir::ExprMethodCall(_, _, ref args) => { for arg_exp in args { - walk_expr(cx, &**arg_exp, scope_stack, scope_map); + walk_expr(cx, &arg_exp, scope_stack, scope_map); } } hir::ExprMatch(ref discriminant_exp, ref arms, _) => { - walk_expr(cx, &**discriminant_exp, scope_stack, scope_map); + walk_expr(cx, &discriminant_exp, scope_stack, scope_map); // For each arm we have to first walk the pattern as these might // introduce new artificial scopes. It should be sufficient to @@ -450,25 +450,25 @@ fn walk_expr(cx: &CrateContext, scope_map, |cx, scope_stack, scope_map| { for pat in &arm_ref.pats { - walk_pattern(cx, &**pat, scope_stack, scope_map); + walk_pattern(cx, &pat, scope_stack, scope_map); } if let Some(ref guard_exp) = arm_ref.guard { - walk_expr(cx, &**guard_exp, scope_stack, scope_map) + walk_expr(cx, &guard_exp, scope_stack, scope_map) } - walk_expr(cx, &*arm_ref.body, scope_stack, scope_map); + walk_expr(cx, &arm_ref.body, scope_stack, scope_map); }) } } hir::ExprStruct(_, ref fields, ref base_exp) => { for &hir::Field { expr: ref exp, .. } in fields { - walk_expr(cx, &**exp, scope_stack, scope_map); + walk_expr(cx, &exp, scope_stack, scope_map); } match *base_exp { - Some(ref exp) => walk_expr(cx, &**exp, scope_stack, scope_map), + Some(ref exp) => walk_expr(cx, &exp, scope_stack, scope_map), None => () } } @@ -478,11 +478,11 @@ fn walk_expr(cx: &CrateContext, .. }) => { // inputs, outputs: Vec<(String, P)> for &(_, ref exp) in inputs { - walk_expr(cx, &**exp, scope_stack, scope_map); + walk_expr(cx, &exp, scope_stack, scope_map); } for out in outputs { - walk_expr(cx, &*out.expr, scope_stack, scope_map); + walk_expr(cx, &out.expr, scope_stack, scope_map); } } } diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index fe37006e5cf73..843aebc443722 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/trans/debuginfo/metadata.rs @@ -1919,7 +1919,7 @@ pub fn create_local_var_metadata(bcx: Block, local: &hir::Local) { let def_map = &cx.tcx().def_map; let locals = bcx.fcx.lllocals.borrow(); - pat_util::pat_bindings(def_map, &*local.pat, |_, node_id, span, var_name| { + pat_util::pat_bindings(def_map, &local.pat, |_, node_id, span, var_name| { let datum = match locals.get(&node_id) { Some(datum) => datum, None => { @@ -2099,7 +2099,7 @@ pub fn create_argument_metadata(bcx: Block, arg: &hir::Arg) { .fn_metadata; let locals = bcx.fcx.lllocals.borrow(); - pat_util::pat_bindings(def_map, &*arg.pat, |_, node_id, span, var_name| { + pat_util::pat_bindings(def_map, &arg.pat, |_, node_id, span, var_name| { let datum = match locals.get(&node_id) { Some(v) => v, None => { diff --git a/src/librustc_trans/trans/debuginfo/mod.rs b/src/librustc_trans/trans/debuginfo/mod.rs index 702721157be51..11dd631bee1fa 100644 --- a/src/librustc_trans/trans/debuginfo/mod.rs +++ b/src/librustc_trans/trans/debuginfo/mod.rs @@ -399,7 +399,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let scope_map = create_scope_map::create_scope_map(cx, &fn_decl.inputs, - &*top_level_block, + &top_level_block, fn_metadata, fn_ast_id); diff --git a/src/librustc_trans/trans/debuginfo/namespace.rs b/src/librustc_trans/trans/debuginfo/namespace.rs index 533f8d7bad7ad..0c2c29724a1d7 100644 --- a/src/librustc_trans/trans/debuginfo/namespace.rs +++ b/src/librustc_trans/trans/debuginfo/namespace.rs @@ -34,7 +34,7 @@ impl NamespaceTreeNode { pub fn mangled_name_of_contained_item(&self, item_name: &str) -> String { fn fill_nested(node: &NamespaceTreeNode, output: &mut String) { match node.parent { - Some(ref parent) => fill_nested(&*parent.upgrade().unwrap(), output), + Some(ref parent) => fill_nested(&parent.upgrade().unwrap(), output), None => {} } let string = node.name.as_str(); diff --git a/src/librustc_trans/trans/debuginfo/utils.rs b/src/librustc_trans/trans/debuginfo/utils.rs index e581e19d4330e..c1d7bb495fafd 100644 --- a/src/librustc_trans/trans/debuginfo/utils.rs +++ b/src/librustc_trans/trans/debuginfo/utils.rs @@ -46,7 +46,7 @@ pub fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray { pub fn contains_nodebug_attribute(attributes: &[ast::Attribute]) -> bool { attributes.iter().any(|attr| { - let meta_item: &ast::MetaItem = &*attr.node.value; + let meta_item: &ast::MetaItem = &attr.node.value; match meta_item.node { ast::MetaItemKind::Word(ref value) => &value[..] == "no_debug", _ => false diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index e411ed3469179..fac956c1ddd20 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -650,39 +650,39 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match expr.node { hir::ExprType(ref e, _) => { - trans(bcx, &**e) + trans(bcx, &e) } hir::ExprPath(..) => { trans_def(bcx, expr, bcx.def(expr.id)) } hir::ExprField(ref base, name) => { - trans_rec_field(bcx, &**base, name.node) + trans_rec_field(bcx, &base, name.node) } hir::ExprTupField(ref base, idx) => { - trans_rec_tup_field(bcx, &**base, idx.node) + trans_rec_tup_field(bcx, &base, idx.node) } hir::ExprIndex(ref base, ref idx) => { - trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id)) + trans_index(bcx, expr, &base, &idx, MethodCall::expr(expr.id)) } hir::ExprBox(ref contents) => { // Special case for `Box` let box_ty = expr_ty(bcx, expr); - let contents_ty = expr_ty(bcx, &**contents); + let contents_ty = expr_ty(bcx, &contents); match box_ty.sty { ty::TyBox(..) => { - trans_uniq_expr(bcx, expr, box_ty, &**contents, contents_ty) + trans_uniq_expr(bcx, expr, box_ty, &contents, contents_ty) } _ => bcx.sess().span_bug(expr.span, "expected unique box") } } - hir::ExprLit(ref lit) => trans_immediate_lit(bcx, expr, &**lit), + hir::ExprLit(ref lit) => trans_immediate_lit(bcx, expr, &lit), hir::ExprBinary(op, ref lhs, ref rhs) => { - trans_binary(bcx, expr, op, &**lhs, &**rhs) + trans_binary(bcx, expr, op, &lhs, &rhs) } hir::ExprUnary(op, ref x) => { - trans_unary(bcx, expr, op, &**x) + trans_unary(bcx, expr, op, &x) } hir::ExprAddrOf(_, ref x) => { match x.node { @@ -695,18 +695,18 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, false); fcx.push_ast_cleanup_scope(cleanup_debug_loc); let datum = unpack_datum!( - bcx, tvec::trans_slice_vec(bcx, expr, &**x)); + bcx, tvec::trans_slice_vec(bcx, expr, &x)); bcx = fcx.pop_and_trans_ast_cleanup_scope(bcx, x.id); DatumBlock::new(bcx, datum) } _ => { - trans_addr_of(bcx, expr, &**x) + trans_addr_of(bcx, expr, &x) } } } hir::ExprCast(ref val, _) => { // Datum output mode means this is a scalar cast: - trans_imm_cast(bcx, &**val, expr.id) + trans_imm_cast(bcx, &val, expr.id) } _ => { bcx.tcx().sess.span_bug( @@ -737,7 +737,7 @@ fn trans_field<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, bcx, vinfo.fields[ix].1, |srcval| { - adt::trans_field_ptr(bcx, &*repr, srcval, vinfo.discr, ix) + adt::trans_field_ptr(bcx, &repr, srcval, vinfo.discr, ix) }); if type_is_sized(bcx.tcx(), d.ty) { @@ -938,7 +938,7 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, controlflow::trans_break(bcx, expr, label_opt.map(|l| l.node.name)) } hir::ExprType(ref e, _) => { - trans_into(bcx, &**e, Ignore) + trans_into(bcx, &e, Ignore) } hir::ExprAgain(label_opt) => { controlflow::trans_cont(bcx, expr, label_opt.map(|l| l.node.name)) @@ -959,7 +959,7 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // directly. This avoids having to manage a return slot when // it won't actually be used anyway. if let &Some(ref x) = ex { - bcx = trans_into(bcx, &**x, Ignore); + bcx = trans_into(bcx, &x, Ignore); } // Mark the end of the block as unreachable. Once we get to // a return expression, there's no more we should be doing @@ -969,14 +969,14 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } hir::ExprWhile(ref cond, ref body, _) => { - controlflow::trans_while(bcx, expr, &**cond, &**body) + controlflow::trans_while(bcx, expr, &cond, &body) } hir::ExprLoop(ref body, _) => { - controlflow::trans_loop(bcx, expr, &**body) + controlflow::trans_loop(bcx, expr, &body) } hir::ExprAssign(ref dst, ref src) => { - let src_datum = unpack_datum!(bcx, trans(bcx, &**src)); - let dst_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &**dst, "assign")); + let src_datum = unpack_datum!(bcx, trans(bcx, &src)); + let dst_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &dst, "assign")); if bcx.fcx.type_needs_drop(dst_datum.ty) { // If there are destructors involved, make sure we @@ -1031,12 +1031,12 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, .contains_key(&MethodCall::expr(expr.id)); if has_method_map { - let dst = unpack_datum!(bcx, trans(bcx, &**dst)); - let src_datum = unpack_datum!(bcx, trans(bcx, &**src)); + let dst = unpack_datum!(bcx, trans(bcx, &dst)); + let src_datum = unpack_datum!(bcx, trans(bcx, &src)); trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), dst, Some((src_datum, src.id)), None, false).bcx } else { - trans_assign_op(bcx, expr, op, &**dst, &**src) + trans_assign_op(bcx, expr, op, &dst, &src) } } hir::ExprInlineAsm(ref a) => { @@ -1064,19 +1064,19 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match expr.node { hir::ExprType(ref e, _) => { - trans_into(bcx, &**e, dest) + trans_into(bcx, &e, dest) } hir::ExprPath(..) => { trans_def_dps_unadjusted(bcx, expr, bcx.def(expr.id), dest) } hir::ExprIf(ref cond, ref thn, ref els) => { - controlflow::trans_if(bcx, expr.id, &**cond, &**thn, els.as_ref().map(|e| &**e), dest) + controlflow::trans_if(bcx, expr.id, &cond, &thn, els.as_ref().map(|e| &**e), dest) } hir::ExprMatch(ref discr, ref arms, _) => { - _match::trans_match(bcx, expr, &**discr, &arms[..], dest) + _match::trans_match(bcx, expr, &discr, &arms[..], dest) } hir::ExprBlock(ref blk) => { - controlflow::trans_block(bcx, &**blk, dest) + controlflow::trans_block(bcx, &blk, dest) } hir::ExprStruct(_, ref fields, ref base) => { trans_struct(bcx, @@ -1201,13 +1201,13 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, if bcx.tcx().is_method_call(expr.id) { trans_overloaded_call(bcx, expr, - &**f, + &f, &args[..], Some(dest)) } else { callee::trans_call(bcx, expr, - &**f, + &f, callee::ArgExprs(&args[..]), dest) } @@ -1215,28 +1215,28 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, hir::ExprMethodCall(_, _, ref args) => { callee::trans_method_call(bcx, expr, - &*args[0], + &args[0], callee::ArgExprs(&args[..]), dest) } hir::ExprBinary(op, ref lhs, ref rhs) => { // if not overloaded, would be RvalueDatumExpr - let lhs = unpack_datum!(bcx, trans(bcx, &**lhs)); - let rhs_datum = unpack_datum!(bcx, trans(bcx, &**rhs)); + let lhs = unpack_datum!(bcx, trans(bcx, &lhs)); + let rhs_datum = unpack_datum!(bcx, trans(bcx, &rhs)); trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), lhs, Some((rhs_datum, rhs.id)), Some(dest), !rustc_front::util::is_by_value_binop(op.node)).bcx } hir::ExprUnary(op, ref subexpr) => { // if not overloaded, would be RvalueDatumExpr - let arg = unpack_datum!(bcx, trans(bcx, &**subexpr)); + let arg = unpack_datum!(bcx, trans(bcx, &subexpr)); trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), arg, None, Some(dest), !rustc_front::util::is_by_value_unop(op)).bcx } hir::ExprIndex(ref base, ref idx) => { // if not overloaded, would be RvalueDatumExpr - let base = unpack_datum!(bcx, trans(bcx, &**base)); - let idx_datum = unpack_datum!(bcx, trans(bcx, &**idx)); + let base = unpack_datum!(bcx, trans(bcx, &base)); + let idx_datum = unpack_datum!(bcx, trans(bcx, &idx)); trans_overloaded_op(bcx, expr, MethodCall::expr(expr.id), base, Some((idx_datum, idx.id)), Some(dest), true).bcx } @@ -1286,7 +1286,7 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // Nullary variant. let ty = expr_ty(bcx, ref_expr); let repr = adt::represent_type(bcx.ccx(), ty); - adt::trans_set_discr(bcx, &*repr, lldest, Disr::from(variant.disr_val)); + adt::trans_set_discr(bcx, &repr, lldest, Disr::from(variant.disr_val)); return bcx; } } @@ -1295,7 +1295,7 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match ty.sty { ty::TyStruct(def, _) if def.has_dtor() => { let repr = adt::represent_type(bcx.ccx(), ty); - adt::trans_set_discr(bcx, &*repr, lldest, Disr(0)); + adt::trans_set_discr(bcx, &repr, lldest, Disr(0)); } _ => {} } @@ -1505,7 +1505,7 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, let mut vec_val = C_undef(llty); for &(i, ref e) in fields { - let block_datum = trans(bcx, &**e); + let block_datum = trans(bcx, &e); bcx = block_datum.bcx; let position = C_uint(bcx.ccx(), i); let value = block_datum.datum.to_llscalarish(bcx); @@ -1518,7 +1518,7 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, // First, trans field expressions to temporary scratch values. let scratch_vals: Vec<_> = fields.iter().map(|&(i, ref e)| { - let datum = unpack_datum!(bcx, trans(bcx, &**e)); + let datum = unpack_datum!(bcx, trans(bcx, &e)); (i, datum) }).collect(); @@ -1528,20 +1528,20 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, assert_eq!(discr, Disr(0)); let addr = adt::MaybeSizedValue::sized(addr); - match expr_kind(bcx.tcx(), &*base.expr) { + match expr_kind(bcx.tcx(), &base.expr) { ExprKind::RvalueDps | ExprKind::RvalueDatum if !bcx.fcx.type_needs_drop(ty) => { - bcx = trans_into(bcx, &*base.expr, SaveIn(addr.value)); + bcx = trans_into(bcx, &base.expr, SaveIn(addr.value)); }, ExprKind::RvalueStmt => { bcx.tcx().sess.bug("unexpected expr kind for struct base expr") } _ => { - let base_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &*base.expr, "base")); + let base_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, &base.expr, "base")); for &(i, t) in &base.fields { let datum = base_datum.get_element( - bcx, t, |srcval| adt::trans_field_ptr(bcx, &*repr, srcval, discr, i)); + bcx, t, |srcval| adt::trans_field_ptr(bcx, &repr, srcval, discr, i)); assert!(type_is_sized(bcx.tcx(), datum.ty)); - let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i); + let dest = adt::trans_field_ptr(bcx, &repr, addr, discr, i); bcx = datum.store_to(bcx, dest); } } @@ -1549,16 +1549,16 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, // Finally, move scratch field values into actual field locations for (i, datum) in scratch_vals { - let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i); + let dest = adt::trans_field_ptr(bcx, &repr, addr, discr, i); bcx = datum.store_to(bcx, dest); } } else { // No base means we can write all fields directly in place. let addr = adt::MaybeSizedValue::sized(addr); for &(i, ref e) in fields { - let dest = adt::trans_field_ptr(bcx, &*repr, addr, discr, i); - let e_ty = expr_ty_adjusted(bcx, &**e); - bcx = trans_into(bcx, &**e, SaveIn(dest)); + let dest = adt::trans_field_ptr(bcx, &repr, addr, discr, i); + let e_ty = expr_ty_adjusted(bcx, &e); + bcx = trans_into(bcx, &e, SaveIn(dest)); let scope = cleanup::CustomScope(custom_cleanup_scope); fcx.schedule_lifetime_end(scope, dest); // FIXME: nonzeroing move should generalize to fields @@ -1566,7 +1566,7 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, } } - adt::trans_set_discr(bcx, &*repr, addr, discr); + adt::trans_set_discr(bcx, &repr, addr, discr); fcx.pop_custom_cleanup_scope(custom_cleanup_scope); @@ -2112,10 +2112,10 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let datum = unpack_datum!( bcx, datum.to_lvalue_datum(bcx, "trans_imm_cast", expr.id)); let llexpr_ptr = datum.to_llref(); - let discr = adt::trans_get_discr(bcx, &*repr, llexpr_ptr, + let discr = adt::trans_get_discr(bcx, &repr, llexpr_ptr, Some(Type::i64(ccx)), true); ll_t_in = val_ty(discr); - (discr, adt::is_discr_signed(&*repr)) + (discr, adt::is_discr_signed(&repr)) } else { (datum.to_llscalarish(bcx), t_in.is_signed()) }; @@ -2165,7 +2165,7 @@ fn trans_assign_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let lhs = immediate_rvalue(lhs, dst.ty); // Evaluate RHS - FIXME(#28160) this sucks - let rhs = unpack_datum!(bcx, trans(bcx, &*src)); + let rhs = unpack_datum!(bcx, trans(bcx, &src)); let rhs = unpack_datum!(bcx, rhs.to_rvalue_datum(bcx, "assign_op_rhs")); // Perform computation and store the result diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index 5a909888bd86d..b96f2cd45cf95 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -472,10 +472,10 @@ fn gate_simd_ffi(tcx: &ty::ctxt, decl: &hir::FnDecl, ty: &ty::BareFnTy) { }; let sig = &ty.sig.0; for (input, ty) in decl.inputs.iter().zip(&sig.inputs) { - check(&*input.ty, *ty) + check(&input.ty, *ty) } if let hir::Return(ref ty) = decl.output { - check(&**ty, sig.output.unwrap()) + check(&ty, sig.output.unwrap()) } } } @@ -491,7 +491,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &hir::ForeignMod) { abi => { let ty = ccx.tcx().node_id_to_type(foreign_item.id); match ty.sty { - ty::TyBareFn(_, bft) => gate_simd_ffi(ccx.tcx(), &**decl, bft), + ty::TyBareFn(_, bft) => gate_simd_ffi(ccx.tcx(), &decl, bft), _ => ccx.tcx().sess.span_bug(foreign_item.span, "foreign fn's sty isn't a bare_fn_ty?") } diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index 12aa2e2e3ea6c..5cb6a7344f1a1 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -298,7 +298,7 @@ fn trans_struct_drop_flag<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, assert!(type_is_sized(bcx.tcx(), t), "Precondition: caller must ensure t is sized"); let repr = adt::represent_type(bcx.ccx(), t); - let drop_flag = unpack_datum!(bcx, adt::trans_drop_flag_ptr(bcx, &*repr, struct_data)); + let drop_flag = unpack_datum!(bcx, adt::trans_drop_flag_ptr(bcx, &repr, struct_data)); let loaded = load_ty(bcx, drop_flag.val, bcx.tcx().dtor_type()); let drop_flag_llty = type_of(bcx.fcx.ccx, bcx.tcx().dtor_type()); let init_val = C_integral(drop_flag_llty, adt::DTOR_NEEDED as u64, false); @@ -402,7 +402,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in // Don't use type_of::sizing_type_of because that expects t to be sized. assert!(!t.is_simd()); let repr = adt::represent_type(ccx, t); - let sizing_type = adt::sizing_type_context_of(ccx, &*repr, true); + let sizing_type = adt::sizing_type_context_of(ccx, &repr, true); debug!("DST {} sizing_type: {}", t, sizing_type.to_string()); let sized_size = llsize_of_alloc(ccx, sizing_type.prefix()); let sized_align = llalign_of_min(ccx, sizing_type.prefix()); diff --git a/src/librustc_trans/trans/inline.rs b/src/librustc_trans/trans/inline.rs index baf244c2e7960..4c647152458f4 100644 --- a/src/librustc_trans/trans/inline.rs +++ b/src/librustc_trans/trans/inline.rs @@ -120,7 +120,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId) -> Option { _ => ccx.sess().bug("instantiate_inline: item has a \ non-enum, non-struct parent") } - trans_item(ccx, &**item); + trans_item(ccx, &item); my_id } FoundAst::FoundParent(_, _) => { diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index 018d4535d0cf1..188fb7de9dd83 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -225,7 +225,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, // efficient (these are done efficiently implicitly in C // with the `__m128i` type and so this means Rust doesn't // lose out there). - let expr = &*arg_exprs[0]; + let expr = &arg_exprs[0]; let datum = unpack_datum!(bcx, expr::trans(bcx, expr)); let datum = unpack_datum!(bcx, datum.to_rvalue_datum(bcx, "transmute_temp")); let val = if datum.kind.is_by_ref() { @@ -253,7 +253,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, expr::SaveIn(d) => expr::SaveIn(PointerCast(bcx, d, llintype.ptr_to())), expr::Ignore => expr::Ignore }; - bcx = expr::trans_into(bcx, &*arg_exprs[0], dest); + bcx = expr::trans_into(bcx, &arg_exprs[0], dest); dest }; @@ -404,7 +404,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, } }; - let simple = get_simple_intrinsic(ccx, &*foreign_item); + let simple = get_simple_intrinsic(ccx, &foreign_item); let llval = match (simple, &*name) { (Some(llfn), _) => { Call(bcx, llfn, &llargs, None, call_debug_location) @@ -658,7 +658,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, match val_ty.sty { ty::TyEnum(..) => { let repr = adt::represent_type(ccx, *val_ty); - adt::trans_get_discr(bcx, &*repr, llargs[0], + adt::trans_get_discr(bcx, &repr, llargs[0], Some(llret_ty), true) } _ => C_null(llret_ty) @@ -849,7 +849,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, assert!(!bcx.fcx.type_needs_drop(arg_type)); let repr = adt::represent_type(bcx.ccx(), arg_type); - let repr_ptr = &*repr; + let repr_ptr = &repr; let arg = adt::MaybeSizedValue::sized(llarg); (0..contents.len()) .map(|i| { diff --git a/src/librustc_trans/trans/mir/block.rs b/src/librustc_trans/trans/mir/block.rs index b3b8214a9a70d..875f09c02e889 100644 --- a/src/librustc_trans/trans/mir/block.rs +++ b/src/librustc_trans/trans/mir/block.rs @@ -67,7 +67,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { assert_eq!(adt_def.variants.len(), targets.len()); for (adt_variant, target) in adt_def.variants.iter().zip(targets) { let llval = bcx.with_block(|bcx| - adt::trans_case(bcx, &*repr, Disr::from(adt_variant.disr_val)) + adt::trans_case(bcx, &repr, Disr::from(adt_variant.disr_val)) ); let llbb = self.llblock(*target); build::AddCase(switch, llval, llbb) diff --git a/src/librustc_trans/trans/mir/rvalue.rs b/src/librustc_trans/trans/mir/rvalue.rs index ab0c299af05ce..2468601afa57a 100644 --- a/src/librustc_trans/trans/mir/rvalue.rs +++ b/src/librustc_trans/trans/mir/rvalue.rs @@ -106,7 +106,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { let repr = adt::represent_type(bcx.ccx(), dest.ty.to_ty(bcx.tcx())); let disr = Disr::from(adt_def.variants[index].disr_val); bcx.with_block(|bcx| { - adt::trans_set_discr(bcx, &*repr, dest.llval, Disr::from(disr)); + adt::trans_set_discr(bcx, &repr, dest.llval, Disr::from(disr)); }); for (i, operand) in operands.iter().enumerate() { let op = self.trans_operand(&bcx, operand); @@ -114,7 +114,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { if !common::type_is_zero_size(bcx.ccx(), op.ty) { let val = adt::MaybeSizedValue::sized(dest.llval); let lldest_i = bcx.with_block(|bcx| { - adt::trans_field_ptr(bcx, &*repr, val, disr, i) + adt::trans_field_ptr(bcx, &repr, val, disr, i) }); self.store_operand(&bcx, lldest_i, op); } @@ -234,9 +234,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { let repr = adt::represent_type(bcx.ccx(), operand.ty); let llval = operand.immediate(); let discr = bcx.with_block(|bcx| { - adt::trans_get_discr(bcx, &*repr, llval, None, true) + adt::trans_get_discr(bcx, &repr, llval, None, true) }); - (discr, common::val_ty(discr), adt::is_discr_signed(&*repr)) + (discr, common::val_ty(discr), adt::is_discr_signed(&repr)) } else { (operand.immediate(), ll_t_in, operand.ty.is_signed()) }; diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs index cda62c238476e..867ac9b8376fb 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -183,12 +183,12 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, if needs_body { if abi != Abi::Rust { foreign::trans_rust_fn_with_foreign_abi( - ccx, &**decl, &**body, &[], d, psubsts, fn_node_id, + ccx, &decl, &body, &[], d, psubsts, fn_node_id, Some(&hash[..])); } else { trans_fn(ccx, - &**decl, - &**body, + &decl, + &body, d, psubsts, fn_node_id, diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index b3f783a974d9b..d6573e96b02a3 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -206,7 +206,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match dest { Ignore => { for element in elements { - bcx = expr::trans_into(bcx, &**element, Ignore); + bcx = expr::trans_into(bcx, &element, Ignore); } } @@ -216,7 +216,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let lleltptr = GEPi(bcx, lldest, &[i]); debug!("writing index {} with lleltptr={}", i, bcx.val_to_string(lleltptr)); - bcx = expr::trans_into(bcx, &**element, + bcx = expr::trans_into(bcx, &element, SaveIn(lleltptr)); let scope = cleanup::CustomScope(temp_scope); // Issue #30822: mark memory as dropped after running destructor @@ -230,14 +230,14 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, hir::ExprRepeat(ref element, ref count_expr) => { match dest { Ignore => { - return expr::trans_into(bcx, &**element, Ignore); + return expr::trans_into(bcx, &element, Ignore); } SaveIn(lldest) => { - match bcx.tcx().eval_repeat_count(&**count_expr) { - 0 => expr::trans_into(bcx, &**element, Ignore), - 1 => expr::trans_into(bcx, &**element, SaveIn(lldest)), + match bcx.tcx().eval_repeat_count(&count_expr) { + 0 => expr::trans_into(bcx, &element, Ignore), + 1 => expr::trans_into(bcx, &element, SaveIn(lldest)), count => { - let elem = unpack_datum!(bcx, expr::trans(bcx, &**element)); + let elem = unpack_datum!(bcx, expr::trans(bcx, &element)); let bcx = iter_vec_loop(bcx, lldest, vt, C_uint(bcx.ccx(), count), |set_bcx, lleltptr, _| { @@ -285,7 +285,7 @@ fn elements_required(bcx: Block, content_expr: &hir::Expr) -> usize { }, hir::ExprVec(ref es) => es.len(), hir::ExprRepeat(_, ref count_expr) => { - bcx.tcx().eval_repeat_count(&**count_expr) + bcx.tcx().eval_repeat_count(&count_expr) } _ => bcx.tcx().sess.span_bug(content_expr.span, "unexpected vec content") diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs index 4b5a0b0551276..0f88269a2c9e9 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -226,7 +226,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ ty::TyTuple(..) | ty::TyEnum(..) | ty::TyClosure(..) => { let repr = adt::represent_type(cx, t); - adt::sizing_type_of(cx, &*repr, false) + adt::sizing_type_of(cx, &repr, false) } ty::TyStruct(..) => { @@ -243,7 +243,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ Type::vector(&llet, n) } else { let repr = adt::represent_type(cx, t); - adt::sizing_type_of(cx, &*repr, false) + adt::sizing_type_of(cx, &repr, false) } } @@ -359,7 +359,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> let repr = adt::represent_type(cx, t); let tps = substs.types.get_slice(subst::TypeSpace); let name = llvm_type_name(cx, def.did, tps); - adt::incomplete_type_of(cx, &*repr, &name[..]) + adt::incomplete_type_of(cx, &repr, &name[..]) } ty::TyClosure(..) => { // Only create the named struct, but don't fill it in. We @@ -369,7 +369,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> // inherited from their environment, so we use entire // contents of the VecPerParamSpace to construct the llvm // name - adt::incomplete_type_of(cx, &*repr, "closure") + adt::incomplete_type_of(cx, &repr, "closure") } ty::TyBox(ty) | @@ -423,7 +423,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> ty::TyTuple(ref tys) if tys.is_empty() => Type::nil(cx), ty::TyTuple(..) => { let repr = adt::represent_type(cx, t); - adt::type_of(cx, &*repr) + adt::type_of(cx, &repr) } ty::TyStruct(def, ref substs) => { if t.is_simd() { @@ -444,7 +444,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> let repr = adt::represent_type(cx, t); let tps = substs.types.get_slice(subst::TypeSpace); let name = llvm_type_name(cx, def.did, tps); - adt::incomplete_type_of(cx, &*repr, &name[..]) + adt::incomplete_type_of(cx, &repr, &name[..]) } } @@ -465,7 +465,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> ty::TyEnum(..) | ty::TyStruct(..) | ty::TyClosure(..) if !t.is_simd() => { let repr = adt::represent_type(cx, t); - adt::finish_type_of(cx, &*repr, &mut llty); + adt::finish_type_of(cx, &repr, &mut llty); } _ => () } From 8ac5f87db8c485e2d659f331f2bfa5d53a498d76 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Feb 2016 21:27:42 +0100 Subject: [PATCH 07/15] Autoderef in librustc_resolve --- src/librustc_resolve/lib.rs | 72 ++++++++++++------------- src/librustc_resolve/resolve_imports.rs | 8 +-- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index a3082cb698a8e..f0e4d7578e373 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -438,25 +438,25 @@ fn resolve_struct_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>, help_msg = format!("To reference an item from the \ `{module}` module, use \ `{module}::{ident}`", - module = &*path, + module = path, ident = ident.node); } ExprMethodCall(ident, _, _) => { help_msg = format!("To call a function from the \ `{module}` module, use \ `{module}::{ident}(..)`", - module = &*path, + module = path, ident = ident.node); } ExprCall(_, _) => { help_msg = format!("No function corresponds to `{module}(..)`", - module = &*path); + module = path); } _ => { } // no help available } } else { help_msg = format!("Module `{module}` cannot be the value of an expression", - module = &*path); + module = path); } if !help_msg.is_empty() { @@ -577,7 +577,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> { self.resolve_expr(expr); } fn visit_local(&mut self, local: &Local) { - execute_callback!(hir_map::Node::NodeLocal(&*local.pat), self); + execute_callback!(hir_map::Node::NodeLocal(&local.pat), self); self.resolve_local(local); } fn visit_ty(&mut self, ty: &Ty) { @@ -1331,8 +1331,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { match search_parent_externals(name, &self.current_module) { Some(module) => { let path_str = names_to_string(module_path); - let target_mod_str = module_to_string(&*module); - let current_mod_str = module_to_string(&*self.current_module); + let target_mod_str = module_to_string(&module); + let current_mod_str = module_to_string(&self.current_module); let prefix = if target_mod_str == current_mod_str { "self::".to_string() @@ -1400,7 +1400,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { debug!("(resolving module path for import) processing `{}` rooted at `{}`", names_to_string(module_path), - module_to_string(&*module_)); + module_to_string(&module_)); // Resolve the module prefix, if any. let module_prefix_result = self.resolve_module_prefix(module_, module_path); @@ -1494,7 +1494,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { debug!("(resolving item in lexical scope) resolving `{}` in namespace {:?} in `{}`", name, namespace, - module_to_string(&*module_)); + module_to_string(&module_)); // Proceed up the scope chain looking for parent modules. let mut search_module = module_; @@ -1502,7 +1502,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // Resolve the name in the parent module. match self.resolve_name_in_module(search_module, name, namespace, true, record_used) { Failed(Some((span, msg))) => { - resolve_error(self, span, ResolutionError::FailedToResolve(&*msg)); + resolve_error(self, span, ResolutionError::FailedToResolve(&msg)); } Failed(None) => (), // Continue up the search chain. Indeterminate => { @@ -1592,7 +1592,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // Now loop through all the `super`s we find. while i < module_path.len() && "super" == module_path[i].as_str() { debug!("(resolving module prefix) resolving `super` at {}", - module_to_string(&*containing_module)); + module_to_string(&containing_module)); match self.get_nearest_normal_module_parent(containing_module) { None => return Failed(None), Some(new_module) => { @@ -1603,7 +1603,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } debug!("(resolving module prefix) finished resolving prefix at {}", - module_to_string(&*containing_module)); + module_to_string(&containing_module)); return Success(PrefixFound(containing_module, i)); } @@ -1770,7 +1770,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { ItemImpl(_, _, ref generics, ref opt_trait_ref, ref self_type, ref impl_items) => { self.resolve_implementation(generics, opt_trait_ref, - &**self_type, + &self_type, item.id, impl_items); } @@ -1965,9 +1965,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // Add each argument to the rib. let mut bindings_list = HashMap::new(); for argument in &declaration.inputs { - self.resolve_pattern(&*argument.pat, ArgumentIrrefutableMode, &mut bindings_list); + self.resolve_pattern(&argument.pat, ArgumentIrrefutableMode, &mut bindings_list); - self.visit_ty(&*argument.ty); + self.visit_ty(&argument.ty); debug!("(resolving function) recorded argument"); } @@ -1997,7 +1997,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let mut err = resolve_struct_error(self, trait_path.span, - ResolutionError::IsNotATrait(&*path_names_to_string(trait_path, + ResolutionError::IsNotATrait(&path_names_to_string(trait_path, path_depth))); // If it's a typedef, give a note @@ -2011,7 +2011,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } else { resolve_error(self, trait_path.span, - ResolutionError::UndeclaredTraitName(&*path_names_to_string(trait_path, + ResolutionError::UndeclaredTraitName(&path_names_to_string(trait_path, path_depth))); Err(()) } @@ -2165,7 +2165,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { if let Some((did, ref trait_ref)) = self.current_trait_ref { if !self.trait_item_map.contains_key(&(name, did)) { let path_str = path_names_to_string(&trait_ref.path, 0); - resolve_error(self, span, err(name, &*path_str)); + resolve_error(self, span, err(name, &path_str)); } } } @@ -2178,7 +2178,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { walk_list!(self, visit_expr, &local.init); // Resolve the pattern. - self.resolve_pattern(&*local.pat, LocalIrrefutableMode, &mut HashMap::new()); + self.resolve_pattern(&local.pat, LocalIrrefutableMode, &mut HashMap::new()); } // build a map from pattern identifiers to binding-info's. @@ -2204,9 +2204,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { if arm.pats.is_empty() { return; } - let map_0 = self.binding_mode_map(&*arm.pats[0]); + let map_0 = self.binding_mode_map(&arm.pats[0]); for (i, p) in arm.pats.iter().enumerate() { - let map_i = self.binding_mode_map(&**p); + let map_i = self.binding_mode_map(&p); for (&key, &binding_0) in &map_0 { match map_i.get(&key) { @@ -2241,7 +2241,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let mut bindings_list = HashMap::new(); for pattern in &arm.pats { - self.resolve_pattern(&**pattern, RefutableMode, &mut bindings_list); + self.resolve_pattern(&pattern, RefutableMode, &mut bindings_list); } // This has to happen *after* we determine which @@ -2249,7 +2249,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { self.check_consistent_bindings(arm); walk_list!(self, visit_expr, &arm.guard); - self.visit_expr(&*arm.body); + self.visit_expr(&arm.body); if !self.resolved { self.value_ribs.pop(); @@ -2340,7 +2340,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { ty.span, ResolutionError::UseOfUndeclared( kind, - &*path_names_to_string(path, + &path_names_to_string(path, 0)) ); } @@ -2616,7 +2616,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { self, path.span, ResolutionError::DoesNotNameAStruct( - &*path_names_to_string(path, 0)) + &path_names_to_string(path, 0)) ); self.record_def(pattern.id, err_path_resolution()); } @@ -2672,7 +2672,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { Failed(err) => { match err { Some((span, msg)) => { - resolve_error(self, span, ResolutionError::FailedToResolve(&*msg)); + resolve_error(self, span, ResolutionError::FailedToResolve(&msg)); } None => (), } @@ -2804,7 +2804,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { match self.resolve_item_in_lexical_scope(module, name, namespace, record_used) { Success(binding) => binding.def().map(LocalDef::from_def), Failed(Some((span, msg))) => { - resolve_error(self, span, ResolutionError::FailedToResolve(&*msg)); + resolve_error(self, span, ResolutionError::FailedToResolve(&msg)); None } _ => None, @@ -2927,7 +2927,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } }; - resolve_error(self, span, ResolutionError::FailedToResolve(&*msg)); + resolve_error(self, span, ResolutionError::FailedToResolve(&msg)); return None; } Indeterminate => return None, @@ -2982,7 +2982,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } }; - resolve_error(self, span, ResolutionError::FailedToResolve(&*msg)); + resolve_error(self, span, ResolutionError::FailedToResolve(&msg)); return None; } @@ -3064,8 +3064,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { -> Option<(Path, NodeId, FallbackChecks)> { match t.node { TyPath(None, ref path) => Some((path.clone(), t.id, allow)), - TyPtr(ref mut_ty) => extract_path_and_node_id(&*mut_ty.ty, OnlyTraitAndStatics), - TyRptr(_, ref mut_ty) => extract_path_and_node_id(&*mut_ty.ty, allow), + TyPtr(ref mut_ty) => extract_path_and_node_id(&mut_ty.ty, OnlyTraitAndStatics), + TyRptr(_, ref mut_ty) => extract_path_and_node_id(&mut_ty.ty, allow), // This doesn't handle the remaining `Ty` variants as they are not // that commonly the self_type, it might be interesting to provide // support for those in future. @@ -3183,7 +3183,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { .flat_map(|rib| rib.bindings.keys()); if let Some(found) = find_best_match_for_name(names, name, None) { - if name != &*found { + if name != found { return SuggestionType::Function(found); } } SuggestionType::NotFound @@ -3229,7 +3229,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let mut err = resolve_struct_error(self, expr.span, - ResolutionError::StructVariantUsedAsFunction(&*path_name)); + ResolutionError::StructVariantUsedAsFunction(&path_name)); let msg = format!("did you mean to write: `{} {{ /* fields */ }}`?", path_name); @@ -3270,7 +3270,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { Some(Def::Struct(..)) => { let mut err = resolve_struct_error(self, expr.span, - ResolutionError::StructVariantUsedAsFunction(&*path_name)); + ResolutionError::StructVariantUsedAsFunction(&path_name)); let msg = format!("did you mean to write: `{} {{ /* fields */ }}`?", path_name); @@ -3346,7 +3346,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { resolve_error(self, expr.span, ResolutionError::UnresolvedName( - &*path_name, &*msg, context)); + &path_name, &msg, context)); } } } @@ -3367,7 +3367,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { resolve_error(self, path.span, ResolutionError::DoesNotNameAStruct( - &*path_names_to_string(path, 0)) + &path_names_to_string(path, 0)) ); self.record_def(expr.id, err_path_resolution()); } diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 6667e48987087..f21ffb9b9a16d 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -238,7 +238,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> { -> Vec> { let mut errors = Vec::new(); debug!("(resolving imports for module subtree) resolving {}", - module_to_string(&*module_)); + module_to_string(&module_)); let orig_module = replace(&mut self.resolver.current_module, module_); errors.extend(self.resolve_imports_for_module(module_)); self.resolver.current_module = orig_module; @@ -268,7 +268,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> { if module.all_imports_resolved() { debug!("(resolving imports for module) all imports resolved for {}", - module_to_string(&*module)); + module_to_string(&module)); return errors; } @@ -320,7 +320,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> { -> ResolveResult<()> { debug!("(resolving import for module) resolving import `{}::...` in `{}`", names_to_string(&import_directive.module_path), - module_to_string(&*module_)); + module_to_string(&module_)); self.resolver .resolve_module_path(module_, @@ -370,7 +370,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> { debug!("(resolving single import) resolving `{}` = `{}::{}` from `{}` id {}, last \ private {:?}", target, - module_to_string(&*target_module), + module_to_string(&target_module), source, module_to_string(module_), directive.id, From 650c082b1e56519939da80be79248b9e32335e95 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Feb 2016 21:28:53 +0100 Subject: [PATCH 08/15] Autoderef in librustc_privacy --- src/librustc_privacy/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 929ec523f639f..85c2fe0c0a568 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -855,7 +855,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &hir::Expr) { match expr.node { hir::ExprField(ref base, name) => { - if let ty::TyStruct(def, _) = self.tcx.expr_ty_adjusted(&**base).sty { + if let ty::TyStruct(def, _) = self.tcx.expr_ty_adjusted(&base).sty { self.check_field(expr.span, def, def.struct_variant(), @@ -863,7 +863,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> { } } hir::ExprTupField(ref base, idx) => { - if let ty::TyStruct(def, _) = self.tcx.expr_ty_adjusted(&**base).sty { + if let ty::TyStruct(def, _) = self.tcx.expr_ty_adjusted(&base).sty { self.check_field(expr.span, def, def.struct_variant(), @@ -1238,7 +1238,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> at_outer_type: true, outer_type_is_public_path: false, }; - visitor.visit_ty(&**self_); + visitor.visit_ty(&self_); self_contains_private = visitor.contains_private; self_is_public_path = visitor.outer_type_is_public_path; } @@ -1395,7 +1395,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> } &hir::WherePredicate::RegionPredicate(_) => {} &hir::WherePredicate::EqPredicate(ref eq_pred) => { - self.visit_ty(&*eq_pred.ty); + self.visit_ty(&eq_pred.ty); } } } From d12adae719ad6cd1bfc4cfe3fc5d20b09757290a Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Feb 2016 21:29:57 +0100 Subject: [PATCH 09/15] Autoderef in librustc_plugin --- src/librustc_plugin/load.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_plugin/load.rs b/src/librustc_plugin/load.rs index 51eec07505a42..c2f8d092b08fd 100644 --- a/src/librustc_plugin/load.rs +++ b/src/librustc_plugin/load.rs @@ -68,7 +68,7 @@ pub fn load_plugins(sess: &Session, cstore: &CStore, krate: &ast::Crate, } let args = plugin.meta_item_list().map(ToOwned::to_owned).unwrap_or_default(); - loader.load_plugin(plugin.span, &*plugin.name(), args); + loader.load_plugin(plugin.span, &plugin.name(), args); } } From 003879ccaa2c290fad32e870576346ba635291d3 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Feb 2016 21:30:52 +0100 Subject: [PATCH 10/15] Autoderef in librustc_passes --- src/librustc_passes/consts.rs | 30 +++++++++++++++--------------- src/librustc_passes/loops.rs | 8 ++++---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index 60cc658eeca8f..50dd33ca993cf 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -266,20 +266,20 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { assert_eq!(self.mode, Mode::Var); match i.node { hir::ItemStatic(_, hir::MutImmutable, ref expr) => { - self.check_static_type(&**expr); - self.global_expr(Mode::Static, &**expr); + self.check_static_type(&expr); + self.global_expr(Mode::Static, &expr); } hir::ItemStatic(_, hir::MutMutable, ref expr) => { - self.check_static_mut_type(&**expr); - self.global_expr(Mode::StaticMut, &**expr); + self.check_static_mut_type(&expr); + self.global_expr(Mode::StaticMut, &expr); } hir::ItemConst(_, ref expr) => { - self.global_expr(Mode::Const, &**expr); + self.global_expr(Mode::Const, &expr); } hir::ItemEnum(ref enum_definition, _) => { for var in &enum_definition.variants { if let Some(ref ex) = var.node.disr_expr { - self.global_expr(Mode::Const, &**ex); + self.global_expr(Mode::Const, &ex); } } } @@ -293,7 +293,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { match t.node { hir::ConstTraitItem(_, ref default) => { if let Some(ref expr) = *default { - self.global_expr(Mode::Const, &*expr); + self.global_expr(Mode::Const, &expr); } else { intravisit::walk_trait_item(self, t); } @@ -305,7 +305,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { fn visit_impl_item(&mut self, i: &'v hir::ImplItem) { match i.node { hir::ImplItemKind::Const(_, ref expr) => { - self.global_expr(Mode::Const, &*expr); + self.global_expr(Mode::Const, &expr); } _ => self.with_mode(Mode::Var, |v| intravisit::walk_impl_item(v, i)), } @@ -323,11 +323,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { fn visit_pat(&mut self, p: &hir::Pat) { match p.node { hir::PatLit(ref lit) => { - self.global_expr(Mode::Const, &**lit); + self.global_expr(Mode::Const, &lit); } hir::PatRange(ref start, ref end) => { - self.global_expr(Mode::Const, &**start); - self.global_expr(Mode::Const, &**end); + self.global_expr(Mode::Const, &start); + self.global_expr(Mode::Const, &end); match const_eval::compare_lit_exprs(self.tcx, start, end) { Some(Ordering::Less) | @@ -379,17 +379,17 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { match ex.node { hir::ExprCall(ref callee, ref args) => { for arg in args { - self.visit_expr(&**arg) + self.visit_expr(&arg) } let inner = self.qualif; - self.visit_expr(&**callee); + self.visit_expr(&callee); // The callee's size doesn't count in the call. let added = self.qualif - inner; self.qualif = inner | (added - ConstQualif::NON_ZERO_SIZED); } hir::ExprRepeat(ref element, _) => { - self.visit_expr(&**element); + self.visit_expr(&element); // The count is checked elsewhere (typeck). let count = match node_ty.sty { ty::TyArray(_, n) => n, @@ -631,7 +631,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, loop { callee = match callee.node { hir::ExprBlock(ref block) => match block.expr { - Some(ref tail) => &**tail, + Some(ref tail) => &tail, None => break }, _ => break diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index bce18d3fe6eed..a89627aea82fb 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -42,14 +42,14 @@ impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> { fn visit_expr(&mut self, e: &hir::Expr) { match e.node { hir::ExprWhile(ref e, ref b, _) => { - self.visit_expr(&**e); - self.with_context(Loop, |v| v.visit_block(&**b)); + self.visit_expr(&e); + self.with_context(Loop, |v| v.visit_block(&b)); } hir::ExprLoop(ref b, _) => { - self.with_context(Loop, |v| v.visit_block(&**b)); + self.with_context(Loop, |v| v.visit_block(&b)); } hir::ExprClosure(_, _, ref b) => { - self.with_context(Closure, |v| v.visit_block(&**b)); + self.with_context(Closure, |v| v.visit_block(&b)); } hir::ExprBreak(_) => self.require_loop("break", e.span), hir::ExprAgain(_) => self.require_loop("continue", e.span), From 53b7464e678395b5bc503d0855bfb29d0ac4ab8b Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Feb 2016 21:32:51 +0100 Subject: [PATCH 11/15] Autoderef in librustc_mir --- src/librustc_mir/build/scope.rs | 2 +- src/librustc_mir/hair/cx/expr.rs | 4 ++-- src/librustc_mir/hair/cx/pattern.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index 87c6e2a672750..3d7c61cd2c1b4 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -488,7 +488,7 @@ impl<'a,'tcx> Builder<'a,'tcx> { let funcdid = match self.hir.tcx().lang_items.require(lang_item) { Ok(d) => d, Err(m) => { - self.hir.tcx().sess.fatal(&*m) + self.hir.tcx().sess.fatal(&m) } }; Constant { diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index f9a9c99f63d5e..90d049cdc731a 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -114,7 +114,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { } hir::ExprBlock(ref blk) => { - ExprKind::Block { body: &**blk } + ExprKind::Block { body: &blk } } hir::ExprAssign(ref lhs, ref rhs) => { @@ -277,7 +277,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { }); ExprKind::Closure { closure_id: def_id, - substs: &**substs, + substs: &substs, upvars: upvars, } } diff --git a/src/librustc_mir/hair/cx/pattern.rs b/src/librustc_mir/hair/cx/pattern.rs index e1a533ce42cca..5985a88382e2f 100644 --- a/src/librustc_mir/hair/cx/pattern.rs +++ b/src/librustc_mir/hair/cx/pattern.rs @@ -90,7 +90,7 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> { Some(const_expr) => { let pat = const_eval::const_expr_to_pat(self.cx.tcx, const_expr, pat.span); - return self.to_pattern(&*pat); + return self.to_pattern(&pat); } None => { self.cx.tcx.sess.span_bug( From 65b38f304d63a39d1a03a09381135d399c2f4e78 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Feb 2016 21:37:21 +0100 Subject: [PATCH 12/15] Autoderef in librustc_metadata --- src/librustc_metadata/astencode.rs | 6 +-- src/librustc_metadata/creader.rs | 4 +- src/librustc_metadata/csearch.rs | 86 +++++++++++++++--------------- src/librustc_metadata/cstore.rs | 2 +- src/librustc_metadata/decoder.rs | 10 ++-- src/librustc_metadata/encoder.rs | 20 +++---- 6 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index cdbb684470314..3a0bd3aa2059d 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -173,7 +173,7 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata, match *ii { InlinedItem::Item(ref i) => { debug!(">>> DECODED ITEM >>>\n{}\n<<< DECODED ITEM <<<", - ::rustc_front::print::pprust::item_to_string(&**i)); + ::rustc_front::print::pprust::item_to_string(&i)); } _ => { } } @@ -1404,8 +1404,8 @@ fn test_simplification() { ).unwrap()))); match (item_out, item_exp) { (InlinedItem::Item(item_out), InlinedItem::Item(item_exp)) => { - assert!(pprust::item_to_string(&*item_out) == - pprust::item_to_string(&*item_exp)); + assert!(pprust::item_to_string(&item_out) == + pprust::item_to_string(&item_exp)); } _ => panic!() } diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 52456251f962b..35d7a0d4b9c27 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -264,7 +264,7 @@ impl<'a> CrateReader<'a> { incompatible with this version of rustc", name, crate_rustc_version - .as_ref().map(|s|&**s) + .as_ref().map(|s| &**s) .unwrap_or("an old version of rustc") ); } @@ -494,7 +494,7 @@ impl<'a> CrateReader<'a> { let source_name = format!("<{} macros>", item.ident); let mut macros = vec![]; decoder::each_exported_macro(ekrate.metadata.as_slice(), - &*self.cstore.intr, + &self.cstore.intr, |name, attrs, span, body| { // NB: Don't use parse::parse_tts_from_source_str because it parses with // quote_depth > 0. diff --git a/src/librustc_metadata/csearch.rs b/src/librustc_metadata/csearch.rs index 5eade3bc0a54e..9b534df075bef 100644 --- a/src/librustc_metadata/csearch.rs +++ b/src/librustc_metadata/csearch.rs @@ -40,64 +40,64 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { fn stability(&self, def: DefId) -> Option { let cdata = self.get_crate_data(def.krate); - decoder::get_stability(&*cdata, def.index) + decoder::get_stability(&cdata, def.index) } fn deprecation(&self, def: DefId) -> Option { let cdata = self.get_crate_data(def.krate); - decoder::get_deprecation(&*cdata, def.index) + decoder::get_deprecation(&cdata, def.index) } fn closure_kind(&self, _tcx: &ty::ctxt<'tcx>, def_id: DefId) -> ty::ClosureKind { assert!(!def_id.is_local()); let cdata = self.get_crate_data(def_id.krate); - decoder::closure_kind(&*cdata, def_id.index) + decoder::closure_kind(&cdata, def_id.index) } fn closure_ty(&self, tcx: &ty::ctxt<'tcx>, def_id: DefId) -> ty::ClosureTy<'tcx> { assert!(!def_id.is_local()); let cdata = self.get_crate_data(def_id.krate); - decoder::closure_ty(&*cdata, def_id.index, tcx) + decoder::closure_ty(&cdata, def_id.index, tcx) } fn item_variances(&self, def: DefId) -> ty::ItemVariances { let cdata = self.get_crate_data(def.krate); - decoder::get_item_variances(&*cdata, def.index) + decoder::get_item_variances(&cdata, def.index) } fn repr_attrs(&self, def: DefId) -> Vec { let cdata = self.get_crate_data(def.krate); - decoder::get_repr_attrs(&*cdata, def.index) + decoder::get_repr_attrs(&cdata, def.index) } fn item_type(&self, tcx: &ty::ctxt<'tcx>, def: DefId) -> ty::TypeScheme<'tcx> { let cdata = self.get_crate_data(def.krate); - decoder::get_type(&*cdata, def.index, tcx) + decoder::get_type(&cdata, def.index, tcx) } fn item_predicates(&self, tcx: &ty::ctxt<'tcx>, def: DefId) -> ty::GenericPredicates<'tcx> { let cdata = self.get_crate_data(def.krate); - decoder::get_predicates(&*cdata, def.index, tcx) + decoder::get_predicates(&cdata, def.index, tcx) } fn item_super_predicates(&self, tcx: &ty::ctxt<'tcx>, def: DefId) -> ty::GenericPredicates<'tcx> { let cdata = self.get_crate_data(def.krate); - decoder::get_super_predicates(&*cdata, def.index, tcx) + decoder::get_super_predicates(&cdata, def.index, tcx) } fn item_attrs(&self, def_id: DefId) -> Vec { let cdata = self.get_crate_data(def_id.krate); - decoder::get_item_attrs(&*cdata, def_id.index) + decoder::get_item_attrs(&cdata, def_id.index) } fn item_symbol(&self, def: DefId) -> String @@ -109,13 +109,13 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { fn trait_def(&self, tcx: &ty::ctxt<'tcx>, def: DefId) -> ty::TraitDef<'tcx> { let cdata = self.get_crate_data(def.krate); - decoder::get_trait_def(&*cdata, def.index, tcx) + decoder::get_trait_def(&cdata, def.index, tcx) } fn adt_def(&self, tcx: &ty::ctxt<'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx> { let cdata = self.get_crate_data(def.krate); - decoder::get_adt_def(&self.intr, &*cdata, def.index, tcx) + decoder::get_adt_def(&self.intr, &cdata, def.index, tcx) } fn method_arg_names(&self, did: DefId) -> Vec @@ -126,7 +126,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { fn item_path(&self, def: DefId) -> Vec { let cdata = self.get_crate_data(def.krate); - let path = decoder::get_item_path(&*cdata, def.index); + let path = decoder::get_item_path(&cdata, def.index); cdata.with_local_path(|cpath| { let mut r = Vec::with_capacity(cpath.len() + path.len()); @@ -138,7 +138,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { fn extern_item_path(&self, def: DefId) -> Vec { let cdata = self.get_crate_data(def.krate); - let path = decoder::get_item_path(&*cdata, def.index); + let path = decoder::get_item_path(&cdata, def.index); let mut r = Vec::with_capacity(path.len() + 1); let crate_name = hir_map::PathMod(token::intern(&cdata.name)); @@ -157,7 +157,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { { let mut result = vec![]; let cdata = self.get_crate_data(def_id.krate); - decoder::each_inherent_implementation_for_type(&*cdata, def_id.index, + decoder::each_inherent_implementation_for_type(&cdata, def_id.index, |iid| result.push(iid)); result } @@ -177,53 +177,53 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { -> Vec>> { let cdata = self.get_crate_data(def.krate); - decoder::get_provided_trait_methods(self.intr.clone(), &*cdata, def.index, tcx) + decoder::get_provided_trait_methods(self.intr.clone(), &cdata, def.index, tcx) } fn trait_item_def_ids(&self, def: DefId) -> Vec { let cdata = self.get_crate_data(def.krate); - decoder::get_trait_item_def_ids(&*cdata, def.index) + decoder::get_trait_item_def_ids(&cdata, def.index) } fn impl_items(&self, impl_def_id: DefId) -> Vec { let cdata = self.get_crate_data(impl_def_id.krate); - decoder::get_impl_items(&*cdata, impl_def_id.index) + decoder::get_impl_items(&cdata, impl_def_id.index) } fn impl_polarity(&self, def: DefId) -> Option { let cdata = self.get_crate_data(def.krate); - decoder::get_impl_polarity(&*cdata, def.index) + decoder::get_impl_polarity(&cdata, def.index) } fn impl_trait_ref(&self, tcx: &ty::ctxt<'tcx>, def: DefId) -> Option> { let cdata = self.get_crate_data(def.krate); - decoder::get_impl_trait(&*cdata, def.index, tcx) + decoder::get_impl_trait(&cdata, def.index, tcx) } fn custom_coerce_unsized_kind(&self, def: DefId) -> Option { let cdata = self.get_crate_data(def.krate); - decoder::get_custom_coerce_unsized_kind(&*cdata, def.index) + decoder::get_custom_coerce_unsized_kind(&cdata, def.index) } // FIXME: killme fn associated_consts(&self, tcx: &ty::ctxt<'tcx>, def: DefId) -> Vec>> { let cdata = self.get_crate_data(def.krate); - decoder::get_associated_consts(self.intr.clone(), &*cdata, def.index, tcx) + decoder::get_associated_consts(self.intr.clone(), &cdata, def.index, tcx) } fn trait_of_item(&self, tcx: &ty::ctxt<'tcx>, def_id: DefId) -> Option { let cdata = self.get_crate_data(def_id.krate); - decoder::get_trait_of_item(&*cdata, def_id.index, tcx) + decoder::get_trait_of_item(&cdata, def_id.index, tcx) } fn impl_or_trait_item(&self, tcx: &ty::ctxt<'tcx>, def: DefId) @@ -232,7 +232,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { let cdata = self.get_crate_data(def.krate); decoder::get_impl_or_trait_item( self.intr.clone(), - &*cdata, + &cdata, def.index, tcx) } @@ -246,29 +246,29 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { fn is_defaulted_trait(&self, trait_def_id: DefId) -> bool { let cdata = self.get_crate_data(trait_def_id.krate); - decoder::is_defaulted_trait(&*cdata, trait_def_id.index) + decoder::is_defaulted_trait(&cdata, trait_def_id.index) } fn is_impl(&self, did: DefId) -> bool { let cdata = self.get_crate_data(did.krate); - decoder::is_impl(&*cdata, did.index) + decoder::is_impl(&cdata, did.index) } fn is_default_impl(&self, impl_did: DefId) -> bool { let cdata = self.get_crate_data(impl_did.krate); - decoder::is_default_impl(&*cdata, impl_did.index) + decoder::is_default_impl(&cdata, impl_did.index) } fn is_extern_item(&self, tcx: &ty::ctxt<'tcx>, did: DefId) -> bool { let cdata = self.get_crate_data(did.krate); - decoder::is_extern_item(&*cdata, did.index, tcx) + decoder::is_extern_item(&cdata, did.index, tcx) } fn is_static_method(&self, def: DefId) -> bool { let cdata = self.get_crate_data(def.krate); - decoder::is_static_method(&*cdata, def.index) + decoder::is_static_method(&cdata, def.index) } fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool @@ -278,7 +278,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { fn is_typedef(&self, did: DefId) -> bool { let cdata = self.get_crate_data(did.krate); - decoder::is_typedef(&*cdata, did.index) + decoder::is_typedef(&cdata, did.index) } fn dylib_dependency_formats(&self, cnum: ast::CrateNum) @@ -292,7 +292,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { { let mut result = vec![]; let crate_data = self.get_crate_data(cnum); - decoder::each_lang_item(&*crate_data, |did, lid| { + decoder::each_lang_item(&crate_data, |did, lid| { result.push((did, lid)); true }); result @@ -302,7 +302,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { -> Vec { let cdata = self.get_crate_data(cnum); - decoder::get_missing_lang_items(&*cdata) + decoder::get_missing_lang_items(&cdata) } fn is_staged_api(&self, cnum: ast::CrateNum) -> bool @@ -339,7 +339,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { fn crate_struct_field_attrs(&self, cnum: ast::CrateNum) -> FnvHashMap> { - decoder::get_struct_field_attrs(&*self.get_crate_data(cnum)) + decoder::get_struct_field_attrs(&self.get_crate_data(cnum)) } fn plugin_registrar_fn(&self, cnum: ast::CrateNum) -> Option @@ -354,19 +354,19 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { fn native_libraries(&self, cnum: ast::CrateNum) -> Vec<(NativeLibraryKind, String)> { let cdata = self.get_crate_data(cnum); - decoder::get_native_libraries(&*cdata) + decoder::get_native_libraries(&cdata) } fn reachable_ids(&self, cnum: ast::CrateNum) -> Vec { let cdata = self.get_crate_data(cnum); - decoder::get_reachable_ids(&*cdata) + decoder::get_reachable_ids(&cdata) } fn def_path(&self, def: DefId) -> hir_map::DefPath { let cdata = self.get_crate_data(def.krate); - let path = decoder::def_path(&*cdata, def.index); + let path = decoder::def_path(&cdata, def.index); let local_path = cdata.local_def_path(); local_path.into_iter().chain(path).collect() } @@ -385,13 +385,13 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { fn tuple_struct_definition_if_ctor(&self, did: DefId) -> Option { let cdata = self.get_crate_data(did.krate); - decoder::get_tuple_struct_definition_if_ctor(&*cdata, did.index) + decoder::get_tuple_struct_definition_if_ctor(&cdata, did.index) } fn struct_field_names(&self, def: DefId) -> Vec { let cdata = self.get_crate_data(def.krate); - decoder::get_struct_field_names(&self.intr, &*cdata, def.index) + decoder::get_struct_field_names(&self.intr, &cdata, def.index) } fn item_children(&self, def_id: DefId) -> Vec @@ -400,7 +400,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { let crate_data = self.get_crate_data(def_id.krate); let get_crate_data = |cnum| self.get_crate_data(cnum); decoder::each_child_of_item( - self.intr.clone(), &*crate_data, + self.intr.clone(), &crate_data, def_id.index, get_crate_data, |def, name, vis| result.push(ChildItem { def: def, @@ -416,7 +416,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { let crate_data = self.get_crate_data(cnum); let get_crate_data = |cnum| self.get_crate_data(cnum); decoder::each_top_level_item_of_crate( - self.intr.clone(), &*crate_data, get_crate_data, + self.intr.clone(), &crate_data, get_crate_data, |def, name, vis| result.push(ChildItem { def: def, name: name, @@ -430,18 +430,18 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { { let cdata = self.get_crate_data(def.krate); let decode_inlined_item = Box::new(astencode::decode_inlined_item); - decoder::maybe_get_item_ast(&*cdata, tcx, def.index, decode_inlined_item) + decoder::maybe_get_item_ast(&cdata, tcx, def.index, decode_inlined_item) } fn maybe_get_item_mir(&self, tcx: &ty::ctxt<'tcx>, def: DefId) -> Option> { let cdata = self.get_crate_data(def.krate); - decoder::maybe_get_item_mir(&*cdata, tcx, def.index) + decoder::maybe_get_item_mir(&cdata, tcx, def.index) } fn is_item_mir_available(&self, def: DefId) -> bool { let cdata = self.get_crate_data(def.krate); - decoder::is_item_mir_available(&*cdata, def.index) + decoder::is_item_mir_available(&cdata, def.index) } fn crates(&self) -> Vec diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index b0eef29467ba2..a96da6bf4d66a 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -138,7 +138,7 @@ impl CStore { for (&k, v) in self.metas.borrow().iter() { let origin = self.opt_used_crate_source(k); origin.as_ref().map(|cs| { assert!(k == cs.cnum); }); - i(k, &**v, origin); + i(k, &v, origin); } } diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 8409a0c74b869..8295ffebda3e6 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -655,7 +655,7 @@ fn each_child_of_item_or_crate(intr: Rc, None => {} Some(child_item_doc) => { // Hand off the item to the callback. - let child_name = item_name(&*intr, child_item_doc); + let child_name = item_name(&intr, child_item_doc); let def_like = item_to_def_like(crate_data, child_item_doc, child_def_id); let visibility = item_visibility(child_item_doc); callback(def_like, child_name, visibility); @@ -677,7 +677,7 @@ fn each_child_of_item_or_crate(intr: Rc, if let Some(impl_method_doc) = cdata.get_item(impl_item_def_id.index) { if let StaticMethod = item_family(impl_method_doc) { // Hand off the static method to the callback. - let static_method_name = item_name(&*intr, impl_method_doc); + let static_method_name = item_name(&intr, impl_method_doc); let static_method_def_like = item_to_def_like(cdata, impl_method_doc, impl_item_def_id); callback(static_method_def_like, @@ -938,7 +938,7 @@ pub fn get_trait_name(intr: Rc, id: DefIndex) -> ast::Name { let doc = cdata.lookup_item(id); - item_name(&*intr, doc) + item_name(&intr, doc) } pub fn is_static_method(cdata: Cmd, id: DefIndex) -> bool { @@ -967,7 +967,7 @@ pub fn get_impl_or_trait_item<'tcx>(intr: Rc, _ => ImplContainer(container_id), }; - let name = item_name(&*intr, item_doc); + let name = item_name(&intr, item_doc); let vis = item_visibility(item_doc); match item_sort(item_doc) { @@ -1622,7 +1622,7 @@ fn doc_generics<'tcx>(base_doc: rbml::Doc, for rp_doc in reader::tagged_docs(doc, tag_region_param_def) { let ident_str_doc = reader::get_doc(rp_doc, tag_region_param_def_ident); - let name = item_name(&*token::get_ident_interner(), ident_str_doc); + let name = item_name(&token::get_ident_interner(), ident_str_doc); let def_id_doc = reader::get_doc(rp_doc, tag_region_param_def_def_id); let def_id = translated_def_id(cdata, def_id_doc); diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 6375f82b2c5ed..207a680a13d80 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -964,7 +964,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_visibility(rbml_w, vis); encode_stability(rbml_w, stab); encode_deprecation(rbml_w, depr); - encode_method_argument_names(rbml_w, &**decl); + encode_method_argument_names(rbml_w, &decl); rbml_w.end_tag(); } hir::ItemMod(ref m) => { @@ -1173,7 +1173,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_info_for_associated_const(ecx, rbml_w, index, - &*associated_const, + &associated_const, path.clone(), item.id, ast_item) @@ -1182,7 +1182,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_info_for_method(ecx, rbml_w, index, - &**method_type, + &method_type, path.clone(), false, item.id, @@ -1192,7 +1192,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_info_for_associated_type(ecx, rbml_w, index, - &**associated_type, + &associated_type, path.clone(), item.id, ast_item) @@ -1290,7 +1290,7 @@ fn encode_info_for_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, ty::MethodTraitItem(method_ty) => { let method_def_id = item_def_id.def_id(); - encode_method_ty_fields(ecx, rbml_w, index, &*method_ty); + encode_method_ty_fields(ecx, rbml_w, index, &method_ty); let elem = ast_map::PathName(method_ty.name); encode_path(rbml_w, @@ -1396,13 +1396,13 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, if abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic { encode_inlined_item(ecx, rbml_w, InlinedItemRef::Foreign(nitem)); } - encode_attributes(rbml_w, &*nitem.attrs); + encode_attributes(rbml_w, &nitem.attrs); let stab = stability::lookup_stability(ecx.tcx, ecx.tcx.map.local_def_id(nitem.id)); let depr = stability::lookup_deprecation(ecx.tcx, ecx.tcx.map.local_def_id(nitem.id)); encode_stability(rbml_w, stab); encode_deprecation(rbml_w, depr); encode_symbol(ecx, rbml_w, nitem.id); - encode_method_argument_names(rbml_w, &*fndecl); + encode_method_argument_names(rbml_w, &fndecl); } hir::ForeignItemStatic(_, mutbl) => { if mutbl { @@ -1411,7 +1411,7 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_family(rbml_w, 'c'); } encode_bounds_and_type_for_item(rbml_w, ecx, index, nitem.id); - encode_attributes(rbml_w, &*nitem.attrs); + encode_attributes(rbml_w, &nitem.attrs); let stab = stability::lookup_stability(ecx.tcx, ecx.tcx.map.local_def_id(nitem.id)); let depr = stability::lookup_deprecation(ecx.tcx, ecx.tcx.map.local_def_id(nitem.id)); encode_stability(rbml_w, stab); @@ -1561,7 +1561,7 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) { rbml_w.start_tag(tag_meta_item_list); rbml_w.wr_tagged_str(tag_meta_item_name, name); for inner_item in items { - encode_meta_item(rbml_w, &**inner_item); + encode_meta_item(rbml_w, &inner_item); } rbml_w.end_tag(); } @@ -1573,7 +1573,7 @@ fn encode_attributes(rbml_w: &mut Encoder, attrs: &[ast::Attribute]) { for attr in attrs { rbml_w.start_tag(tag_attribute); rbml_w.wr_tagged_u8(tag_attribute_is_sugared_doc, attr.node.is_sugared_doc as u8); - encode_meta_item(rbml_w, &*attr.node.value); + encode_meta_item(rbml_w, &attr.node.value); rbml_w.end_tag(); } rbml_w.end_tag(); From fbeb67985df7fadfb01dd2e3b0defe2fa0dfd9d4 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Feb 2016 21:39:09 +0100 Subject: [PATCH 13/15] Autoderef in librustc_lint --- src/librustc_lint/types.rs | 14 +++++++------- src/librustc_lint/unused.rs | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 9fe1aa15f4a0f..203f6626f51d3 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -125,7 +125,7 @@ impl LateLintPass for TypeLimits { } }, hir::ExprBinary(binop, ref l, ref r) => { - if is_comparison(binop) && !check_limits(cx.tcx, binop, &**l, &**r) { + if is_comparison(binop) && !check_limits(cx.tcx, binop, &l, &r) { cx.span_lint(UNUSED_COMPARISONS, e.span, "comparison is useless due to type limits"); } @@ -174,7 +174,7 @@ impl LateLintPass for TypeLimits { if (negative && v > max as u64 + 1) || (!negative && v > max as u64) { cx.span_lint(OVERFLOWING_LITERALS, e.span, - &*format!("literal out of range for {:?}", t)); + &format!("literal out of range for {:?}", t)); return; } } @@ -196,7 +196,7 @@ impl LateLintPass for TypeLimits { }; if lit_val < min || lit_val > max { cx.span_lint(OVERFLOWING_LITERALS, e.span, - &*format!("literal out of range for {:?}", t)); + &format!("literal out of range for {:?}", t)); } }, ty::TyFloat(t) => { @@ -213,7 +213,7 @@ impl LateLintPass for TypeLimits { }; if lit_val < min || lit_val > max { cx.span_lint(OVERFLOWING_LITERALS, e.span, - &*format!("literal out of range for {:?}", t)); + &format!("literal out of range for {:?}", t)); } }, _ => () @@ -666,7 +666,7 @@ impl LateLintPass for ImproperCTypes { fn check_foreign_fn(cx: &LateContext, decl: &hir::FnDecl) { for input in &decl.inputs { - check_ty(cx, &*input.ty); + check_ty(cx, &input.ty); } if let hir::Return(ref ret_ty) = decl.output { let tty = ast_ty_to_normalized(cx.tcx, ret_ty.id); @@ -680,8 +680,8 @@ impl LateLintPass for ImproperCTypes { if nmod.abi != Abi::RustIntrinsic && nmod.abi != Abi::PlatformIntrinsic { for ni in &nmod.items { match ni.node { - hir::ForeignItemFn(ref decl, _) => check_foreign_fn(cx, &**decl), - hir::ForeignItemStatic(ref t, _) => check_ty(cx, &**t) + hir::ForeignItemFn(ref decl, _) => check_foreign_fn(cx, &decl), + hir::ForeignItemStatic(ref t, _) => check_ty(cx, &t) } } } diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index f18b68a5b73d8..36ed06a6c00b4 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -248,7 +248,7 @@ impl LateLintPass for UnusedAttributes { let plugin_attributes = cx.sess().plugin_attributes.borrow_mut(); for &(ref name, ty) in plugin_attributes.iter() { - if ty == AttributeType::Whitelisted && attr.check_name(&*name) { + if ty == AttributeType::Whitelisted && attr.check_name(&name) { break; } } @@ -265,7 +265,7 @@ impl LateLintPass for UnusedAttributes { // the crate level? let plugin_crate = plugin_attributes.iter() .find(|&&(ref x, t)| { - &*attr.name() == &*x && + &*attr.name() == x && AttributeType::CrateLevel == t }).is_some(); if known_crate || plugin_crate { @@ -294,7 +294,7 @@ impl UnusedParens { fn check_unused_parens_core(&self, cx: &EarlyContext, value: &ast::Expr, msg: &str, struct_lit_needs_parens: bool) { if let ast::ExprKind::Paren(ref inner) = value.node { - let necessary = struct_lit_needs_parens && contains_exterior_struct_lit(&**inner); + let necessary = struct_lit_needs_parens && contains_exterior_struct_lit(&inner); if !necessary { cx.span_lint(UNUSED_PARENS, value.span, &format!("unnecessary parentheses around {}", msg)) @@ -314,8 +314,8 @@ impl UnusedParens { ast::ExprKind::AssignOp(_, ref lhs, ref rhs) | ast::ExprKind::Binary(_, ref lhs, ref rhs) => { // X { y: 1 } + X { y: 2 } - contains_exterior_struct_lit(&**lhs) || - contains_exterior_struct_lit(&**rhs) + contains_exterior_struct_lit(&lhs) || + contains_exterior_struct_lit(&rhs) } ast::ExprKind::Unary(_, ref x) | ast::ExprKind::Cast(ref x, _) | @@ -324,12 +324,12 @@ impl UnusedParens { ast::ExprKind::TupField(ref x, _) | ast::ExprKind::Index(ref x, _) => { // &X { y: 1 }, X { y: 1 }.y - contains_exterior_struct_lit(&**x) + contains_exterior_struct_lit(&x) } ast::ExprKind::MethodCall(_, _, ref exprs) => { // X { y: 1 }.bar(...) - contains_exterior_struct_lit(&*exprs[0]) + contains_exterior_struct_lit(&exprs[0]) } _ => false @@ -360,7 +360,7 @@ impl EarlyLintPass for UnusedParens { InPlace(_, ref value) => (value, "emplacement value", false), _ => return }; - self.check_unused_parens_core(cx, &**value, msg, struct_lit_needs_parens); + self.check_unused_parens_core(cx, &value, msg, struct_lit_needs_parens); } fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) { @@ -374,7 +374,7 @@ impl EarlyLintPass for UnusedParens { }, _ => return }; - self.check_unused_parens_core(cx, &**value, msg, false); + self.check_unused_parens_core(cx, &value, msg, false); } } From 62bada40dec16bb47e2ea0a0d54f74389309512a Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Feb 2016 21:42:39 +0100 Subject: [PATCH 14/15] Autoderef in librustc_borrowck --- src/librustc_borrowck/borrowck/check_loans.rs | 38 +++++++------- .../borrowck/gather_loans/mod.rs | 8 +-- src/librustc_borrowck/borrowck/mod.rs | 50 +++++++++---------- src/librustc_borrowck/borrowck/move_data.rs | 8 +-- src/librustc_borrowck/graphviz.rs | 2 +- 5 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 5e8495ceddd97..f19a8658a057b 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 8cf10cb9b05a0..38157d04a5d6d 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 3ca9a17686485..1fa36a98ec5d9 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 735e618cc732b..cbec32e358d81 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 eb63f572649a3..7a5491cdbe7f3 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 From 559fca0fd306dc1048cc66ca86f8c6fc89f9a055 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Feb 2016 22:00:20 +0100 Subject: [PATCH 15/15] Autoderef in librustc --- src/librustc/front/map/blocks.rs | 6 +- src/librustc/front/map/mod.rs | 30 ++--- src/librustc/middle/cfg/construct.rs | 48 ++++---- src/librustc/middle/check_match.rs | 40 +++---- src/librustc/middle/const_eval.rs | 40 +++---- src/librustc/middle/cstore.rs | 4 +- src/librustc/middle/dead.rs | 14 +-- src/librustc/middle/expr_use_visitor.rs | 110 +++++++++--------- src/librustc/middle/infer/error_reporting.rs | 18 +-- .../middle/infer/region_inference/graphviz.rs | 2 +- src/librustc/middle/liveness.rs | 104 ++++++++--------- src/librustc/middle/mem_categorization.rs | 42 +++---- src/librustc/middle/reachable.rs | 14 +-- src/librustc/middle/region.rs | 34 +++--- src/librustc/middle/resolve_lifetime.rs | 10 +- src/librustc/middle/traits/error_reporting.rs | 4 +- src/librustc/middle/traits/object_safety.rs | 2 +- src/librustc/util/common.rs | 2 +- 18 files changed, 262 insertions(+), 262 deletions(-) diff --git a/src/librustc/front/map/blocks.rs b/src/librustc/front/map/blocks.rs index 0e24a4446fbe9..752b625f529c0 100644 --- a/src/librustc/front/map/blocks.rs +++ b/src/librustc/front/map/blocks.rs @@ -217,9 +217,9 @@ impl<'a> FnLikeNode<'a> { item_fn(ItemFnParts { id: i.id, name: i.name, - decl: &**decl, + decl: &decl, unsafety: unsafety, - body: &**block, + body: &block, generics: generics, abi: abi, vis: i.vis, @@ -246,7 +246,7 @@ impl<'a> FnLikeNode<'a> { } map::NodeExpr(e) => match e.node { ast::ExprClosure(_, ref decl, ref block) => - closure(ClosureParts::new(&**decl, &**block, e.id, e.span)), + closure(ClosureParts::new(&decl, &block, e.id, e.span)), _ => panic!("expr FnLikeNode that is not fn-like"), }, _ => panic!("other FnLikeNode that is not fn-like"), diff --git a/src/librustc/front/map/mod.rs b/src/librustc/front/map/mod.rs index f398c465ffe6e..310e341749381 100644 --- a/src/librustc/front/map/mod.rs +++ b/src/librustc/front/map/mod.rs @@ -795,7 +795,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> { loop { match map.find(id) { None => return None, - Some(NodeItem(item)) if item_is_mod(&*item) => + Some(NodeItem(item)) if item_is_mod(&item) => return Some((id, item.name)), _ => {} } @@ -967,16 +967,16 @@ pub trait NodePrinter { impl<'a> NodePrinter for pprust::State<'a> { fn print_node(&mut self, node: &Node) -> io::Result<()> { match *node { - NodeItem(a) => self.print_item(&*a), - NodeForeignItem(a) => self.print_foreign_item(&*a), + NodeItem(a) => self.print_item(&a), + NodeForeignItem(a) => self.print_foreign_item(&a), NodeTraitItem(a) => self.print_trait_item(a), NodeImplItem(a) => self.print_impl_item(a), - NodeVariant(a) => self.print_variant(&*a), - NodeExpr(a) => self.print_expr(&*a), - NodeStmt(a) => self.print_stmt(&*a), - NodePat(a) => self.print_pat(&*a), - NodeBlock(a) => self.print_block(&*a), - NodeLifetime(a) => self.print_lifetime(&*a), + NodeVariant(a) => self.print_variant(&a), + NodeExpr(a) => self.print_expr(&a), + NodeStmt(a) => self.print_stmt(&a), + NodePat(a) => self.print_pat(&a), + NodeBlock(a) => self.print_block(&a), + NodeLifetime(a) => self.print_lifetime(&a), NodeTyParam(_) => panic!("cannot print TyParam"), // these cases do not carry enough information in the // ast_map to reconstruct their full structure for pretty @@ -1055,26 +1055,26 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { map.path_to_string(id), id_str) } Some(NodeExpr(ref expr)) => { - format!("expr {}{}", pprust::expr_to_string(&**expr), id_str) + format!("expr {}{}", pprust::expr_to_string(&expr), id_str) } Some(NodeStmt(ref stmt)) => { - format!("stmt {}{}", pprust::stmt_to_string(&**stmt), id_str) + format!("stmt {}{}", pprust::stmt_to_string(&stmt), id_str) } Some(NodeLocal(ref pat)) => { - format!("local {}{}", pprust::pat_to_string(&**pat), id_str) + format!("local {}{}", pprust::pat_to_string(&pat), id_str) } Some(NodePat(ref pat)) => { - format!("pat {}{}", pprust::pat_to_string(&**pat), id_str) + format!("pat {}{}", pprust::pat_to_string(&pat), id_str) } Some(NodeBlock(ref block)) => { - format!("block {}{}", pprust::block_to_string(&**block), id_str) + format!("block {}{}", pprust::block_to_string(&block), id_str) } Some(NodeStructCtor(_)) => { format!("struct_ctor {}{}", map.path_to_string(id), id_str) } Some(NodeLifetime(ref l)) => { format!("lifetime {}{}", - pprust::lifetime_to_string(&**l), id_str) + pprust::lifetime_to_string(&l), id_str) } Some(NodeTyParam(ref ty_param)) => { format!("typaram {:?}{}", ty_param, id_str) diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index a6bcf70925ca3..6142f14db3ecc 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -73,12 +73,12 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex { match stmt.node { hir::StmtDecl(ref decl, id) => { - let exit = self.decl(&**decl, pred); + let exit = self.decl(&decl, pred); self.add_ast_node(id, &[exit]) } hir::StmtExpr(ref expr, id) | hir::StmtSemi(ref expr, id) => { - let exit = self.expr(&**expr, pred); + let exit = self.expr(&expr, pred); self.add_ast_node(id, &[exit]) } } @@ -88,7 +88,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { match decl.node { hir::DeclLocal(ref local) => { let init_exit = self.opt_expr(&local.init, pred); - self.pat(&*local.pat, init_exit) + self.pat(&local.pat, init_exit) } hir::DeclItem(_) => { @@ -111,7 +111,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { hir::PatBox(ref subpat) | hir::PatRegion(ref subpat, _) | hir::PatIdent(_, _, Some(ref subpat)) => { - let subpat_exit = self.pat(&**subpat, pred); + let subpat_exit = self.pat(&subpat, pred); self.add_ast_node(pat.id, &[subpat_exit]) } @@ -140,13 +140,13 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { pats: I, pred: CFGIndex) -> CFGIndex { //! Handles case where all of the patterns must match. - pats.fold(pred, |pred, pat| self.pat(&**pat, pred)) + pats.fold(pred, |pred, pat| self.pat(&pat, pred)) } fn expr(&mut self, expr: &hir::Expr, pred: CFGIndex) -> CFGIndex { match expr.node { hir::ExprBlock(ref blk) => { - let blk_exit = self.block(&**blk, pred); + let blk_exit = self.block(&blk, pred); self.add_ast_node(expr.id, &[blk_exit]) } @@ -165,8 +165,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { // v 3 v 4 // [..expr..] // - let cond_exit = self.expr(&**cond, pred); // 1 - let then_exit = self.block(&**then, cond_exit); // 2 + let cond_exit = self.expr(&cond, pred); // 1 + let then_exit = self.block(&then, cond_exit); // 2 self.add_ast_node(expr.id, &[cond_exit, then_exit]) // 3,4 } @@ -185,9 +185,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { // v 4 v 5 // [..expr..] // - let cond_exit = self.expr(&**cond, pred); // 1 - let then_exit = self.block(&**then, cond_exit); // 2 - let else_exit = self.expr(&**otherwise, cond_exit); // 3 + let cond_exit = self.expr(&cond, pred); // 1 + let then_exit = self.block(&then, cond_exit); // 2 + let else_exit = self.expr(&otherwise, cond_exit); // 3 self.add_ast_node(expr.id, &[then_exit, else_exit]) // 4, 5 } @@ -211,14 +211,14 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { // Is the condition considered part of the loop? let loopback = self.add_dummy_node(&[pred]); // 1 - let cond_exit = self.expr(&**cond, loopback); // 2 + let cond_exit = self.expr(&cond, loopback); // 2 let expr_exit = self.add_ast_node(expr.id, &[cond_exit]); // 3 self.loop_scopes.push(LoopScope { loop_id: expr.id, continue_index: loopback, break_index: expr_exit }); - let body_exit = self.block(&**body, cond_exit); // 4 + let body_exit = self.block(&body, cond_exit); // 4 self.add_contained_edge(body_exit, loopback); // 5 self.loop_scopes.pop(); expr_exit @@ -246,7 +246,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { continue_index: loopback, break_index: expr_exit, }); - let body_exit = self.block(&**body, loopback); // 3 + let body_exit = self.block(&body, loopback); // 3 self.add_contained_edge(body_exit, loopback); // 4 self.loop_scopes.pop(); expr_exit @@ -271,8 +271,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { // v 3 v 4 // [..exit..] // - let l_exit = self.expr(&**l, pred); // 1 - let r_exit = self.expr(&**r, l_exit); // 2 + let l_exit = self.expr(&l, pred); // 1 + let r_exit = self.expr(&r, l_exit); // 2 self.add_ast_node(expr.id, &[l_exit, r_exit]) // 3,4 } @@ -304,16 +304,16 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } hir::ExprCall(ref func, ref args) => { - self.call(expr, pred, &**func, args.iter().map(|e| &**e)) + self.call(expr, pred, &func, args.iter().map(|e| &**e)) } hir::ExprMethodCall(_, _, ref args) => { - self.call(expr, pred, &*args[0], args[1..].iter().map(|e| &**e)) + self.call(expr, pred, &args[0], args[1..].iter().map(|e| &**e)) } hir::ExprIndex(ref l, ref r) | hir::ExprBinary(_, ref l, ref r) if self.tcx.is_method_call(expr.id) => { - self.call(expr, pred, &**l, Some(&**r).into_iter()) + self.call(expr, pred, &l, Some(&**r).into_iter()) } hir::ExprRange(ref start, ref end) => { @@ -323,7 +323,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } hir::ExprUnary(_, ref e) if self.tcx.is_method_call(expr.id) => { - self.call(expr, pred, &**e, None::.iter()) + self.call(expr, pred, &e, None::.iter()) } hir::ExprTup(ref exprs) => { @@ -413,7 +413,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { opt_expr: &Option>, pred: CFGIndex) -> CFGIndex { //! Constructs graph for `opt_expr` evaluated, if Some - opt_expr.iter().fold(pred, |p, e| self.expr(&**e, p)) + opt_expr.iter().fold(pred, |p, e| self.expr(&e, p)) } fn straightline<'b, I: Iterator>(&mut self, @@ -461,7 +461,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { for pat in &arm.pats { // Visit the pattern, coming from the discriminant exit - let mut pat_exit = self.pat(&**pat, discr_exit); + let mut pat_exit = self.pat(&pat, discr_exit); // If there is a guard expression, handle it here if let Some(ref guard) = arm.guard { @@ -469,10 +469,10 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { // expression to target let guard_start = self.add_dummy_node(&[pat_exit]); // Visit the guard expression - let guard_exit = self.expr(&**guard, guard_start); + let guard_exit = self.expr(&guard, guard_start); let this_has_bindings = pat_util::pat_contains_bindings_or_wild( - &self.tcx.def_map.borrow(), &**pat); + &self.tcx.def_map.borrow(), &pat); // If both this pattern and the previous pattern // were free of bindings, they must consist only diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 62b6279bb3329..a32f5b8797d3e 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -72,7 +72,7 @@ impl<'a> fmt::Debug for Matrix<'a> { let &Matrix(ref m) = self; let pretty_printed_matrix: Vec> = m.iter().map(|row| { row.iter() - .map(|&pat| pat_to_string(&*pat)) + .map(|&pat| pat_to_string(&pat)) .collect::>() }).collect(); @@ -175,7 +175,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) { // Second, if there is a guard on each arm, make sure it isn't // assigning or borrowing anything mutably. match arm.guard { - Some(ref guard) => check_for_mutation_in_guard(cx, &**guard), + Some(ref guard) => check_for_mutation_in_guard(cx, &guard), None => {} } } @@ -196,14 +196,14 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) { .iter() .flat_map(|&(ref pats, _)| pats) { // Third, check legality of move bindings. - check_legality_of_bindings_in_at_patterns(cx, &**pat); + check_legality_of_bindings_in_at_patterns(cx, &pat); // Fourth, check if there are any references to NaN that we should warn about. - check_for_static_nan(cx, &**pat); + check_for_static_nan(cx, &pat); // Fifth, check if for any of the patterns that match an enumerated type // are bindings with the same name as one of the variants of said type. - check_for_bindings_named_the_same_as_variants(cx, &**pat); + check_for_bindings_named_the_same_as_variants(cx, &pat); } // Fourth, check for unreachable arms. @@ -275,7 +275,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat) fn check_for_static_nan(cx: &MatchCheckCtxt, pat: &Pat) { front_util::walk_pat(pat, |p| { if let hir::PatLit(ref expr) = p.node { - match eval_const_expr_partial(cx.tcx, &**expr, ExprTypeChecked, None) { + match eval_const_expr_partial(cx.tcx, &expr, ExprTypeChecked, None) { Ok(ConstVal::Float(f)) if f.is_nan() => { span_warn!(cx.tcx.sess, p.span, E0003, "unmatchable NaN in pattern, \ @@ -360,7 +360,7 @@ fn check_arms(cx: &MatchCheckCtxt, fn raw_pat<'a>(p: &'a Pat) -> &'a Pat { match p.node { - hir::PatIdent(_, _, Some(ref s)) => raw_pat(&**s), + hir::PatIdent(_, _, Some(ref s)) => raw_pat(&s), _ => p } } @@ -679,7 +679,7 @@ fn is_useful(cx: &MatchCheckCtxt, let left_ty = if real_pat.id == DUMMY_NODE_ID { cx.tcx.mk_nil() } else { - let left_ty = cx.tcx.pat_ty(&*real_pat); + let left_ty = cx.tcx.pat_ty(&real_pat); match real_pat.node { hir::PatIdent(hir::BindByRef(..), _, _) => { @@ -798,9 +798,9 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat, _ => vec!(Single) }, hir::PatLit(ref expr) => - vec!(ConstantValue(eval_const_expr(cx.tcx, &**expr))), + vec!(ConstantValue(eval_const_expr(cx.tcx, &expr))), hir::PatRange(ref lo, ref hi) => - vec!(ConstantRange(eval_const_expr(cx.tcx, &**lo), eval_const_expr(cx.tcx, &**hi))), + vec!(ConstantRange(eval_const_expr(cx.tcx, &lo), eval_const_expr(cx.tcx, &hi))), hir::PatVec(ref before, ref slice, ref after) => match left_ty.sty { ty::TyArray(_, _) => vec!(Single), @@ -941,7 +941,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat], Some(vec![&**inner]), hir::PatLit(ref expr) => { - let expr_value = eval_const_expr(cx.tcx, &**expr); + let expr_value = eval_const_expr(cx.tcx, &expr); match range_covered_by_constructor(constructor, &expr_value, &expr_value) { Some(true) => Some(vec![]), Some(false) => None, @@ -953,8 +953,8 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat], } hir::PatRange(ref from, ref to) => { - let from_value = eval_const_expr(cx.tcx, &**from); - let to_value = eval_const_expr(cx.tcx, &**to); + let from_value = eval_const_expr(cx.tcx, &from); + let to_value = eval_const_expr(cx.tcx, &to); match range_covered_by_constructor(constructor, &from_value, &to_value) { Some(true) => Some(vec![]), Some(false) => None, @@ -1012,7 +1012,7 @@ fn check_local(cx: &mut MatchCheckCtxt, loc: &hir::Local) { // Check legality of move bindings and `@` patterns. check_legality_of_move_bindings(cx, false, slice::ref_slice(&loc.pat)); - check_legality_of_bindings_in_at_patterns(cx, &*loc.pat); + check_legality_of_bindings_in_at_patterns(cx, &loc.pat); } fn check_fn(cx: &mut MatchCheckCtxt, @@ -1031,7 +1031,7 @@ fn check_fn(cx: &mut MatchCheckCtxt, for input in &decl.inputs { check_irrefutable(cx, &input.pat, true); check_legality_of_move_bindings(cx, false, slice::ref_slice(&input.pat)); - check_legality_of_bindings_in_at_patterns(cx, &*input.pat); + check_legality_of_bindings_in_at_patterns(cx, &input.pat); } } @@ -1058,7 +1058,7 @@ fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat, refutable: F) -> Option match is_useful(cx, &pats, &[DUMMY_WILD_PAT], ConstructWitness) { UsefulWithWitness(pats) => { assert_eq!(pats.len(), 1); - Some(refutable(&*pats[0])) + Some(refutable(&pats[0])) }, NotUseful => None, Useful => unreachable!() @@ -1073,7 +1073,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, let def_map = &tcx.def_map; let mut by_ref_span = None; for pat in pats { - pat_bindings(def_map, &**pat, |bm, _, span, _path| { + pat_bindings(def_map, &pat, |bm, _, span, _path| { match bm { hir::BindByRef(_) => { by_ref_span = Some(span); @@ -1088,7 +1088,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, // check legality of moving out of the enum // x @ Foo(..) is legal, but x @ Foo(y) isn't. - if sub.map_or(false, |p| pat_contains_bindings(&def_map.borrow(), &*p)) { + if sub.map_or(false, |p| pat_contains_bindings(&def_map.borrow(), &p)) { span_err!(cx.tcx.sess, p.span, E0007, "cannot bind by-move with sub-bindings"); } else if has_guard { span_err!(cx.tcx.sess, p.span, E0008, "cannot bind by-move into a pattern guard"); @@ -1101,8 +1101,8 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, }; for pat in pats { - front_util::walk_pat(&**pat, |p| { - if pat_is_binding(&def_map.borrow(), &*p) { + front_util::walk_pat(&pat, |p| { + if pat_is_binding(&def_map.borrow(), &p) { match p.node { hir::PatIdent(hir::BindByValue(_), _, ref sub) => { let pat_ty = tcx.node_id_to_type(p.id); diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 6650a06229adc..f9922f725c615 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -94,7 +94,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, None => None, Some(ast_map::NodeItem(it)) => match it.node { hir::ItemConst(_, ref const_expr) => { - Some(&*const_expr) + Some(&const_expr) } _ => None }, @@ -129,7 +129,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, }, Some(ast_map::NodeImplItem(ii)) => match ii.node { hir::ImplItemKind::Const(_, ref expr) => { - Some(&*expr) + Some(&expr) } _ => None }, @@ -325,7 +325,7 @@ impl ConstVal { pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P { let pat = match expr.node { hir::ExprTup(ref exprs) => - hir::PatTup(exprs.iter().map(|expr| const_expr_to_pat(tcx, &**expr, span)).collect()), + hir::PatTup(exprs.iter().map(|expr| const_expr_to_pat(tcx, &expr, span)).collect()), hir::ExprCall(ref callee, ref args) => { let def = *tcx.def_map.borrow().get(&callee.id).unwrap(); @@ -342,7 +342,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P }), _ => unreachable!() }; - let pats = args.iter().map(|expr| const_expr_to_pat(tcx, &**expr, span)).collect(); + let pats = args.iter().map(|expr| const_expr_to_pat(tcx, &expr, span)).collect(); hir::PatEnum(path, Some(pats)) } @@ -351,7 +351,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P span: codemap::DUMMY_SP, node: hir::FieldPat { name: field.name.node, - pat: const_expr_to_pat(tcx, &*field.expr, span), + pat: const_expr_to_pat(tcx, &field.expr, span), is_shorthand: false, }, }).collect(); @@ -359,7 +359,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P } hir::ExprVec(ref exprs) => { - let pats = exprs.iter().map(|expr| const_expr_to_pat(tcx, &**expr, span)).collect(); + let pats = exprs.iter().map(|expr| const_expr_to_pat(tcx, &expr, span)).collect(); hir::PatVec(pats, None, hir::HirVec::new()) } @@ -850,7 +850,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, let result = match e.node { hir::ExprUnary(hir::UnNeg, ref inner) => { - match try!(eval_const_expr_partial(tcx, &**inner, ty_hint, fn_args)) { + match try!(eval_const_expr_partial(tcx, &inner, ty_hint, fn_args)) { Float(f) => Float(-f), Int(n) => try!(const_int_checked_neg(n, e, expr_int_type)), Uint(i) => { @@ -860,7 +860,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, } } hir::ExprUnary(hir::UnNot, ref inner) => { - match try!(eval_const_expr_partial(tcx, &**inner, ty_hint, fn_args)) { + match try!(eval_const_expr_partial(tcx, &inner, ty_hint, fn_args)) { Int(i) => Int(!i), Uint(i) => const_uint_not(i, expr_uint_type), Bool(b) => Bool(!b), @@ -872,8 +872,8 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, hir::BiShl | hir::BiShr => ty_hint.checked_or(tcx.types.usize), _ => ty_hint }; - match (try!(eval_const_expr_partial(tcx, &**a, ty_hint, fn_args)), - try!(eval_const_expr_partial(tcx, &**b, b_ty, fn_args))) { + match (try!(eval_const_expr_partial(tcx, &a, ty_hint, fn_args)), + try!(eval_const_expr_partial(tcx, &b, b_ty, fn_args))) { (Float(a), Float(b)) => { match op.node { hir::BiAdd => Float(a + b), @@ -964,7 +964,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, } } hir::ExprCast(ref base, ref target_ty) => { - let ety = ety.or_else(|| ast_ty_to_prim_ty(tcx, &**target_ty)) + let ety = ety.or_else(|| ast_ty_to_prim_ty(tcx, &target_ty)) .unwrap_or_else(|| { tcx.sess.span_fatal(target_ty.span, "target type not found for const cast") @@ -982,7 +982,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, } }; - let val = try!(eval_const_expr_partial(tcx, &**base, base_hint, fn_args)); + let val = try!(eval_const_expr_partial(tcx, &base, base_hint, fn_args)); match cast_const(tcx, val, ety) { Ok(val) => val, Err(kind) => return Err(ConstEvalErr { span: e.span, kind: kind }), @@ -1116,16 +1116,16 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, assert!(old.is_none()); } debug!("const call({:?})", call_args); - try!(eval_const_expr_partial(tcx, &**result, ty_hint, Some(&call_args))) + try!(eval_const_expr_partial(tcx, &result, ty_hint, Some(&call_args))) }, - hir::ExprLit(ref lit) => lit_to_const(tcx.sess, e.span, &**lit, ety), + hir::ExprLit(ref lit) => lit_to_const(tcx.sess, e.span, &lit, ety), hir::ExprBlock(ref block) => { match block.expr { - Some(ref expr) => try!(eval_const_expr_partial(tcx, &**expr, ty_hint, fn_args)), + Some(ref expr) => try!(eval_const_expr_partial(tcx, &expr, ty_hint, fn_args)), None => unreachable!(), } } - hir::ExprType(ref e, _) => try!(eval_const_expr_partial(tcx, &**e, ty_hint, fn_args)), + hir::ExprType(ref e, _) => try!(eval_const_expr_partial(tcx, &e, ty_hint, fn_args)), hir::ExprTup(_) => Tuple(e.id), hir::ExprStruct(..) => Struct(e.id), hir::ExprIndex(ref arr, ref idx) => { @@ -1144,7 +1144,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, match arr { Array(_, n) if idx >= n => signal!(e, IndexOutOfBounds), Array(v, _) => if let hir::ExprVec(ref v) = tcx.map.expect_expr(v).node { - try!(eval_const_expr_partial(tcx, &*v[idx as usize], ty_hint, fn_args)) + try!(eval_const_expr_partial(tcx, &v[idx as usize], ty_hint, fn_args)) } else { unreachable!() }, @@ -1152,7 +1152,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, Repeat(_, n) if idx >= n => signal!(e, IndexOutOfBounds), Repeat(elem, _) => try!(eval_const_expr_partial( tcx, - &*tcx.map.expect_expr(elem), + &tcx.map.expect_expr(elem), ty_hint, fn_args, )), @@ -1172,7 +1172,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, let len_hint = ty_hint.checked_or(tcx.types.usize); Repeat( e.id, - match try!(eval_const_expr_partial(tcx, &**n, len_hint, fn_args)) { + match try!(eval_const_expr_partial(tcx, &n, len_hint, fn_args)) { Int(i) if i >= 0 => i as u64, Int(_) => signal!(e, RepeatCountNotNatural), Uint(i) => i, @@ -1207,7 +1207,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, // if the idents are compared run-pass/issue-19244 fails if let Some(f) = fields.iter().find(|f| f.name.node == field_name.node) { - return eval_const_expr_partial(tcx, &*f.expr, base_hint, fn_args) + return eval_const_expr_partial(tcx, &f.expr, base_hint, fn_args) } else { signal!(e, MissingStructField); } diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index c2c23f6a03250..5de192ca4ebfb 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -254,8 +254,8 @@ impl InlinedItem { where V: Visitor<'ast> { match *self { - InlinedItem::Item(ref i) => visitor.visit_item(&**i), - InlinedItem::Foreign(ref i) => visitor.visit_foreign_item(&**i), + InlinedItem::Item(ref i) => visitor.visit_item(&i), + InlinedItem::Foreign(ref i) => visitor.visit_foreign_item(&i), InlinedItem::TraitItem(_, ref ti) => visitor.visit_trait_item(ti), InlinedItem::ImplItem(_, ref ii) => visitor.visit_impl_item(ii), } diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 7ed931265f22c..ae2252b6df6ca 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -183,17 +183,17 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { .contains(&attr::ReprExtern) }); - intravisit::walk_item(self, &*item); + intravisit::walk_item(self, &item); } hir::ItemEnum(..) => { self.inherited_pub_visibility = item.vis == hir::Public; - intravisit::walk_item(self, &*item); + intravisit::walk_item(self, &item); } hir::ItemFn(..) | hir::ItemTy(..) | hir::ItemStatic(..) | hir::ItemConst(..) => { - intravisit::walk_item(self, &*item); + intravisit::walk_item(self, &item); } _ => () } @@ -205,7 +205,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { intravisit::walk_impl_item(self, impl_item); } ast_map::NodeForeignItem(foreign_item) => { - intravisit::walk_foreign_item(self, &*foreign_item); + intravisit::walk_foreign_item(self, &foreign_item); } _ => () } @@ -237,10 +237,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> { self.lookup_and_handle_method(expr.id); } hir::ExprField(ref lhs, ref name) => { - self.handle_field_access(&**lhs, name.node); + self.handle_field_access(&lhs, name.node); } hir::ExprTupField(ref lhs, idx) => { - self.handle_tup_field_access(&**lhs, idx.node); + self.handle_tup_field_access(&lhs, idx.node); } _ => () } @@ -257,7 +257,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> { // necessary for the pattern to match. Those construction sites // can't be reached unless the variant is constructed elsewhere. let len = self.ignore_variant_stack.len(); - self.ignore_variant_stack.extend_from_slice(&*variants); + self.ignore_variant_stack.extend_from_slice(&variants); intravisit::walk_arm(self, arm); self.ignore_variant_stack.truncate(len); } else { diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index b5baf84eef23d..5bdb553a2fea9 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -303,7 +303,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { ty::ReScope(fn_body_scope), // Args live only as long as the fn body. arg_ty); - self.walk_irrefutable_pat(arg_cmt, &*arg.pat); + self.walk_irrefutable_pat(arg_cmt, &arg.pat); } } @@ -324,7 +324,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { fn consume_exprs(&mut self, exprs: &[P]) { for expr in exprs { - self.consume_expr(&**expr); + self.consume_expr(&expr); } } @@ -372,40 +372,40 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { hir::ExprPath(..) => { } hir::ExprType(ref subexpr, _) => { - self.walk_expr(&**subexpr) + self.walk_expr(&subexpr) } hir::ExprUnary(hir::UnDeref, ref base) => { // *base - if !self.walk_overloaded_operator(expr, &**base, Vec::new(), PassArgs::ByRef) { - self.select_from_expr(&**base); + if !self.walk_overloaded_operator(expr, &base, Vec::new(), PassArgs::ByRef) { + self.select_from_expr(&base); } } hir::ExprField(ref base, _) => { // base.f - self.select_from_expr(&**base); + self.select_from_expr(&base); } hir::ExprTupField(ref base, _) => { // base. - self.select_from_expr(&**base); + self.select_from_expr(&base); } hir::ExprIndex(ref lhs, ref rhs) => { // lhs[rhs] if !self.walk_overloaded_operator(expr, - &**lhs, - vec![&**rhs], + &lhs, + vec![&rhs], PassArgs::ByValue) { - self.select_from_expr(&**lhs); - self.consume_expr(&**rhs); + self.select_from_expr(&lhs); + self.consume_expr(&rhs); } } hir::ExprRange(ref start, ref end) => { - start.as_ref().map(|e| self.consume_expr(&**e)); - end.as_ref().map(|e| self.consume_expr(&**e)); + start.as_ref().map(|e| self.consume_expr(&e)); + end.as_ref().map(|e| self.consume_expr(&e)); } hir::ExprCall(ref callee, ref args) => { // callee(args) - self.walk_callee(expr, &**callee); + self.walk_callee(expr, &callee); self.consume_exprs(args); } @@ -422,16 +422,16 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { } hir::ExprIf(ref cond_expr, ref then_blk, ref opt_else_expr) => { - self.consume_expr(&**cond_expr); - self.walk_block(&**then_blk); + self.consume_expr(&cond_expr); + self.walk_block(&then_blk); if let Some(ref else_expr) = *opt_else_expr { - self.consume_expr(&**else_expr); + self.consume_expr(&else_expr); } } hir::ExprMatch(ref discr, ref arms, _) => { - let discr_cmt = return_if_err!(self.mc.cat_expr(&**discr)); - self.borrow_expr(&**discr, ty::ReEmpty, ty::ImmBorrow, MatchDiscriminant); + let discr_cmt = return_if_err!(self.mc.cat_expr(&discr)); + self.borrow_expr(&discr, ty::ReEmpty, ty::ImmBorrow, MatchDiscriminant); // treatment of the discriminant is handled while walking the arms. for arm in arms { @@ -451,20 +451,20 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { let expr_ty = return_if_err!(self.typer.node_ty(expr.id)); if let ty::TyRef(&r, _) = expr_ty.sty { let bk = ty::BorrowKind::from_mutbl(m); - self.borrow_expr(&**base, r, bk, AddrOf); + self.borrow_expr(&base, r, bk, AddrOf); } } hir::ExprInlineAsm(ref ia) => { for &(_, ref input) in &ia.inputs { - self.consume_expr(&**input); + self.consume_expr(&input); } for output in &ia.outputs { if output.is_indirect { - self.consume_expr(&*output.expr); + self.consume_expr(&output.expr); } else { - self.mutate_expr(expr, &*output.expr, + self.mutate_expr(expr, &output.expr, if output.is_rw { MutateMode::WriteAndRead } else { @@ -479,12 +479,12 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { hir::ExprLit(..) => {} hir::ExprLoop(ref blk, _) => { - self.walk_block(&**blk); + self.walk_block(&blk); } hir::ExprWhile(ref cond_expr, ref blk, _) => { - self.consume_expr(&**cond_expr); - self.walk_block(&**blk); + self.consume_expr(&cond_expr); + self.walk_block(&blk); } hir::ExprUnary(op, ref lhs) => { @@ -494,8 +494,8 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { PassArgs::ByRef }; - if !self.walk_overloaded_operator(expr, &**lhs, Vec::new(), pass_args) { - self.consume_expr(&**lhs); + if !self.walk_overloaded_operator(expr, &lhs, Vec::new(), pass_args) { + self.consume_expr(&lhs); } } @@ -506,29 +506,29 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { PassArgs::ByRef }; - if !self.walk_overloaded_operator(expr, &**lhs, vec![&**rhs], pass_args) { - self.consume_expr(&**lhs); - self.consume_expr(&**rhs); + if !self.walk_overloaded_operator(expr, &lhs, vec![&rhs], pass_args) { + self.consume_expr(&lhs); + self.consume_expr(&rhs); } } hir::ExprBlock(ref blk) => { - self.walk_block(&**blk); + self.walk_block(&blk); } hir::ExprRet(ref opt_expr) => { if let Some(ref expr) = *opt_expr { - self.consume_expr(&**expr); + self.consume_expr(&expr); } } hir::ExprAssign(ref lhs, ref rhs) => { - self.mutate_expr(expr, &**lhs, MutateMode::JustWrite); - self.consume_expr(&**rhs); + self.mutate_expr(expr, &lhs, MutateMode::JustWrite); + self.consume_expr(&rhs); } hir::ExprCast(ref base, _) => { - self.consume_expr(&**base); + self.consume_expr(&base); } hir::ExprAssignOp(op, ref lhs, ref rhs) => { @@ -536,14 +536,14 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { assert!(::rustc_front::util::is_by_value_binop(op.node)); if !self.walk_overloaded_operator(expr, lhs, vec![rhs], PassArgs::ByValue) { - self.mutate_expr(expr, &**lhs, MutateMode::WriteAndRead); - self.consume_expr(&**rhs); + self.mutate_expr(expr, &lhs, MutateMode::WriteAndRead); + self.consume_expr(&rhs); } } hir::ExprRepeat(ref base, ref count) => { - self.consume_expr(&**base); - self.consume_expr(&**count); + self.consume_expr(&base); + self.consume_expr(&count); } hir::ExprClosure(..) => { @@ -551,7 +551,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { } hir::ExprBox(ref base) => { - self.consume_expr(&**base); + self.consume_expr(&base); } } } @@ -602,7 +602,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { hir::StmtDecl(ref decl, _) => { match decl.node { hir::DeclLocal(ref local) => { - self.walk_local(&**local); + self.walk_local(&local); } hir::DeclItem(_) => { @@ -614,7 +614,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { hir::StmtExpr(ref expr, _) | hir::StmtSemi(ref expr, _) => { - self.consume_expr(&**expr); + self.consume_expr(&expr); } } } @@ -623,7 +623,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { match local.init { None => { let delegate = &mut self.delegate; - pat_util::pat_bindings(&self.typer.tcx.def_map, &*local.pat, + pat_util::pat_bindings(&self.typer.tcx.def_map, &local.pat, |_, id, span, _| { delegate.decl_without_init(id, span); }) @@ -634,9 +634,9 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { // initializers are considered // "assigns", which is handled by // `walk_pat`: - self.walk_expr(&**expr); - let init_cmt = return_if_err!(self.mc.cat_expr(&**expr)); - self.walk_irrefutable_pat(init_cmt, &*local.pat); + self.walk_expr(&expr); + let init_cmt = return_if_err!(self.mc.cat_expr(&expr)); + self.walk_irrefutable_pat(init_cmt, &local.pat); } } } @@ -651,7 +651,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { } if let Some(ref tail_expr) = blk.expr { - self.consume_expr(&**tail_expr); + self.consume_expr(&tail_expr); } } @@ -661,7 +661,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { opt_with: &Option>) { // Consume the expressions supplying values for each field. for field in fields { - self.consume_expr(&*field.expr); + self.consume_expr(&field.expr); } let with_expr = match *opt_with { @@ -669,7 +669,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { None => { return; } }; - let with_cmt = return_if_err!(self.mc.cat_expr(&*with_expr)); + let with_cmt = return_if_err!(self.mc.cat_expr(&with_expr)); // Select just those fields of the `with` // expression that will actually be used @@ -906,21 +906,21 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { fn arm_move_mode(&mut self, discr_cmt: mc::cmt<'tcx>, arm: &hir::Arm) -> TrackMatchMode { let mut mode = Unknown; for pat in &arm.pats { - self.determine_pat_move_mode(discr_cmt.clone(), &**pat, &mut mode); + self.determine_pat_move_mode(discr_cmt.clone(), &pat, &mut mode); } mode } fn walk_arm(&mut self, discr_cmt: mc::cmt<'tcx>, arm: &hir::Arm, mode: MatchMode) { for pat in &arm.pats { - self.walk_pat(discr_cmt.clone(), &**pat, mode); + self.walk_pat(discr_cmt.clone(), &pat, mode); } if let Some(ref guard) = arm.guard { - self.consume_expr(&**guard); + self.consume_expr(&guard); } - self.consume_expr(&*arm.body); + self.consume_expr(&arm.body); } /// Walks a pat that occurs in isolation (i.e. top-level of fn @@ -1029,7 +1029,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { // matched. let (slice_cmt, slice_mutbl, slice_r) = - return_if_err!(mc.cat_slice_pattern(cmt_pat, &**slice_pat)); + return_if_err!(mc.cat_slice_pattern(cmt_pat, &slice_pat)); // Note: We declare here that the borrow // occurs upon entering the `[...]` diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index b83cd60031d13..8c578bcd3d2ae 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -145,7 +145,7 @@ impl<'tcx> ty::ctxt<'tcx> { _ => "expression", }, Some(ast_map::NodeStmt(_)) => "statement", - Some(ast_map::NodeItem(it)) => item_scope_tag(&*it), + Some(ast_map::NodeItem(it)) => item_scope_tag(&it), Some(_) | None => { err.span_note(span, &unknown_scope()); return; @@ -190,7 +190,7 @@ impl<'tcx> ty::ctxt<'tcx> { (format!("{} {}", prefix, msg), opt_span) } Some(ast_map::NodeItem(it)) => { - let tag = item_scope_tag(&*it); + let tag = item_scope_tag(&it); let (msg, opt_span) = explain_span(self, tag, it.span); (format!("{} {}", prefix, msg), opt_span) } @@ -1333,7 +1333,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { -> hir::HirVec { let mut new_inputs = Vec::new(); for arg in inputs { - let new_ty = self.rebuild_arg_ty_or_output(&*arg.ty, lifetime, + let new_ty = self.rebuild_arg_ty_or_output(&arg.ty, lifetime, anon_nums, region_names); let possibly_new_arg = hir::Arg { ty: new_ty, @@ -1351,7 +1351,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { region_names: &HashSet) -> hir::FunctionRetTy { match *ty { hir::Return(ref ret_ty) => hir::Return( - self.rebuild_arg_ty_or_output(&**ret_ty, lifetime, anon_nums, region_names) + self.rebuild_arg_ty_or_output(&ret_ty, lifetime, anon_nums, region_names) ), hir::DefaultReturn(span) => hir::DefaultReturn(span), hir::NoReturn(span) => hir::NoReturn(span) @@ -1390,7 +1390,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { }; new_ty = self.rebuild_ty(new_ty, P(to)); } - ty_queue.push(&*mut_ty.ty); + ty_queue.push(&mut_ty.ty); } hir::TyPath(ref maybe_qself, ref path) => { let a_def = match self.tcx.def_map.borrow().get(&cur_ty.id) { @@ -1455,11 +1455,11 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { } hir::TyPtr(ref mut_ty) => { - ty_queue.push(&*mut_ty.ty); + ty_queue.push(&mut_ty.ty); } hir::TyVec(ref ty) | hir::TyFixedLengthVec(ref ty, _) => { - ty_queue.push(&**ty); + ty_queue.push(&ty); } hir::TyTup(ref tys) => ty_queue.extend(tys.iter().map(|ty| &**ty)), _ => {} @@ -1554,13 +1554,13 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { } } let new_types = data.types.iter().map(|t| { - self.rebuild_arg_ty_or_output(&**t, lifetime, anon_nums, region_names) + self.rebuild_arg_ty_or_output(&t, lifetime, anon_nums, region_names) }).collect(); let new_bindings = data.bindings.iter().map(|b| { hir::TypeBinding { id: b.id, name: b.name, - ty: self.rebuild_arg_ty_or_output(&*b.ty, + ty: self.rebuild_arg_ty_or_output(&b.ty, lifetime, anon_nums, region_names), diff --git a/src/librustc/middle/infer/region_inference/graphviz.rs b/src/librustc/middle/infer/region_inference/graphviz.rs index 439274cd47696..dafa65c5bdca8 100644 --- a/src/librustc/middle/infer/region_inference/graphviz.rs +++ b/src/librustc/middle/infer/region_inference/graphviz.rs @@ -76,7 +76,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a, let output_path = { let output_template = match requested_output { - Ok(ref s) if &**s == "help" => { + Ok(ref s) if s == "help" => { static PRINTED_YET: AtomicBool = AtomicBool::new(false); if !PRINTED_YET.load(Ordering::SeqCst) { print_help_message(); diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 5fa9d45934571..a487ddbc2b1c2 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -382,7 +382,7 @@ fn visit_fn(ir: &mut IrMaps, for arg in &decl.inputs { pat_util::pat_bindings(&ir.tcx.def_map, - &*arg.pat, + &arg.pat, |_bm, arg_id, _x, path1| { debug!("adding argument {}", arg_id); let name = path1.node; @@ -416,7 +416,7 @@ fn visit_fn(ir: &mut IrMaps, } fn visit_local(ir: &mut IrMaps, local: &hir::Local) { - pat_util::pat_bindings(&ir.tcx.def_map, &*local.pat, |_, p_id, sp, path1| { + pat_util::pat_bindings(&ir.tcx.def_map, &local.pat, |_, p_id, sp, path1| { debug!("adding local variable {}", p_id); let name = path1.node; ir.add_live_node_for_node(p_id, VarDefNode(sp)); @@ -430,7 +430,7 @@ fn visit_local(ir: &mut IrMaps, local: &hir::Local) { fn visit_arm(ir: &mut IrMaps, arm: &hir::Arm) { for pat in &arm.pats { - pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| { + pat_util::pat_bindings(&ir.tcx.def_map, &pat, |bm, p_id, sp, path1| { debug!("adding local variable {} from match with bm {:?}", p_id, bm); let name = path1.node; @@ -876,11 +876,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { -> LiveNode { match stmt.node { hir::StmtDecl(ref decl, _) => { - self.propagate_through_decl(&**decl, succ) + self.propagate_through_decl(&decl, succ) } hir::StmtExpr(ref expr, _) | hir::StmtSemi(ref expr, _) => { - self.propagate_through_expr(&**expr, succ) + self.propagate_through_expr(&expr, succ) } } } @@ -889,7 +889,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { -> LiveNode { match decl.node { hir::DeclLocal(ref local) => { - self.propagate_through_local(&**local, succ) + self.propagate_through_local(&local, succ) } hir::DeclItem(_) => succ, } @@ -912,13 +912,13 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // once at the func header but otherwise equivalent. let succ = self.propagate_through_opt_expr(local.init.as_ref().map(|e| &**e), succ); - self.define_bindings_in_pat(&*local.pat, succ) + self.define_bindings_in_pat(&local.pat, succ) } fn propagate_through_exprs(&mut self, exprs: &[P], succ: LiveNode) -> LiveNode { exprs.iter().rev().fold(succ, |succ, expr| { - self.propagate_through_expr(&**expr, succ) + self.propagate_through_expr(&expr, succ) }) } @@ -941,11 +941,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } hir::ExprField(ref e, _) => { - self.propagate_through_expr(&**e, succ) + self.propagate_through_expr(&e, succ) } hir::ExprTupField(ref e, _) => { - self.propagate_through_expr(&**e, succ) + self.propagate_through_expr(&e, succ) } hir::ExprClosure(_, _, ref blk) => { @@ -991,21 +991,21 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // ( succ ) // let else_ln = self.propagate_through_opt_expr(els.as_ref().map(|e| &**e), succ); - let then_ln = self.propagate_through_block(&**then, succ); + let then_ln = self.propagate_through_block(&then, succ); let ln = self.live_node(expr.id, expr.span); self.init_from_succ(ln, else_ln); self.merge_from_succ(ln, then_ln, false); - self.propagate_through_expr(&**cond, ln) + self.propagate_through_expr(&cond, ln) } hir::ExprWhile(ref cond, ref blk, _) => { - self.propagate_through_loop(expr, WhileLoop(&**cond), &**blk, succ) + self.propagate_through_loop(expr, WhileLoop(&cond), &blk, succ) } // Note that labels have been resolved, so we don't need to look // at the label ident hir::ExprLoop(ref blk, _) => { - self.propagate_through_loop(expr, LoopLoop, &**blk, succ) + self.propagate_through_loop(expr, LoopLoop, &blk, succ) } hir::ExprMatch(ref e, ref arms, _) => { @@ -1028,7 +1028,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { let mut first_merge = true; for arm in arms { let body_succ = - self.propagate_through_expr(&*arm.body, succ); + self.propagate_through_expr(&arm.body, succ); let guard_succ = self.propagate_through_opt_expr(arm.guard.as_ref().map(|e| &**e), body_succ); // only consider the first pattern; any later patterns must have @@ -1040,7 +1040,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.merge_from_succ(ln, arm_succ, first_merge); first_merge = false; }; - self.propagate_through_expr(&**e, ln) + self.propagate_through_expr(&e, ln) } hir::ExprRet(ref o_e) => { @@ -1080,17 +1080,17 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { hir::ExprAssign(ref l, ref r) => { // see comment on lvalues in // propagate_through_lvalue_components() - let succ = self.write_lvalue(&**l, succ, ACC_WRITE); - let succ = self.propagate_through_lvalue_components(&**l, succ); - self.propagate_through_expr(&**r, succ) + let succ = self.write_lvalue(&l, succ, ACC_WRITE); + let succ = self.propagate_through_lvalue_components(&l, succ); + self.propagate_through_expr(&r, succ) } hir::ExprAssignOp(_, ref l, ref r) => { // see comment on lvalues in // propagate_through_lvalue_components() - let succ = self.write_lvalue(&**l, succ, ACC_WRITE|ACC_READ); - let succ = self.propagate_through_expr(&**r, succ); - self.propagate_through_lvalue_components(&**l, succ) + let succ = self.write_lvalue(&l, succ, ACC_WRITE|ACC_READ); + let succ = self.propagate_through_expr(&r, succ); + self.propagate_through_lvalue_components(&l, succ) } // Uninteresting cases: just propagate in rev exec order @@ -1100,27 +1100,27 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } hir::ExprRepeat(ref element, ref count) => { - let succ = self.propagate_through_expr(&**count, succ); - self.propagate_through_expr(&**element, succ) + let succ = self.propagate_through_expr(&count, succ); + self.propagate_through_expr(&element, succ) } hir::ExprStruct(_, ref fields, ref with_expr) => { let succ = self.propagate_through_opt_expr(with_expr.as_ref().map(|e| &**e), succ); fields.iter().rev().fold(succ, |succ, field| { - self.propagate_through_expr(&*field.expr, succ) + self.propagate_through_expr(&field.expr, succ) }) } hir::ExprCall(ref f, ref args) => { let diverges = !self.ir.tcx.is_method_call(expr.id) && - self.ir.tcx.expr_ty_adjusted(&**f).fn_ret().diverges(); + self.ir.tcx.expr_ty_adjusted(&f).fn_ret().diverges(); let succ = if diverges { self.s.exit_ln } else { succ }; let succ = self.propagate_through_exprs(&args[..], succ); - self.propagate_through_expr(&**f, succ) + self.propagate_through_expr(&f, succ) } hir::ExprMethodCall(_, _, ref args) => { @@ -1139,24 +1139,24 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } hir::ExprBinary(op, ref l, ref r) if ::rustc_front::util::lazy_binop(op.node) => { - let r_succ = self.propagate_through_expr(&**r, succ); + let r_succ = self.propagate_through_expr(&r, succ); let ln = self.live_node(expr.id, expr.span); self.init_from_succ(ln, succ); self.merge_from_succ(ln, r_succ, false); - self.propagate_through_expr(&**l, ln) + self.propagate_through_expr(&l, ln) } hir::ExprIndex(ref l, ref r) | hir::ExprBinary(_, ref l, ref r) => { - let r_succ = self.propagate_through_expr(&**r, succ); - self.propagate_through_expr(&**l, r_succ) + let r_succ = self.propagate_through_expr(&r, succ); + self.propagate_through_expr(&l, r_succ) } hir::ExprRange(ref e1, ref e2) => { - let succ = e2.as_ref().map_or(succ, |e| self.propagate_through_expr(&**e, succ)); - e1.as_ref().map_or(succ, |e| self.propagate_through_expr(&**e, succ)) + let succ = e2.as_ref().map_or(succ, |e| self.propagate_through_expr(&e, succ)); + e1.as_ref().map_or(succ, |e| self.propagate_through_expr(&e, succ)) } hir::ExprBox(ref e) | @@ -1164,7 +1164,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { hir::ExprCast(ref e, _) | hir::ExprType(ref e, _) | hir::ExprUnary(_, ref e) => { - self.propagate_through_expr(&**e, succ) + self.propagate_through_expr(&e, succ) } hir::ExprInlineAsm(ref ia) => { @@ -1174,17 +1174,17 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // see comment on lvalues // in propagate_through_lvalue_components() if out.is_indirect { - self.propagate_through_expr(&*out.expr, succ) + self.propagate_through_expr(&out.expr, succ) } else { let acc = if out.is_rw { ACC_WRITE|ACC_READ } else { ACC_WRITE }; - let succ = self.write_lvalue(&*out.expr, succ, acc); - self.propagate_through_lvalue_components(&*out.expr, succ) + let succ = self.write_lvalue(&out.expr, succ, acc); + self.propagate_through_lvalue_components(&out.expr, succ) } } ); // Inputs are executed first. Propagate last because of rev order ia.inputs.iter().rev().fold(succ, |succ, &(_, ref expr)| { - self.propagate_through_expr(&**expr, succ) + self.propagate_through_expr(&expr, succ) }) } @@ -1193,7 +1193,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } hir::ExprBlock(ref blk) => { - self.propagate_through_block(&**blk, succ) + self.propagate_through_block(&blk, succ) } } } @@ -1253,8 +1253,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { match expr.node { hir::ExprPath(..) => succ, - hir::ExprField(ref e, _) => self.propagate_through_expr(&**e, succ), - hir::ExprTupField(ref e, _) => self.propagate_through_expr(&**e, succ), + hir::ExprField(ref e, _) => self.propagate_through_expr(&e, succ), + hir::ExprTupField(ref e, _) => self.propagate_through_expr(&e, succ), _ => self.propagate_through_expr(expr, succ) } } @@ -1336,7 +1336,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { let cond_ln = match kind { LoopLoop => ln, - WhileLoop(ref cond) => self.propagate_through_expr(&**cond, ln), + WhileLoop(ref cond) => self.propagate_through_expr(&cond, ln), }; let body_ln = self.with_loop_nodes(expr.id, succ, ln, |this| { this.propagate_through_block(body, cond_ln) @@ -1349,7 +1349,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { let new_cond_ln = match kind { LoopLoop => ln, WhileLoop(ref cond) => { - self.propagate_through_expr(&**cond, ln) + self.propagate_through_expr(&cond, ln) } }; assert!(cond_ln == new_cond_ln); @@ -1384,10 +1384,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn check_local(this: &mut Liveness, local: &hir::Local) { match local.init { Some(_) => { - this.warn_about_unused_or_dead_vars_in_pat(&*local.pat); + this.warn_about_unused_or_dead_vars_in_pat(&local.pat); }, None => { - this.pat_bindings(&*local.pat, |this, ln, var, sp, id| { + this.pat_bindings(&local.pat, |this, ln, var, sp, id| { this.warn_about_unused(sp, id, ln, var); }) } @@ -1409,28 +1409,28 @@ fn check_arm(this: &mut Liveness, arm: &hir::Arm) { fn check_expr(this: &mut Liveness, expr: &Expr) { match expr.node { hir::ExprAssign(ref l, _) => { - this.check_lvalue(&**l); + this.check_lvalue(&l); intravisit::walk_expr(this, expr); } hir::ExprAssignOp(_, ref l, _) => { - this.check_lvalue(&**l); + this.check_lvalue(&l); intravisit::walk_expr(this, expr); } hir::ExprInlineAsm(ref ia) => { for &(_, ref input) in &ia.inputs { - this.visit_expr(&**input); + this.visit_expr(&input); } // Output operands must be lvalues for out in &ia.outputs { if !out.is_indirect { - this.check_lvalue(&*out.expr); + this.check_lvalue(&out.expr); } - this.visit_expr(&*out.expr); + this.visit_expr(&out.expr); } intravisit::walk_expr(this, expr); @@ -1496,7 +1496,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { None if !body.stmts.is_empty() => match body.stmts.first().unwrap().node { hir::StmtSemi(ref e, _) => { - self.ir.tcx.expr_ty(&**e) == t_ret + self.ir.tcx.expr_ty(&e) == t_ret }, _ => false }, @@ -1565,7 +1565,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn warn_about_unused_args(&self, decl: &hir::FnDecl, entry_ln: LiveNode) { for arg in &decl.inputs { pat_util::pat_bindings(&self.ir.tcx.def_map, - &*arg.pat, + &arg.pat, |_bm, p_id, sp, path1| { let var = self.variable(p_id, sp); // Ignore unused self. diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index affd963fb7917..71af07c21cf50 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -463,12 +463,12 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { let expr_ty = try!(self.expr_ty(expr)); match expr.node { hir::ExprUnary(hir::UnDeref, ref e_base) => { - let base_cmt = try!(self.cat_expr(&**e_base)); + let base_cmt = try!(self.cat_expr(&e_base)); self.cat_deref(expr, base_cmt, 0, None) } hir::ExprField(ref base, f_name) => { - let base_cmt = try!(self.cat_expr(&**base)); + let base_cmt = try!(self.cat_expr(&base)); debug!("cat_expr(cat_field): id={} expr={:?} base={:?}", expr.id, expr, @@ -477,7 +477,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { } hir::ExprTupField(ref base, idx) => { - let base_cmt = try!(self.cat_expr(&**base)); + let base_cmt = try!(self.cat_expr(&base)); Ok(self.cat_tup_field(expr, base_cmt, idx.node, expr_ty)) } @@ -508,7 +508,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { self.cat_deref_common(expr, base_cmt, 1, elem_ty, Some(context), true) } None => { - self.cat_index(expr, try!(self.cat_expr(&**base)), context) + self.cat_index(expr, try!(self.cat_expr(&base)), context) } } } @@ -519,7 +519,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { } hir::ExprType(ref e, _) => { - self.cat_expr(&**e) + self.cat_expr(&e) } hir::ExprAddrOf(..) | hir::ExprCall(..) | @@ -584,7 +584,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { None => { self.tcx().sess.span_bug( span, - &*format!("No closure kind for {:?}", closure_id)); + &format!("No closure kind for {:?}", closure_id)); } } } @@ -1234,29 +1234,29 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { Some(Def::Variant(..)) => { // variant(x, y, z) for (i, subpat) in subpats.iter().enumerate() { - let subpat_ty = try!(self.pat_ty(&**subpat)); // see (*2) + let subpat_ty = try!(self.pat_ty(&subpat)); // see (*2) let subcmt = self.cat_imm_interior( pat, cmt.clone(), subpat_ty, InteriorField(PositionalField(i))); - try!(self.cat_pattern_(subcmt, &**subpat, op)); + try!(self.cat_pattern_(subcmt, &subpat, op)); } } Some(Def::Struct(..)) => { for (i, subpat) in subpats.iter().enumerate() { - let subpat_ty = try!(self.pat_ty(&**subpat)); // see (*2) + let subpat_ty = try!(self.pat_ty(&subpat)); // see (*2) let cmt_field = self.cat_imm_interior( pat, cmt.clone(), subpat_ty, InteriorField(PositionalField(i))); - try!(self.cat_pattern_(cmt_field, &**subpat, op)); + try!(self.cat_pattern_(cmt_field, &subpat, op)); } } Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => { for subpat in subpats { - try!(self.cat_pattern_(cmt.clone(), &**subpat, op)); + try!(self.cat_pattern_(cmt.clone(), &subpat, op)); } } _ => { @@ -1272,7 +1272,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { } hir::PatIdent(_, _, Some(ref subpat)) => { - try!(self.cat_pattern_(cmt, &**subpat, op)); + try!(self.cat_pattern_(cmt, &subpat, op)); } hir::PatIdent(_, _, None) => { @@ -1282,21 +1282,21 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { hir::PatStruct(_, ref field_pats, _) => { // {f1: p1, ..., fN: pN} for fp in field_pats { - let field_ty = try!(self.pat_ty(&*fp.node.pat)); // see (*2) + let field_ty = try!(self.pat_ty(&fp.node.pat)); // see (*2) let cmt_field = self.cat_field(pat, cmt.clone(), fp.node.name, field_ty); - try!(self.cat_pattern_(cmt_field, &*fp.node.pat, op)); + try!(self.cat_pattern_(cmt_field, &fp.node.pat, op)); } } hir::PatTup(ref subpats) => { // (p1, ..., pN) for (i, subpat) in subpats.iter().enumerate() { - let subpat_ty = try!(self.pat_ty(&**subpat)); // see (*2) + let subpat_ty = try!(self.pat_ty(&subpat)); // see (*2) let subcmt = self.cat_imm_interior( pat, cmt.clone(), subpat_ty, InteriorField(PositionalField(i))); - try!(self.cat_pattern_(subcmt, &**subpat, op)); + try!(self.cat_pattern_(subcmt, &subpat, op)); } } @@ -1305,7 +1305,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { // PatRegion since that information is already contained // in the type. let subcmt = try!(self.cat_deref(pat, cmt, 0, None)); - try!(self.cat_pattern_(subcmt, &**subpat, op)); + try!(self.cat_pattern_(subcmt, &subpat, op)); } hir::PatVec(ref before, ref slice, ref after) => { @@ -1313,15 +1313,15 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { let vec_cmt = try!(self.deref_vec(pat, cmt, context)); let elt_cmt = try!(self.cat_index(pat, vec_cmt, context)); for before_pat in before { - try!(self.cat_pattern_(elt_cmt.clone(), &**before_pat, op)); + try!(self.cat_pattern_(elt_cmt.clone(), &before_pat, op)); } if let Some(ref slice_pat) = *slice { - let slice_ty = try!(self.pat_ty(&**slice_pat)); + let slice_ty = try!(self.pat_ty(&slice_pat)); let slice_cmt = self.cat_rvalue_node(pat.id(), pat.span(), slice_ty); - try!(self.cat_pattern_(slice_cmt, &**slice_pat, op)); + try!(self.cat_pattern_(slice_cmt, &slice_pat, op)); } for after_pat in after { - try!(self.cat_pattern_(elt_cmt.clone(), &**after_pat, op)); + try!(self.cat_pattern_(elt_cmt.clone(), &after_pat, op)); } } diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index d2e1b3edc3a68..614d9be147bd8 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -65,7 +65,7 @@ fn method_might_be_inlined(tcx: &ty::ctxt, sig: &hir::MethodSig, if let Some(impl_node_id) = tcx.map.as_local_node_id(impl_src) { match tcx.map.find(impl_node_id) { Some(ast_map::NodeItem(item)) => - item_might_be_inlined(&*item), + item_might_be_inlined(&item), Some(..) | None => tcx.sess.span_bug(impl_item.span, "impl did is not an item") } @@ -166,7 +166,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { match self.tcx.map.find(node_id) { Some(ast_map::NodeItem(item)) => { match item.node { - hir::ItemFn(..) => item_might_be_inlined(&*item), + hir::ItemFn(..) => item_might_be_inlined(&item), _ => false, } } @@ -255,8 +255,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { ast_map::NodeItem(item) => { match item.node { hir::ItemFn(_, _, _, _, _, ref search_block) => { - if item_might_be_inlined(&*item) { - intravisit::walk_block(self, &**search_block) + if item_might_be_inlined(&item) { + intravisit::walk_block(self, &search_block) } } @@ -264,7 +264,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // unconditionally, so we need to make sure that their // contents are also reachable. hir::ItemConst(_, ref init) => { - self.visit_expr(&**init); + self.visit_expr(&init); } // These are normal, nothing reachable about these @@ -285,7 +285,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // Keep going, nothing to get exported } hir::ConstTraitItem(_, Some(ref expr)) => { - self.visit_expr(&*expr); + self.visit_expr(&expr); } hir::MethodTraitItem(_, Some(ref body)) => { intravisit::walk_block(self, body); @@ -296,7 +296,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { ast_map::NodeImplItem(impl_item) => { match impl_item.node { hir::ImplItemKind::Const(_, ref expr) => { - self.visit_expr(&*expr); + self.visit_expr(&expr); } hir::ImplItemKind::Method(ref sig, ref body) => { let did = self.tcx.map.get_parent_did(search_item); diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index bf21b607b778d..81d2f37bfd99e 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -933,13 +933,13 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) { match local.init { Some(ref expr) => { - record_rvalue_scope_if_borrow_expr(visitor, &**expr, blk_scope); + record_rvalue_scope_if_borrow_expr(visitor, &expr, blk_scope); let is_borrow = - if let Some(ref ty) = local.ty { is_borrowed_ty(&**ty) } else { false }; + if let Some(ref ty) = local.ty { is_borrowed_ty(&ty) } else { false }; - if is_binding_pat(&*local.pat) || is_borrow { - record_rvalue_scope(visitor, &**expr, blk_scope); + if is_binding_pat(&local.pat) || is_borrow { + record_rvalue_scope(visitor, &expr, blk_scope); } } @@ -961,22 +961,22 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) { hir::PatIdent(hir::BindByRef(_), _, _) => true, hir::PatStruct(_, ref field_pats, _) => { - field_pats.iter().any(|fp| is_binding_pat(&*fp.node.pat)) + field_pats.iter().any(|fp| is_binding_pat(&fp.node.pat)) } hir::PatVec(ref pats1, ref pats2, ref pats3) => { - pats1.iter().any(|p| is_binding_pat(&**p)) || - pats2.iter().any(|p| is_binding_pat(&**p)) || - pats3.iter().any(|p| is_binding_pat(&**p)) + pats1.iter().any(|p| is_binding_pat(&p)) || + pats2.iter().any(|p| is_binding_pat(&p)) || + pats3.iter().any(|p| is_binding_pat(&p)) } hir::PatEnum(_, Some(ref subpats)) | hir::PatTup(ref subpats) => { - subpats.iter().any(|p| is_binding_pat(&**p)) + subpats.iter().any(|p| is_binding_pat(&p)) } hir::PatBox(ref subpat) => { - is_binding_pat(&**subpat) + is_binding_pat(&subpat) } _ => false, @@ -1006,30 +1006,30 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) { blk_id: CodeExtent) { match expr.node { hir::ExprAddrOf(_, ref subexpr) => { - record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id); - record_rvalue_scope(visitor, &**subexpr, blk_id); + record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id); + record_rvalue_scope(visitor, &subexpr, blk_id); } hir::ExprStruct(_, ref fields, _) => { for field in fields { record_rvalue_scope_if_borrow_expr( - visitor, &*field.expr, blk_id); + visitor, &field.expr, blk_id); } } hir::ExprVec(ref subexprs) | hir::ExprTup(ref subexprs) => { for subexpr in subexprs { record_rvalue_scope_if_borrow_expr( - visitor, &**subexpr, blk_id); + visitor, &subexpr, blk_id); } } hir::ExprCast(ref subexpr, _) => { - record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id) + record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id) } hir::ExprBlock(ref block) => { match block.expr { Some(ref subexpr) => { record_rvalue_scope_if_borrow_expr( - visitor, &**subexpr, blk_id); + visitor, &subexpr, blk_id); } None => { } } @@ -1072,7 +1072,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) { hir::ExprField(ref subexpr, _) | hir::ExprTupField(ref subexpr, _) | hir::ExprIndex(ref subexpr, _) => { - expr = &**subexpr; + expr = &subexpr; } _ => { return; diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 4bdf716e63709..f29e14f67d73f 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -256,7 +256,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { for ty_param in generics.ty_params.iter() { walk_list!(self, visit_ty_param_bound, &ty_param.bounds); match ty_param.default { - Some(ref ty) => self.visit_ty(&**ty), + Some(ref ty) => self.visit_ty(&ty), None => {} } } @@ -271,13 +271,13 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { let result = self.with(LateScope(bound_lifetimes, self.scope), |old_scope, this| { this.check_lifetime_defs(old_scope, bound_lifetimes); - this.visit_ty(&**bounded_ty); + this.visit_ty(&bounded_ty); walk_list!(this, visit_ty_param_bound, bounds); }); self.trait_ref_hack = false; result } else { - self.visit_ty(&**bounded_ty); + self.visit_ty(&bounded_ty); walk_list!(self, visit_ty_param_bound, bounds); } } @@ -295,7 +295,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { ref ty, .. }) => { self.visit_path(path, id); - self.visit_ty(&**ty); + self.visit_ty(&ty); } } } @@ -810,7 +810,7 @@ fn early_bound_lifetime_names(generics: &hir::Generics) -> Vec { &hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate{ref bounds, ref bounded_ty, ..}) => { - collector.visit_ty(&**bounded_ty); + collector.visit_ty(&bounded_ty); walk_list!(&mut collector, visit_ty_param_bound, bounds); } &hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate{ref lifetime, diff --git a/src/librustc/middle/traits/error_reporting.rs b/src/librustc/middle/traits/error_reporting.rs index d09bbc37fe468..fac53ec140dbc 100644 --- a/src/librustc/middle/traits/error_reporting.rs +++ b/src/librustc/middle/traits/error_reporting.rs @@ -770,7 +770,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, err, &parent_predicate, cause_span, - &*data.parent_code); + &data.parent_code); } ObligationCauseCode::ImplDerivedObligation(ref data) => { let parent_trait_ref = infcx.resolve_type_vars_if_possible(&data.parent_trait_ref); @@ -784,7 +784,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, err, &parent_predicate, cause_span, - &*data.parent_code); + &data.parent_code); } ObligationCauseCode::CompareImplMethodObligation => { err.fileline_note( diff --git a/src/librustc/middle/traits/object_safety.rs b/src/librustc/middle/traits/object_safety.rs index 0e4a42bd15134..7ffdc3bdef27a 100644 --- a/src/librustc/middle/traits/object_safety.rs +++ b/src/librustc/middle/traits/object_safety.rs @@ -116,7 +116,7 @@ fn object_safety_violations_for_trait<'tcx>(tcx: &ty::ctxt<'tcx>, .filter_map(|item| { match *item { ty::MethodTraitItem(ref m) => { - object_safety_violation_for_method(tcx, trait_def_id, &**m) + object_safety_violation_for_method(tcx, trait_def_id, &m) .map(|code| ObjectSafetyViolation::Method(m.clone(), code)) } _ => None, diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 9441e34cb9b1f..888a623b24a83 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -196,7 +196,7 @@ pub fn block_query

(b: &hir::Block, p: P) -> bool where P: FnMut(&hir::Expr) - p: p, flag: false, }; - intravisit::walk_block(&mut v, &*b); + intravisit::walk_block(&mut v, &b); return v.flag; }