mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
update to the rust-PR that unblocks clippy
This commit is contained in:
parent
4a05fbba3e
commit
778ce4dfd3
66 changed files with 217 additions and 217 deletions
|
@ -59,8 +59,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if let ExprLit(ref lit) = e.node {
|
||||
check_lit(cx, lit, e);
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ impl LintPass for Arithmetic {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Arithmetic {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
if self.span.is_some() {
|
||||
return;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ impl LateLintPass for Arithmetic {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_expr_post<'a, 'tcx: 'a>(&mut self, _: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
fn check_expr_post(&mut self, _: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
if Some(expr.span) == self.span {
|
||||
self.span = None;
|
||||
}
|
||||
|
|
|
@ -55,8 +55,8 @@ impl LintPass for ArrayIndexing {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for ArrayIndexing {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ArrayIndexing {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
|
||||
if let hir::ExprIndex(ref array, ref index) = e.node {
|
||||
// Array with known size can be checked statically
|
||||
let ty = cx.tcx.tables().expr_ty(array);
|
||||
|
|
|
@ -66,8 +66,8 @@ impl LintPass for AssignOps {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for AssignOps {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
match expr.node {
|
||||
hir::ExprAssignOp(op, ref lhs, ref rhs) => {
|
||||
span_lint_and_then(cx, ASSIGN_OPS, expr.span, "assign operation detected", |db| {
|
||||
|
|
|
@ -81,8 +81,8 @@ impl LintPass for AttrPass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for AttrPass {
|
||||
fn check_attribute<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, attr: &'tcx Attribute) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
|
||||
fn check_attribute(&mut self, cx: &LateContext<'a, 'tcx>, attr: &'tcx Attribute) {
|
||||
if let MetaItemKind::List(ref items) = attr.value.node {
|
||||
if items.is_empty() || attr.name() != "deprecated" {
|
||||
return;
|
||||
|
@ -99,7 +99,7 @@ impl LateLintPass for AttrPass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if is_relevant_item(cx, item) {
|
||||
check_attrs(cx, item.span, &item.name, &item.attrs)
|
||||
}
|
||||
|
@ -138,13 +138,13 @@ impl LateLintPass for AttrPass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_impl_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||
if is_relevant_impl(cx, item) {
|
||||
check_attrs(cx, item.span, &item.name, &item.attrs)
|
||||
}
|
||||
}
|
||||
|
||||
fn check_trait_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
|
||||
if is_relevant_trait(cx, item) {
|
||||
check_attrs(cx, item.span, &item.name, &item.attrs)
|
||||
}
|
||||
|
|
|
@ -79,8 +79,8 @@ impl LintPass for BitMask {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for BitMask {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if let ExprBinary(ref cmp, ref left, ref right) = e.node {
|
||||
if cmp.node.is_comparison() {
|
||||
if let Some(cmp_opt) = fetch_int_literal(cx, right) {
|
||||
|
|
|
@ -37,8 +37,8 @@ impl LintPass for BlackListedName {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for BlackListedName {
|
||||
fn check_pat<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlackListedName {
|
||||
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
|
||||
if let PatKind::Binding(_, _, ref ident, _) = pat.node {
|
||||
if self.blacklist.iter().any(|s| s == &*ident.node.as_str()) {
|
||||
span_lint(cx,
|
||||
|
|
|
@ -74,8 +74,8 @@ const BRACED_EXPR_MESSAGE: &'static str = "omit braces around single expression
|
|||
const COMPLEX_BLOCK_MESSAGE: &'static str = "in an 'if' condition, avoid complex blocks or closures with blocks; \
|
||||
instead, move the block or closure higher and bind it with a 'let'";
|
||||
|
||||
impl LateLintPass for BlockInIfCondition {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprIf(ref check, ref then, _) = expr.node {
|
||||
if let ExprBlock(ref block) = check.node {
|
||||
if block.rules == DefaultBlock {
|
||||
|
|
|
@ -53,8 +53,8 @@ impl LintPass for NonminimalBool {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for NonminimalBool {
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonminimalBool {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
NonminimalBoolVisitor { cx: cx }.visit_item(item)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,8 +109,8 @@ impl LintPass for CopyAndPaste {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for CopyAndPaste {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyAndPaste {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if !in_macro(cx, expr.span) {
|
||||
// skip ifs directly in else, it will be checked in the parent if
|
||||
if let Some(&Expr { node: ExprIf(_, _, Some(ref else_expr)), .. }) = get_parent_expr(cx, expr) {
|
||||
|
|
|
@ -90,8 +90,8 @@ impl CyclomaticComplexity {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for CyclomaticComplexity {
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CyclomaticComplexity {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let ItemFn(_, _, _, _, _, eid) = item.node {
|
||||
if !attr::contains_name(&item.attrs, "test") {
|
||||
self.check(cx, cx.tcx.map.expr(eid), item.span);
|
||||
|
@ -99,22 +99,22 @@ impl LateLintPass for CyclomaticComplexity {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_impl_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||
if let ImplItemKind::Method(_, eid) = item.node {
|
||||
self.check(cx, cx.tcx.map.expr(eid), item.span);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_trait_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
|
||||
if let MethodTraitItem(_, Some(eid)) = item.node {
|
||||
self.check(cx, cx.tcx.map.expr(eid), item.span);
|
||||
}
|
||||
}
|
||||
|
||||
fn enter_lint_attrs<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, attrs: &'tcx [Attribute]) {
|
||||
fn enter_lint_attrs(&mut self, cx: &LateContext<'a, 'tcx>, attrs: &'tcx [Attribute]) {
|
||||
self.limit.push_attrs(cx.sess(), attrs, "cyclomatic_complexity");
|
||||
}
|
||||
fn exit_lint_attrs<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, attrs: &'tcx [Attribute]) {
|
||||
fn exit_lint_attrs(&mut self, cx: &LateContext<'a, 'tcx>, attrs: &'tcx [Attribute]) {
|
||||
self.limit.pop_attrs(cx.sess(), attrs, "cyclomatic_complexity");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,8 +70,8 @@ impl LintPass for Derive {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Derive {
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node {
|
||||
let ty = cx.tcx.item_type(cx.tcx.map.local_def_id(item.id));
|
||||
let is_automatically_derived = is_automatically_derived(&*item.attrs);
|
||||
|
@ -86,7 +86,7 @@ impl LateLintPass for Derive {
|
|||
}
|
||||
|
||||
/// Implementation of the `DERIVE_HASH_XOR_EQ` lint.
|
||||
fn check_hash_peq<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, span: Span, trait_ref: &TraitRef, ty: ty::Ty<'tcx>,
|
||||
fn check_hash_peq<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, span: Span, trait_ref: &TraitRef, ty: ty::Ty<'tcx>,
|
||||
hash_is_automatically_derived: bool) {
|
||||
if_let_chain! {[
|
||||
match_path_old(&trait_ref.path, &paths::HASH),
|
||||
|
|
|
@ -35,8 +35,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprCall(ref path, ref args) = expr.node {
|
||||
if let ExprPath(ref qpath) = path.node {
|
||||
let def_id = cx.tcx.tables().qpath_def(qpath, path.id).def_id();
|
||||
|
|
|
@ -39,8 +39,8 @@ impl LintPass for HashMapLint {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for HashMapLint {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HashMapLint {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprIf(ref check, ref then_block, ref else_block) = expr.node {
|
||||
if let ExprUnary(UnOp::UnNot, ref check) = check.node {
|
||||
if let Some((ty, map, key)) = check_cond(cx, check) {
|
||||
|
|
|
@ -36,9 +36,9 @@ impl LintPass for UnportableVariant {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for UnportableVariant {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
|
||||
#[allow(cast_possible_truncation, cast_sign_loss)]
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let ItemEnum(ref def, _) = item.node {
|
||||
for var in &def.variants {
|
||||
let variant = &var.node;
|
||||
|
|
|
@ -32,8 +32,8 @@ impl LintPass for EnumGlobUse {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for EnumGlobUse {
|
||||
fn check_mod<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, m: &'tcx Mod, _: Span, _: NodeId) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EnumGlobUse {
|
||||
fn check_mod(&mut self, cx: &LateContext<'a, 'tcx>, m: &'tcx Mod, _: Span, _: NodeId) {
|
||||
// only check top level `use` statements
|
||||
for item in &m.item_ids {
|
||||
self.lint_item(cx, cx.krate.item(item.id));
|
||||
|
|
|
@ -32,8 +32,8 @@ impl LintPass for EqOp {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for EqOp {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if let ExprBinary(ref op, ref left, ref right) = e.node {
|
||||
if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) {
|
||||
span_lint(cx,
|
||||
|
|
|
@ -60,8 +60,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_fn<'a, 'tcx: 'a>(
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_fn(
|
||||
&mut self,
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
_: visit::FnKind<'tcx>,
|
||||
|
|
|
@ -33,8 +33,8 @@ impl LintPass for EtaPass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for EtaPass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EtaPass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
match expr.node {
|
||||
ExprCall(_, ref args) |
|
||||
ExprMethodCall(_, _, ref args) => {
|
||||
|
|
|
@ -56,8 +56,8 @@ impl LintPass for EvalOrderDependence {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for EvalOrderDependence {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
// Find a write to a local variable.
|
||||
match expr.node {
|
||||
ExprAssign(ref lhs, _) | ExprAssignOp(_, ref lhs, _) => {
|
||||
|
@ -79,7 +79,7 @@ impl LateLintPass for EvalOrderDependence {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
fn check_stmt<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
|
||||
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
|
||||
match stmt.node {
|
||||
StmtExpr(ref e, _) | StmtSemi(ref e, _) => DivergenceVisitor { cx: cx }.maybe_walk_expr(e),
|
||||
StmtDecl(ref d, _) => {
|
||||
|
@ -214,7 +214,7 @@ enum StopEarly {
|
|||
Stop,
|
||||
}
|
||||
|
||||
fn check_expr<'a, 'tcx: 'a>(vis: & mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> StopEarly {
|
||||
fn check_expr<'a, 'tcx>(vis: & mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> StopEarly {
|
||||
if expr.id == vis.last_expr.id {
|
||||
return StopEarly::KeepGoing;
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ fn check_expr<'a, 'tcx: 'a>(vis: & mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr)
|
|||
StopEarly::KeepGoing
|
||||
}
|
||||
|
||||
fn check_stmt<'a, 'tcx: 'a>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> StopEarly {
|
||||
fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> StopEarly {
|
||||
match stmt.node {
|
||||
StmtExpr(ref expr, _) |
|
||||
StmtSemi(ref expr, _) => check_expr(vis, expr),
|
||||
|
|
|
@ -38,8 +38,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let Some(span) = is_expn_of(cx, expr.span, "format") {
|
||||
match expr.node {
|
||||
// `format!("{}", foo)` expansion
|
||||
|
|
|
@ -68,8 +68,8 @@ impl LintPass for Functions {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Functions {
|
||||
fn check_fn<'a, 'tcx: 'a>(
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
|
||||
fn check_fn(
|
||||
&mut self,
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
kind: intravisit::FnKind<'tcx>,
|
||||
|
@ -105,7 +105,7 @@ impl LateLintPass for Functions {
|
|||
self.check_raw_ptr(cx, unsafety, decl, expr, nodeid);
|
||||
}
|
||||
|
||||
fn check_trait_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
|
||||
if let hir::MethodTraitItem(ref sig, eid) = item.node {
|
||||
// don't lint extern functions decls, it's not their fault
|
||||
if sig.abi == Abi::Rust {
|
||||
|
@ -120,7 +120,7 @@ impl LateLintPass for Functions {
|
|||
}
|
||||
}
|
||||
|
||||
impl Functions {
|
||||
impl<'a, 'tcx> Functions {
|
||||
fn check_arg_number(&self, cx: &LateContext, decl: &hir::FnDecl, span: Span) {
|
||||
let args = decl.inputs.len() as u64;
|
||||
if args > self.threshold {
|
||||
|
@ -131,7 +131,7 @@ impl Functions {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_raw_ptr<'a, 'tcx: 'a>(
|
||||
fn check_raw_ptr(
|
||||
&self,
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
unsafety: hir::Unsafety,
|
||||
|
|
|
@ -31,8 +31,8 @@ impl LintPass for IdentityOp {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for IdentityOp {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if in_macro(cx, e.span) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
|
||||
if let ExprMatch(ref op, ref arms, MatchSource::IfLetDesugar{..}) = expr.node {
|
||||
|
||||
|
|
|
@ -59,8 +59,8 @@ impl LintPass for LenZero {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for LenZero {
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if in_macro(cx, item.span) {
|
||||
return;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ impl LateLintPass for LenZero {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if in_macro(cx, expr.span) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -57,8 +57,8 @@ impl LintPass for LetIfSeq {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for LetIfSeq {
|
||||
fn check_block<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx hir::Block) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
|
||||
fn check_block(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx hir::Block) {
|
||||
let mut it = block.stmts.iter().peekable();
|
||||
while let Some(stmt) = it.next() {
|
||||
if_let_chain! {[
|
||||
|
@ -149,7 +149,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_assign<'a, 'tcx: 'a>(
|
||||
fn check_assign<'a, 'tcx>(
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
decl: hir::def_id::DefId,
|
||||
block: &'tcx hir::Block,
|
||||
|
|
|
@ -56,20 +56,20 @@ impl LintPass for LifetimePass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for LifetimePass {
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LifetimePass {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let ItemFn(ref decl, _, _, _, ref generics, _) = item.node {
|
||||
check_fn_inner(cx, decl, generics, item.span);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_impl_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||
if let ImplItemKind::Method(ref sig, _) = item.node {
|
||||
check_fn_inner(cx, &sig.decl, &sig.generics, item.span);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_trait_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
|
||||
if let MethodTraitItem(ref sig, _) = item.node {
|
||||
check_fn_inner(cx, &sig.decl, &sig.generics, item.span);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ fn bound_lifetimes(bound: &TyParamBound) -> HirVec<&Lifetime> {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_fn_inner<'a, 'tcx: 'a>(
|
||||
fn check_fn_inner<'a, 'tcx>(
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
decl: &'tcx FnDecl,
|
||||
generics: &'tcx Generics,
|
||||
|
|
|
@ -307,8 +307,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let Some((pat, arg, body)) = higher::for_loop(expr) {
|
||||
check_for_loop(cx, pat, arg, body, expr);
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ impl LateLintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_stmt<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
|
||||
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
|
||||
if let StmtSemi(ref expr, _) = stmt.node {
|
||||
if let ExprMethodCall(ref method, _, ref args) = expr.node {
|
||||
if args.len() == 1 && &*method.node.as_str() == "collect" &&
|
||||
|
@ -407,7 +407,7 @@ impl LateLintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_for_loop<'a, 'tcx: 'a>(
|
||||
fn check_for_loop<'a, 'tcx>(
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
pat: &'tcx Pat,
|
||||
arg: &'tcx Expr,
|
||||
|
@ -423,7 +423,7 @@ fn check_for_loop<'a, 'tcx: 'a>(
|
|||
|
||||
/// Check for looping over a range and then indexing a sequence with it.
|
||||
/// The iteratee must be a range literal.
|
||||
fn check_for_loop_range<'a, 'tcx: 'a>(
|
||||
fn check_for_loop_range<'a, 'tcx>(
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
pat: &'tcx Pat,
|
||||
arg: &'tcx Expr,
|
||||
|
@ -658,7 +658,7 @@ fn check_arg_type(cx: &LateContext, pat: &Pat, arg: &Expr) {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_for_loop_explicit_counter<'a, 'tcx: 'a>(
|
||||
fn check_for_loop_explicit_counter<'a, 'tcx>(
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
arg: &'tcx Expr,
|
||||
body: &'tcx Expr,
|
||||
|
@ -708,7 +708,7 @@ fn check_for_loop_explicit_counter<'a, 'tcx: 'a>(
|
|||
}
|
||||
|
||||
/// Check for the `FOR_KV_MAP` lint.
|
||||
fn check_for_loop_over_map_kv<'a, 'tcx: 'a>(
|
||||
fn check_for_loop_over_map_kv<'a, 'tcx>(
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
pat: &'tcx Pat,
|
||||
arg: &'tcx Expr,
|
||||
|
|
|
@ -24,8 +24,8 @@ declare_lint! {
|
|||
#[derive(Copy, Clone)]
|
||||
pub struct Pass;
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
// call to .map()
|
||||
if let ExprMethodCall(name, _, ref args) = expr.node {
|
||||
if &*name.node.as_str() == "map" && args.len() == 2 {
|
||||
|
|
|
@ -129,8 +129,8 @@ impl LintPass for MatchPass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for MatchPass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MatchPass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if in_external_macro(cx, expr.span) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ impl LintPass for MemForget {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for MemForget {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemForget {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if let ExprCall(ref path_expr, ref args) = e.node {
|
||||
if let ExprPath(ref qpath) = path_expr.node {
|
||||
let def_id = cx.tcx.tables().qpath_def(qpath, path_expr.id).def_id();
|
||||
|
|
|
@ -549,11 +549,11 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
#[allow(unused_attributes)]
|
||||
// ^ required because `cyclomatic_complexity` attribute shows up as unused
|
||||
#[cyclomatic_complexity = "30"]
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
if in_macro(cx, expr.span) {
|
||||
return;
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ impl LateLintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_impl_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, implitem: &'tcx hir::ImplItem) {
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, implitem: &'tcx hir::ImplItem) {
|
||||
if in_external_macro(cx, implitem.span) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ impl LintPass for MinMaxPass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for MinMaxPass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MinMaxPass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let Some((outer_max, outer_c, oe)) = min_max(cx, expr) {
|
||||
if let Some((inner_max, inner_c, _)) = min_max(cx, oe) {
|
||||
if outer_max == inner_max {
|
||||
|
|
|
@ -166,8 +166,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_fn<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, k: FnKind<'tcx>, decl: &'tcx FnDecl, _: &'tcx Expr, _: Span, _: NodeId) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_fn(&mut self, cx: &LateContext<'a, 'tcx>, k: FnKind<'tcx>, decl: &'tcx FnDecl, _: &'tcx Expr, _: Span, _: NodeId) {
|
||||
if let FnKind::Closure(_) = k {
|
||||
// Does not apply to closures
|
||||
return;
|
||||
|
@ -182,7 +182,7 @@ impl LateLintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_stmt<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx Stmt) {
|
||||
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx Stmt) {
|
||||
if_let_chain! {[
|
||||
let StmtDecl(ref d, _) = s.node,
|
||||
let DeclLocal(ref l) = d.node,
|
||||
|
@ -216,7 +216,7 @@ impl LateLintPass for Pass {
|
|||
}}
|
||||
}
|
||||
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprBinary(ref cmp, ref left, ref right) = expr.node {
|
||||
let op = cmp.node;
|
||||
if op.is_comparison() {
|
||||
|
@ -294,7 +294,7 @@ impl LateLintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_pat<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
|
||||
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
|
||||
if let PatKind::Binding(_, _, ref ident, Some(ref right)) = pat.node {
|
||||
if right.node == PatKind::Wild {
|
||||
span_lint(cx,
|
||||
|
|
|
@ -94,8 +94,8 @@ impl LintPass for MissingDoc {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for MissingDoc {
|
||||
fn enter_lint_attrs<'a, 'tcx: 'a>(&mut self, _: &LateContext<'a, 'tcx>, attrs: &'tcx [ast::Attribute]) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
fn enter_lint_attrs(&mut self, _: &LateContext<'a, 'tcx>, attrs: &'tcx [ast::Attribute]) {
|
||||
let doc_hidden = self.doc_hidden() || attrs.iter().any(|attr| {
|
||||
attr.check_name("doc") && match attr.meta_item_list() {
|
||||
None => false,
|
||||
|
@ -105,15 +105,15 @@ impl LateLintPass for MissingDoc {
|
|||
self.doc_hidden_stack.push(doc_hidden);
|
||||
}
|
||||
|
||||
fn exit_lint_attrs<'a, 'tcx: 'a>(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx [ast::Attribute]) {
|
||||
fn exit_lint_attrs(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx [ast::Attribute]) {
|
||||
self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
|
||||
}
|
||||
|
||||
fn check_crate<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
|
||||
fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
|
||||
self.check_missing_docs_attrs(cx, &krate.attrs, krate.span, "crate");
|
||||
}
|
||||
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
|
||||
let desc = match it.node {
|
||||
hir::ItemConst(..) => "a constant",
|
||||
hir::ItemEnum(..) => "an enum",
|
||||
|
@ -134,7 +134,7 @@ impl LateLintPass for MissingDoc {
|
|||
self.check_missing_docs_attrs(cx, &it.attrs, it.span, desc);
|
||||
}
|
||||
|
||||
fn check_trait_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir::TraitItem) {
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir::TraitItem) {
|
||||
let desc = match trait_item.node {
|
||||
hir::ConstTraitItem(..) => "an associated constant",
|
||||
hir::MethodTraitItem(..) => "a trait method",
|
||||
|
@ -144,7 +144,7 @@ impl LateLintPass for MissingDoc {
|
|||
self.check_missing_docs_attrs(cx, &trait_item.attrs, trait_item.span, desc);
|
||||
}
|
||||
|
||||
fn check_impl_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem) {
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem) {
|
||||
// If the method is an impl for a trait, don't doc.
|
||||
let def_id = cx.tcx.map.local_def_id(impl_item.id);
|
||||
match cx.tcx.associated_item(def_id).container {
|
||||
|
@ -164,13 +164,13 @@ impl LateLintPass for MissingDoc {
|
|||
self.check_missing_docs_attrs(cx, &impl_item.attrs, impl_item.span, desc);
|
||||
}
|
||||
|
||||
fn check_struct_field<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, sf: &'tcx hir::StructField) {
|
||||
fn check_struct_field(&mut self, cx: &LateContext<'a, 'tcx>, sf: &'tcx hir::StructField) {
|
||||
if !sf.is_positional() {
|
||||
self.check_missing_docs_attrs(cx, &sf.attrs, sf.span, "a struct field");
|
||||
}
|
||||
}
|
||||
|
||||
fn check_variant<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, v: &'tcx hir::Variant, _: &hir::Generics) {
|
||||
fn check_variant(&mut self, cx: &LateContext<'a, 'tcx>, v: &'tcx hir::Variant, _: &hir::Generics) {
|
||||
self.check_missing_docs_attrs(cx, &v.node.attrs, v.span, "a variant");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ impl LintPass for MutMut {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for MutMut {
|
||||
fn check_block<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx hir::Block) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutMut {
|
||||
fn check_block(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx hir::Block) {
|
||||
intravisit::walk_block(&mut MutVisitor { cx: cx }, block);
|
||||
}
|
||||
|
||||
fn check_ty<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, ty: &'tcx hir::Ty) {
|
||||
fn check_ty(&mut self, cx: &LateContext<'a, 'tcx>, ty: &'tcx hir::Ty) {
|
||||
use rustc::hir::intravisit::Visitor;
|
||||
|
||||
MutVisitor { cx: cx }.visit_ty(ty);
|
||||
|
|
|
@ -32,8 +32,8 @@ impl LintPass for UnnecessaryMutPassed {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for UnnecessaryMutPassed {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
let borrowed_table = cx.tcx.tables.borrow();
|
||||
match e.node {
|
||||
ExprCall(ref fn_expr, ref arguments) => {
|
||||
|
|
|
@ -54,8 +54,8 @@ impl LintPass for MutexAtomic {
|
|||
|
||||
pub struct MutexAtomic;
|
||||
|
||||
impl LateLintPass for MutexAtomic {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutexAtomic {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
let ty = cx.tcx.tables().expr_ty(expr);
|
||||
if let ty::TyAdt(_, subst) = ty.sty {
|
||||
if match_type(cx, ty, &paths::MUTEX) {
|
||||
|
|
|
@ -56,8 +56,8 @@ impl LintPass for NeedlessBool {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for NeedlessBool {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
use self::Expression::*;
|
||||
if let ExprIf(ref pred, ref then_block, Some(ref else_expr)) = e.node {
|
||||
let reduce = |ret, not| {
|
||||
|
@ -116,8 +116,8 @@ impl LintPass for BoolComparison {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for BoolComparison {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoolComparison {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
use self::Expression::*;
|
||||
if let ExprBinary(Spanned { node: BiEq, .. }, ref left_side, ref right_side) = e.node {
|
||||
match (fetch_bool_expr(left_side), fetch_bool_expr(right_side)) {
|
||||
|
|
|
@ -34,8 +34,8 @@ impl LintPass for NeedlessBorrow {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for NeedlessBorrow {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if in_macro(cx, e.span) {
|
||||
return;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ impl LateLintPass for NeedlessBorrow {
|
|||
}
|
||||
}
|
||||
}
|
||||
fn check_pat<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
|
||||
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
|
||||
if in_macro(cx, pat.span) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprStruct(_, ref fields, Some(ref base)) = expr.node {
|
||||
let ty = cx.tcx.tables().expr_ty(expr);
|
||||
if let TyAdt(def, _) = ty.sty {
|
||||
|
|
|
@ -31,8 +31,8 @@ impl LintPass for NegMultiply {
|
|||
}
|
||||
|
||||
#[allow(match_same_arms)]
|
||||
impl LateLintPass for NegMultiply {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NegMultiply {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if let ExprBinary(Spanned { node: BiMul, .. }, ref l, ref r) = e.node {
|
||||
match (&l.node, &r.node) {
|
||||
(&ExprUnary(..), &ExprUnary(..)) => (),
|
||||
|
|
|
@ -89,8 +89,8 @@ impl LintPass for NewWithoutDefault {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for NewWithoutDefault {
|
||||
fn check_fn<'a, 'tcx: 'a>(
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
|
||||
fn check_fn(
|
||||
&mut self,
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
kind: FnKind<'tcx>,
|
||||
|
|
|
@ -102,8 +102,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_stmt<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
|
||||
if let StmtSemi(ref expr, _) = stmt.node {
|
||||
if has_no_effect(cx, expr) {
|
||||
span_lint(cx, NO_EFFECT, stmt.span, "statement with no effect");
|
||||
|
|
|
@ -40,8 +40,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if_let_chain! {[ //begin checking variables
|
||||
let ExprMatch(ref op, ref body, ref source) = expr.node, //test if expr is a match
|
||||
let MatchSource::IfLetDesugar { .. } = *source, //test if it is an If Let
|
||||
|
|
|
@ -32,8 +32,8 @@ impl LintPass for NonSensical {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for NonSensical {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSensical {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if let ExprMethodCall(ref name, _, ref arguments) = e.node {
|
||||
let (obj_ty, _) = walk_ptrs_ty_depth(cx.tcx.tables().expr_ty(&arguments[0]));
|
||||
if &*name.node.as_str() == "open" && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) {
|
||||
|
|
|
@ -29,9 +29,9 @@ impl LintPass for OverflowCheckConditional {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for OverflowCheckConditional {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OverflowCheckConditional {
|
||||
// a + b < a, a > a + b, a < a - b, a - b > a
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if_let_chain! {[
|
||||
let Expr_::ExprBinary(ref op, ref first, ref second) = expr.node,
|
||||
let Expr_::ExprBinary(ref op2, ref ident1, ref ident2) = first.node,
|
||||
|
|
|
@ -32,8 +32,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if_let_chain! {[
|
||||
let ExprBlock(ref block) = expr.node,
|
||||
let Some(ref ex) = block.expr,
|
||||
|
|
|
@ -35,8 +35,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if_let_chain! {[
|
||||
let ItemImpl(_, _, _, Some(ref trait_ref), _, ref impl_items) = item.node,
|
||||
!is_automatically_derived(&*item.attrs),
|
||||
|
|
|
@ -65,8 +65,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if_let_chain! {[
|
||||
let ExprCall(ref fun, ref args) = expr.node,
|
||||
let ExprPath(ref qpath) = fun.node,
|
||||
|
|
|
@ -54,14 +54,14 @@ impl LintPass for PointerPass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for PointerPass {
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let ItemFn(ref decl, _, _, _, _, _) = item.node {
|
||||
check_fn(cx, decl, item.id);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_impl_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||
if let ImplItemKind::Method(ref sig, _) = item.node {
|
||||
if let Some(NodeItem(it)) = cx.tcx.map.find(cx.tcx.map.get_parent(item.id)) {
|
||||
if let ItemImpl(_, _, _, Some(_), _, _) = it.node {
|
||||
|
@ -72,13 +72,13 @@ impl LateLintPass for PointerPass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_trait_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
|
||||
if let MethodTraitItem(ref sig, _) = item.node {
|
||||
check_fn(cx, &sig.decl, item.id);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprBinary(ref op, ref l, ref r) = expr.node {
|
||||
if (op.node == BiEq || op.node == BiNe) && (is_null_path(l) || is_null_path(r)) {
|
||||
span_lint(cx,
|
||||
|
|
|
@ -46,8 +46,8 @@ impl LintPass for StepByZero {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for StepByZero {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StepByZero {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprMethodCall(Spanned { node: ref name, .. }, _, ref args) = expr.node {
|
||||
let name = &*name.as_str();
|
||||
|
||||
|
|
|
@ -82,12 +82,12 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_crate<'a, 'tcx: 'a>(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx Crate) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_crate(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx Crate) {
|
||||
self.spans.clear();
|
||||
}
|
||||
|
||||
fn check_block<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx Block) {
|
||||
fn check_block(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx Block) {
|
||||
if_let_chain!{[
|
||||
self.last.is_none(),
|
||||
let Some(ref expr) = block.expr,
|
||||
|
@ -106,13 +106,13 @@ impl LateLintPass for Pass {
|
|||
}}
|
||||
}
|
||||
|
||||
fn check_block_post<'a, 'tcx: 'a>(&mut self, _: &LateContext<'a, 'tcx>, block: &'tcx Block) {
|
||||
fn check_block_post(&mut self, _: &LateContext<'a, 'tcx>, block: &'tcx Block) {
|
||||
if self.last.map_or(false, |id| block.id == id) {
|
||||
self.last = None;
|
||||
}
|
||||
}
|
||||
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if_let_chain!{[
|
||||
let ExprCall(ref fun, ref args) = expr.node,
|
||||
let ExprPath(ref qpath) = fun.node,
|
||||
|
|
|
@ -26,8 +26,8 @@ impl LintPass for Serde {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Serde {
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Serde {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let ItemImpl(_, _, _, Some(ref trait_ref), _, ref items) = item.node {
|
||||
let did = trait_ref.path.def.def_id();
|
||||
if let Some(visit_did) = get_trait_def_id(cx, &paths::SERDE_DE_VISITOR) {
|
||||
|
|
|
@ -79,8 +79,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_fn<'a, 'tcx: 'a>(
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_fn(
|
||||
&mut self,
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
_: FnKind<'tcx>,
|
||||
|
@ -96,7 +96,7 @@ impl LateLintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_fn<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, expr: &'tcx Expr) {
|
||||
fn check_fn<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, expr: &'tcx Expr) {
|
||||
let mut bindings = Vec::new();
|
||||
for arg in &decl.inputs {
|
||||
if let PatKind::Binding(_, _, ident, _) = arg.pat.node {
|
||||
|
@ -106,7 +106,7 @@ fn check_fn<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, expr:
|
|||
check_expr(cx, expr, &mut bindings);
|
||||
}
|
||||
|
||||
fn check_block<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, block: &'tcx Block, bindings: &mut Vec<(Name, Span)>) {
|
||||
fn check_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, block: &'tcx Block, bindings: &mut Vec<(Name, Span)>) {
|
||||
let len = bindings.len();
|
||||
for stmt in &block.stmts {
|
||||
match stmt.node {
|
||||
|
@ -121,7 +121,7 @@ fn check_block<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, block: &'tcx Block, bin
|
|||
bindings.truncate(len);
|
||||
}
|
||||
|
||||
fn check_decl<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, decl: &'tcx Decl, bindings: &mut Vec<(Name, Span)>) {
|
||||
fn check_decl<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx Decl, bindings: &mut Vec<(Name, Span)>) {
|
||||
if in_external_macro(cx, decl.span) {
|
||||
return;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ fn is_binding(cx: &LateContext, pat_id: NodeId) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_pat<'a, 'tcx: 'a>(
|
||||
fn check_pat<'a, 'tcx>(
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
pat: &'tcx Pat,
|
||||
init: Option<&'tcx Expr>,
|
||||
|
@ -285,7 +285,7 @@ fn lint_shadow<'a, 'tcx: 'a>(
|
|||
}
|
||||
}
|
||||
|
||||
fn check_expr<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings: &mut Vec<(Name, Span)>) {
|
||||
fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings: &mut Vec<(Name, Span)>) {
|
||||
if in_external_macro(cx, expr.span) {
|
||||
return;
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ fn check_expr<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindin
|
|||
}
|
||||
}
|
||||
|
||||
fn check_ty<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut Vec<(Name, Span)>) {
|
||||
fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut Vec<(Name, Span)>) {
|
||||
match ty.node {
|
||||
TyObjectSum(ref sty, _) |
|
||||
TySlice(ref sty) => check_ty(cx, sty, bindings),
|
||||
|
|
|
@ -79,8 +79,8 @@ impl LintPass for StringAdd {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for StringAdd {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringAdd {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if let ExprBinary(Spanned { node: BiAdd, .. }, ref left, _) = e.node {
|
||||
if is_string(cx, left) {
|
||||
if let Allow = cx.current_level(STRING_ADD_ASSIGN) {
|
||||
|
@ -136,8 +136,8 @@ impl LintPass for StringLitAsBytes {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for StringLitAsBytes {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
use std::ascii::AsciiExt;
|
||||
use syntax::ast::LitKind;
|
||||
use utils::{snippet, in_macro};
|
||||
|
|
|
@ -50,8 +50,8 @@ impl LintPass for Swap {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Swap {
|
||||
fn check_block<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx Block) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Swap {
|
||||
fn check_block(&mut self, cx: &LateContext<'a, 'tcx>, block: &'tcx Block) {
|
||||
check_manual_swap(cx, block);
|
||||
check_suspicious_swap(cx, block);
|
||||
}
|
||||
|
|
|
@ -37,8 +37,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprAssign(ref target, _) = expr.node {
|
||||
match target.node {
|
||||
ExprField(ref base, _) |
|
||||
|
|
|
@ -84,8 +84,8 @@ impl LintPass for Transmute {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Transmute {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if let ExprCall(ref path_expr, ref args) = e.node {
|
||||
if let ExprPath(ref qpath) = path_expr.node {
|
||||
let def_id = cx.tcx.tables().qpath_def(qpath, path_expr.id).def_id();
|
||||
|
|
|
@ -69,8 +69,8 @@ impl LintPass for TypePass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for TypePass {
|
||||
fn check_ty<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, ast_ty: &'tcx Ty) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypePass {
|
||||
fn check_ty(&mut self, cx: &LateContext<'a, 'tcx>, ast_ty: &'tcx Ty) {
|
||||
if in_macro(cx, ast_ty.span) {
|
||||
return;
|
||||
}
|
||||
|
@ -153,8 +153,8 @@ impl LintPass for LetPass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for LetPass {
|
||||
fn check_decl<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, decl: &'tcx Decl) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetPass {
|
||||
fn check_decl(&mut self, cx: &LateContext<'a, 'tcx>, decl: &'tcx Decl) {
|
||||
check_let_unit(cx, decl)
|
||||
}
|
||||
}
|
||||
|
@ -190,8 +190,8 @@ impl LintPass for UnitCmp {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for UnitCmp {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitCmp {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if in_macro(cx, expr.span) {
|
||||
return;
|
||||
}
|
||||
|
@ -447,8 +447,8 @@ impl LintPass for CastPass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for CastPass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprCast(ref ex, _) = expr.node {
|
||||
let (cast_from, cast_to) = (cx.tcx.tables().expr_ty(ex), cx.tcx.tables().expr_ty(expr));
|
||||
if cast_from.is_numeric() && cast_to.is_numeric() && !in_external_macro(cx, expr.span) {
|
||||
|
@ -535,17 +535,17 @@ impl LintPass for TypeComplexityPass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for TypeComplexityPass {
|
||||
fn check_fn<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, _: FnKind<'tcx>, decl: &'tcx FnDecl, _: &'tcx Expr, _: Span, _: NodeId) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexityPass {
|
||||
fn check_fn(&mut self, cx: &LateContext<'a, 'tcx>, _: FnKind<'tcx>, decl: &'tcx FnDecl, _: &'tcx Expr, _: Span, _: NodeId) {
|
||||
self.check_fndecl(cx, decl);
|
||||
}
|
||||
|
||||
fn check_struct_field<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, field: &'tcx StructField) {
|
||||
fn check_struct_field(&mut self, cx: &LateContext<'a, 'tcx>, field: &'tcx StructField) {
|
||||
// enum variants are also struct fields now
|
||||
self.check_type(cx, &field.ty);
|
||||
}
|
||||
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
match item.node {
|
||||
ItemStatic(ref ty, _, _) |
|
||||
ItemConst(ref ty, _) => self.check_type(cx, ty),
|
||||
|
@ -554,7 +554,7 @@ impl LateLintPass for TypeComplexityPass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_trait_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
|
||||
match item.node {
|
||||
ConstTraitItem(ref ty, _) |
|
||||
TypeTraitItem(_, Some(ref ty)) => self.check_type(cx, ty),
|
||||
|
@ -564,7 +564,7 @@ impl LateLintPass for TypeComplexityPass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_impl_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||
match item.node {
|
||||
ImplItemKind::Const(ref ty, _) |
|
||||
ImplItemKind::Type(ref ty) => self.check_type(cx, ty),
|
||||
|
@ -573,15 +573,15 @@ impl LateLintPass for TypeComplexityPass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_local<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, local: &'tcx Local) {
|
||||
fn check_local(&mut self, cx: &LateContext<'a, 'tcx>, local: &'tcx Local) {
|
||||
if let Some(ref ty) = local.ty {
|
||||
self.check_type(cx, ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeComplexityPass {
|
||||
fn check_fndecl<'a, 'tcx: 'a>(&self, cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl) {
|
||||
impl<'a, 'tcx> TypeComplexityPass {
|
||||
fn check_fndecl(&self, cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl) {
|
||||
for arg in &decl.inputs {
|
||||
self.check_type(cx, &arg.ty);
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ impl TypeComplexityPass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_type<'a, 'tcx: 'a>(&self, cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty) {
|
||||
fn check_type(&self, cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty) {
|
||||
if in_macro(cx, ty.span) {
|
||||
return;
|
||||
}
|
||||
|
@ -682,8 +682,8 @@ impl LintPass for CharLitAsU8 {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for CharLitAsU8 {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CharLitAsU8 {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
use syntax::ast::{LitKind, UintTy};
|
||||
|
||||
if let ExprCast(ref e, _) = expr.node {
|
||||
|
@ -846,8 +846,8 @@ fn detect_extreme_expr<'a>(cx: &LateContext, expr: &'a Expr) -> Option<ExtremeEx
|
|||
})
|
||||
}
|
||||
|
||||
impl LateLintPass for AbsurdExtremeComparisons {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AbsurdExtremeComparisons {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
use types::ExtremeType::*;
|
||||
use types::AbsurdComparisonResult::*;
|
||||
|
||||
|
@ -1071,8 +1071,8 @@ fn upcast_comparison_bounds_err(cx: &LateContext, span: &Span, rel: comparisons:
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for InvalidUpcastComparisons {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidUpcastComparisons {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprBinary(ref cmp, ref lhs, ref rhs) = expr.node {
|
||||
|
||||
let normalized = comparisons::normalize_comparison(cmp.node, lhs, rhs);
|
||||
|
|
|
@ -68,8 +68,8 @@ impl LintPass for Unicode {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Unicode {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Unicode {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
if let ExprLit(ref lit) = expr.node {
|
||||
if let LitKind::Str(_, _) = lit.node {
|
||||
check_str(cx, lit.span)
|
||||
|
|
|
@ -40,8 +40,8 @@ impl LintPass for UnusedLabel {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for UnusedLabel {
|
||||
fn check_fn<'a, 'tcx: 'a>(
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedLabel {
|
||||
fn check_fn(
|
||||
&mut self,
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
kind: FnKind<'tcx>,
|
||||
|
|
|
@ -36,15 +36,15 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
|
||||
if !has_attr(&item.attrs) {
|
||||
return;
|
||||
}
|
||||
print_item(cx, item);
|
||||
}
|
||||
|
||||
fn check_impl_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem) {
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem) {
|
||||
if !has_attr(&item.attrs) {
|
||||
return;
|
||||
}
|
||||
|
@ -68,33 +68,33 @@ impl LateLintPass for Pass {
|
|||
}
|
||||
}
|
||||
/*
|
||||
fn check_trait_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
|
||||
if !has_attr(&item.attrs) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fn check_variant<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, var: &'tcx hir::Variant, _: &hir::Generics) {
|
||||
fn check_variant(&mut self, cx: &LateContext<'a, 'tcx>, var: &'tcx hir::Variant, _: &hir::Generics) {
|
||||
if !has_attr(&var.node.attrs) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fn check_struct_field<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, field: &'tcx hir::StructField) {
|
||||
fn check_struct_field(&mut self, cx: &LateContext<'a, 'tcx>, field: &'tcx hir::StructField) {
|
||||
if !has_attr(&field.attrs) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
if !has_attr(&expr.attrs) {
|
||||
return;
|
||||
}
|
||||
print_expr(cx, expr, 0);
|
||||
}
|
||||
|
||||
fn check_arm<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, arm: &'tcx hir::Arm) {
|
||||
fn check_arm(&mut self, cx: &LateContext<'a, 'tcx>, arm: &'tcx hir::Arm) {
|
||||
if !has_attr(&arm.attrs) {
|
||||
return;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ impl LateLintPass for Pass {
|
|||
print_expr(cx, &arm.body, 1);
|
||||
}
|
||||
|
||||
fn check_stmt<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx hir::Stmt) {
|
||||
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx hir::Stmt) {
|
||||
if !has_attr(stmt.node.attrs()) {
|
||||
return;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ impl LateLintPass for Pass {
|
|||
}
|
||||
/*
|
||||
|
||||
fn check_foreign_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ForeignItem) {
|
||||
fn check_foreign_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ForeignItem) {
|
||||
if !has_attr(&item.attrs) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -104,8 +104,8 @@ impl LintPass for LintWithoutLintPass {
|
|||
}
|
||||
|
||||
|
||||
impl LateLintPass for LintWithoutLintPass {
|
||||
fn check_item<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let ItemStatic(ref ty, MutImmutable, ref expr) = item.node {
|
||||
if is_lint_ref_type(ty) {
|
||||
self.declared_lints.insert(item.name, item.span);
|
||||
|
@ -116,7 +116,7 @@ impl LateLintPass for LintWithoutLintPass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_crate_post<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, _: &'tcx Crate) {
|
||||
fn check_crate_post(&mut self, cx: &LateContext<'a, 'tcx>, _: &'tcx Crate) {
|
||||
for (lint_name, &lint_span) in &self.declared_lints {
|
||||
// When using the `declare_lint!` macro, the original `lint_span`'s
|
||||
// file points to "<rustc macros>".
|
||||
|
|
|
@ -32,8 +32,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
// search for `&vec![_]` expressions where the adjusted type is `&[_]`
|
||||
if_let_chain!{[
|
||||
let ty::TypeVariants::TyRef(_, ref ty) = cx.tcx.tables().expr_ty_adjusted(expr).sty,
|
||||
|
|
|
@ -27,8 +27,8 @@ impl LintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
impl LateLintPass for Pass {
|
||||
fn check_expr<'a, 'tcx: 'a>(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
// check for instances of 0.0/0.0
|
||||
if_let_chain! {[
|
||||
let ExprBinary(ref op, ref left, ref right) = expr.node,
|
||||
|
|
Loading…
Add table
Reference in a new issue