Adapt codebase to the tool_lints

This commit is contained in:
flip1995 2018-08-01 22:48:41 +02:00 committed by Manish Goregaokar
parent cfd4c538d4
commit f3bb161f0e
25 changed files with 39 additions and 38 deletions

View file

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

View file

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

View file

@ -1,5 +1,4 @@
#![allow(cast_possible_truncation)]
#![allow(float_cmp)]
#![allow(clippy::float_cmp)]
use rustc::lint::LateContext;
use rustc::{span_bug, bug};

View file

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

View file

@ -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] = &["///!", "///", "//!", "//"];

View file

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

View file

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

View file

@ -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(..)) => {},

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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.
///

View file

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

View file

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

View file

@ -1,4 +1,4 @@
#![allow(print_stdout, use_debug)]
#![allow(clippy::print_stdout, clippy::use_debug)]
//! checks for attributes

View file

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

View file

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

View file

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

View file

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