Skip to content

Commit

Permalink
Autoderef in librustc_lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Feb 12, 2016
1 parent 65b38f3 commit fbeb679
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions src/librustc_lint/types.rs
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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) => {
Expand All @@ -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));
}
},
_ => ()
Expand Down Expand Up @@ -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);
Expand All @@ -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)
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/librustc_lint/unused.rs
Expand Up @@ -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;
}
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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))
Expand All @@ -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, _) |
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}

Expand Down

0 comments on commit fbeb679

Please sign in to comment.