From f3bb161f0e634f45ce1c189baaf0d3d6cc651cec Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Wed, 1 Aug 2018 22:48:41 +0200 Subject: [PATCH] Adapt codebase to the tool_lints --- clippy_lints/src/assign_ops.rs | 2 +- clippy_lints/src/booleans.rs | 6 +++--- clippy_lints/src/consts.rs | 3 +-- clippy_lints/src/cyclomatic_complexity.rs | 4 ++-- clippy_lints/src/doc.rs | 2 +- clippy_lints/src/enum_clike.rs | 2 +- clippy_lints/src/enum_variants.rs | 2 +- clippy_lints/src/eq_op.rs | 2 +- clippy_lints/src/identity_op.rs | 2 +- clippy_lints/src/int_plus_one.rs | 2 +- clippy_lints/src/lib.rs | 5 +++-- clippy_lints/src/methods.rs | 4 ++-- clippy_lints/src/neg_multiply.rs | 2 +- clippy_lints/src/types.rs | 4 ++-- clippy_lints/src/utils/author.rs | 2 +- clippy_lints/src/utils/comparisons.rs | 2 +- clippy_lints/src/utils/conf.rs | 2 +- clippy_lints/src/utils/constants.rs | 2 +- clippy_lints/src/utils/higher.rs | 2 +- clippy_lints/src/utils/hir_utils.rs | 2 +- clippy_lints/src/utils/inspector.rs | 2 +- clippy_lints/src/utils/sugg.rs | 6 ++---- src/driver.rs | 5 +++-- src/lib.rs | 3 ++- src/main.rs | 7 ++++--- 25 files changed, 39 insertions(+), 38 deletions(-) diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 5a27f6a2c36..9a1808345a5 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -108,7 +108,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { }, hir::ExprKind::Assign(ref assignee, ref e) => { if let hir::ExprKind::Binary(op, ref l, ref r) = e.node { - #[allow(cyclomatic_complexity)] + #[allow(clippy::cyclomatic_complexity)] let lint = |assignee: &hir::Expr, rhs: &hir::Expr| { let ty = cx.tables.expr_ty(assignee); let rty = cx.tables.expr_ty(rhs); diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index f867dc56c3c..3d3fa7b5e73 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -118,7 +118,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { } for (n, expr) in self.terminals.iter().enumerate() { if SpanlessEq::new(self.cx).ignore_fn().eq_expr(e, expr) { - #[allow(cast_possible_truncation)] + #[allow(clippy::cast_possible_truncation)] return Ok(Bool::Term(n as u8)); } let negated = match e.node { @@ -150,14 +150,14 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { _ => continue, }; if SpanlessEq::new(self.cx).ignore_fn().eq_expr(&negated, expr) { - #[allow(cast_possible_truncation)] + #[allow(clippy::cast_possible_truncation)] return Ok(Bool::Not(Box::new(Bool::Term(n as u8)))); } } let n = self.terminals.len(); self.terminals.push(e); if n < 32 { - #[allow(cast_possible_truncation)] + #[allow(clippy::cast_possible_truncation)] Ok(Bool::Term(n as u8)) } else { Err("too many literals".to_owned()) diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index ff189d6e893..b126215c049 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -1,5 +1,4 @@ -#![allow(cast_possible_truncation)] -#![allow(float_cmp)] +#![allow(clippy::float_cmp)] use rustc::lint::LateContext; use rustc::{span_bug, bug}; diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index 6195db7b482..c975e31cec9 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -186,7 +186,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CCHelper<'a, 'tcx> { } #[cfg(feature = "debugging")] -#[allow(too_many_arguments)] +#[allow(clippy::too_many_arguments)] fn report_cc_bug(_: &LateContext<'_, '_>, cc: u64, narms: u64, div: u64, shorts: u64, returns: u64, span: Span, _: NodeId) { span_bug!( span, @@ -200,7 +200,7 @@ fn report_cc_bug(_: &LateContext<'_, '_>, cc: u64, narms: u64, div: u64, shorts: ); } #[cfg(not(feature = "debugging"))] -#[allow(too_many_arguments)] +#[allow(clippy::too_many_arguments)] fn report_cc_bug(cx: &LateContext<'_, '_>, cc: u64, narms: u64, div: u64, shorts: u64, returns: u64, span: Span, id: NodeId) { if !is_allowed(cx, CYCLOMATIC_COMPLEXITY, id) { cx.sess().span_note_without_error( diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 2db950b3365..4d603570ebe 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -86,7 +86,7 @@ impl<'a> Iterator for Parser<'a> { /// `syntax::parse::lexer::comments::strip_doc_comment_decoration` because we /// need to keep track of /// the spans but this function is inspired from the later. -#[allow(cast_possible_truncation)] +#[allow(clippy::cast_possible_truncation)] pub fn strip_doc_comment_decoration(comment: &str, span: Span) -> (String, Vec<(usize, Span)>) { // one-line comments lose their prefix const ONELINERS: &[&str] = &["///!", "///", "//!", "//"]; diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index 3a7f884b784..0271fee8a3c 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -43,7 +43,7 @@ impl LintPass for UnportableVariant { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant { - #[allow(cast_possible_truncation, cast_sign_loss)] + #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { if cx.tcx.data_layout.pointer_size.bits() != 64 { return; diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index 85b133cbd03..56b99aa9449 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -147,7 +147,7 @@ fn partial_rmatch(post: &str, name: &str) -> usize { } // FIXME: #600 -#[allow(while_let_on_iterator)] +#[allow(clippy::while_let_on_iterator)] fn check_variant( cx: &EarlyContext<'_>, threshold: u64, diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index de1b5b77e6e..b6b34204480 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -83,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp { BinOpKind::Lt | BinOpKind::Le | BinOpKind::Ge | BinOpKind::Gt => (cx.tcx.lang_items().ord_trait(), true), }; if let Some(trait_id) = trait_id { - #[allow(match_same_arms)] + #[allow(clippy::match_same_arms)] match (&left.node, &right.node) { // do not suggest to dereference literals (&ExprKind::Lit(..), _) | (_, &ExprKind::Lit(..)) => {}, diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index bb3741088cf..052275d7a45 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp { } } -#[allow(cast_possible_wrap)] +#[allow(clippy::cast_possible_wrap)] fn check(cx: &LateContext<'_, '_>, e: &Expr, m: i8, span: Span, arg: Span) { if let Some(Constant::Int(v)) = constant_simple(cx, cx.tables, e) { let check = match cx.tables.expr_ty(e).sty { diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index b640eff2c5d..f94461b75a5 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -53,7 +53,7 @@ enum Side { } impl IntPlusOne { - #[allow(cast_sign_loss)] + #[allow(clippy::cast_sign_loss)] fn check_lit(&self, lit: &Lit, target_value: i128) -> bool { if let LitKind::Int(value, ..) = lit.node { return value == (target_value as u128); diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 32c3dca6357..f1a89c3d46b 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -5,9 +5,10 @@ #![feature(slice_patterns)] #![feature(stmt_expr_attributes)] #![feature(range_contains)] -#![allow(unknown_lints, shadow_reuse, missing_docs_in_private_items)] +#![allow(unknown_lints, clippy::shadow_reuse, clippy::missing_docs_in_private_items)] #![recursion_limit = "256"] #![feature(macro_at_most_once_rep)] +#![feature(tool_lints)] #![warn(rust_2018_idioms)] use toml; @@ -933,7 +934,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { // only exists to let the dogfood integration test works. // Don't run clippy as an executable directly -#[allow(dead_code, print_stdout)] +#[allow(dead_code, clippy::print_stdout)] fn main() { panic!("Please use the cargo-clippy executable"); } diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 4f6cb64dd4f..f428a498b4d 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -714,7 +714,7 @@ impl LintPass for Pass { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { - #[allow(cyclomatic_complexity)] + #[allow(clippy::cyclomatic_complexity)] fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { if in_macro(expr.span) { return; @@ -922,7 +922,7 @@ fn lint_or_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: Spa } /// Check for `*or(foo())`. - #[allow(too_many_arguments)] + #[allow(clippy::too_many_arguments)] fn check_general_case( cx: &LateContext<'_, '_>, name: &str, diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index 8df33b1e99a..93a83fe97ba 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -32,7 +32,7 @@ impl LintPass for NegMultiply { } } -#[allow(match_same_arms)] +#[allow(clippy::match_same_arms)] impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NegMultiply { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { if let ExprKind::Binary(Spanned { node: BinOpKind::Mul, .. }, ref l, ref r) = e.node { diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 81842421fa3..400a06c061e 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -1525,7 +1525,7 @@ enum FullInt { } impl FullInt { - #[allow(cast_sign_loss)] + #[allow(clippy::cast_sign_loss)] fn cmp_s_u(s: i128, u: u128) -> Ordering { if s < 0 { Ordering::Less @@ -1744,7 +1744,7 @@ impl LintPass for ImplicitHasher { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher { - #[allow(cast_possible_truncation)] + #[allow(clippy::cast_possible_truncation)] fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { use syntax_pos::BytePos; diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index fe8123d288d..fb131b9086a 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -1,7 +1,7 @@ //! A group of attributes that can be attached to Rust code in order //! to generate a clippy lint detecting said code automatically. -#![allow(print_stdout, use_debug)] +#![allow(clippy::print_stdout, clippy::use_debug)] use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; diff --git a/clippy_lints/src/utils/comparisons.rs b/clippy_lints/src/utils/comparisons.rs index 35f41d400ad..31e20f37e20 100644 --- a/clippy_lints/src/utils/comparisons.rs +++ b/clippy_lints/src/utils/comparisons.rs @@ -1,6 +1,6 @@ //! Utility functions about comparison operators. -#![deny(missing_docs_in_private_items)] +#![deny(clippy::missing_docs_in_private_items)] use rustc::hir::{BinOpKind, Expr}; diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index 1567bd9ffb6..47b71ae524f 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -1,6 +1,6 @@ //! Read configurations files. -#![deny(missing_docs_in_private_items)] +#![deny(clippy::missing_docs_in_private_items)] use lazy_static::lazy_static; use std::{env, fmt, fs, io, path}; diff --git a/clippy_lints/src/utils/constants.rs b/clippy_lints/src/utils/constants.rs index f59716268a0..b63be9b86c8 100644 --- a/clippy_lints/src/utils/constants.rs +++ b/clippy_lints/src/utils/constants.rs @@ -1,6 +1,6 @@ //! This module contains some useful constants. -#![deny(missing_docs_in_private_items)] +#![deny(clippy::missing_docs_in_private_items)] /// List of the built-in types names. /// diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 65d58c4e55b..42b37568a99 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -1,7 +1,7 @@ //! This module contains functions for retrieve the original AST from lowered //! `hir`. -#![deny(missing_docs_in_private_items)] +#![deny(clippy::missing_docs_in_private_items)] use if_chain::if_chain; use rustc::{hir, ty}; diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index 30c6db977f7..93d73ca707e 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -364,7 +364,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { }.hash(&mut self.s); } - #[allow(many_single_char_names)] + #[allow(clippy::many_single_char_names)] pub fn hash_expr(&mut self, e: &Expr) { if let Some(e) = constant_simple(self.cx, self.tables, e) { return e.hash(&mut self.s); diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 12b4f55e432..b9a0435eb35 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -1,4 +1,4 @@ -#![allow(print_stdout, use_debug)] +#![allow(clippy::print_stdout, clippy::use_debug)] //! checks for attributes diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index 3d587a72eec..4239b24d817 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -1,7 +1,5 @@ //! Contains utility functions to generate suggestions. -#![deny(missing_docs_in_private_items)] -// currently ignores lifetimes and generics -#![allow(use_self)] +#![deny(clippy::missing_docs_in_private_items)] use matches::matches; use rustc::hir; @@ -40,7 +38,7 @@ impl Display for Sugg<'_> { } } -#[allow(wrong_self_convention)] // ok, because of the function `as_ty` method +#[allow(clippy::wrong_self_convention)] // ok, because of the function `as_ty` method impl<'a> Sugg<'a> { /// Prepare a suggestion from an expression. pub fn hir_opt(cx: &LateContext<'_, '_>, expr: &hir::Expr) -> Option { diff --git a/src/driver.rs b/src/driver.rs index 6854ccbbddc..6885c2aed2b 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -1,13 +1,14 @@ // error-pattern:yummy #![feature(box_syntax)] #![feature(rustc_private)] -#![allow(unknown_lints, missing_docs_in_private_items)] +#![feature(tool_lints)] +#![allow(unknown_lints, clippy::missing_docs_in_private_items)] use rustc_driver::{self, driver::CompileController, Compilation}; use rustc_plugin; use std::process::{exit, Command}; -#[allow(print_stdout)] +#[allow(clippy::print_stdout)] fn show_version() { println!(env!("CARGO_PKG_VERSION")); } diff --git a/src/lib.rs b/src/lib.rs index 1525dbda4ee..a7167ac10de 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,9 @@ // error-pattern:cargo-clippy #![feature(plugin_registrar)] #![feature(rustc_private)] +#![feature(tool_lints)] #![allow(unknown_lints)] -#![allow(missing_docs_in_private_items)] +#![allow(clippy::missing_docs_in_private_items)] #![warn(rust_2018_idioms)] use rustc_plugin::Registry; diff --git a/src/main.rs b/src/main.rs index 057a585e3d7..12c07f60a11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,8 @@ // error-pattern:yummy #![feature(box_syntax)] #![feature(rustc_private)] -#![allow(unknown_lints, missing_docs_in_private_items)] +#![feature(tool_lints)] +#![allow(unknown_lints, clippy::missing_docs_in_private_items)] const CARGO_CLIPPY_HELP: &str = r#"Checks a package to catch common mistakes and improve your Rust code. @@ -28,12 +29,12 @@ it to allow or deny lints from the code, eg.: #[cfg_attr(feature = "cargo-clippy", allow(needless_lifetimes))] "#; -#[allow(print_stdout)] +#[allow(clippy::print_stdout)] fn show_help() { println!("{}", CARGO_CLIPPY_HELP); } -#[allow(print_stdout)] +#[allow(clippy::print_stdout)] fn show_version() { println!(env!("CARGO_PKG_VERSION")); }