Autoderef in librustc

This commit is contained in:
Jonas Schievink 2016-02-09 22:00:20 +01:00
parent 62bada40de
commit 559fca0fd3
18 changed files with 262 additions and 262 deletions

View File

@ -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"),

View File

@ -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)

View File

@ -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::<hir::Expr>.iter())
self.call(expr, pred, &e, None::<hir::Expr>.iter())
}
hir::ExprTup(ref exprs) => {
@ -413,7 +413,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
opt_expr: &Option<P<hir::Expr>>,
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<Item=&'b hir::Expr>>(&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

View File

@ -72,7 +72,7 @@ impl<'a> fmt::Debug for Matrix<'a> {
let &Matrix(ref m) = self;
let pretty_printed_matrix: Vec<Vec<String>> = m.iter().map(|row| {
row.iter()
.map(|&pat| pat_to_string(&*pat))
.map(|&pat| pat_to_string(&pat))
.collect::<Vec<String>>()
}).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<A, F>(cx: &MatchCheckCtxt, pat: &Pat, refutable: F) -> Option<A>
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);

View File

@ -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<hir::Pat> {
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<hir::Pat>
}),
_ => 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<hir::Pat>
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::Pat>
}
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);
}

View File

@ -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),
}

View File

@ -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 {

View File

@ -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<hir::Expr>]) {
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.<n>
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<P<hir::Expr>>) {
// 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 `[...]`

View File

@ -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<hir::Arg> {
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<ast::Name>) -> 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),

View File

@ -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();

View File

@ -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<Expr>], 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.

View File

@ -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));
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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<ast::Name> {
&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,

View File

@ -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(

View File

@ -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,

View File

@ -196,7 +196,7 @@ pub fn block_query<P>(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;
}