Merge branch 'master' into issue-2879

This commit is contained in:
Daniel Wagner-Hall 2018-09-03 00:01:57 +01:00
commit 9f0216d520
536 changed files with 3895 additions and 3586 deletions

View file

@ -170,7 +170,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
// ...
reg.register_lint_group("clippy_restriction", vec![
reg.register_lint_group("clippy::restriction", vec![
// ...
else_if_without_else::ELSE_IF_WITHOUT_ELSE,
// ...
@ -185,7 +185,7 @@ It's worth noting that the majority of `clippy_lints/src/lib.rs` is autogenerate
```rust
// ./clippy_lints/src/else_if_without_else.rs
use rustc::lint::*;
use rustc::lint::{EarlyLintPass, LintArray, LintPass};
// ...

View file

@ -13,14 +13,14 @@ A collection of lints to catch common mistakes and improve your [Rust](https://g
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
* `clippy` (everything that has no false positives)
* `clippy_pedantic` (everything)
* `clippy_nursery` (new lints that aren't quite ready yet)
* `clippy_style` (code that should be written in a more idiomatic way)
* `clippy_complexity` (code that does something simple but in a complex way)
* `clippy_perf` (code that can be written in a faster way)
* `clippy_cargo` (checks against the cargo manifest)
* **`clippy_correctness`** (code that is just outright wrong or very very useless)
* `clippy::all` (everything that has no false positives)
* `clippy::pedantic` (everything)
* `clippy::nursery` (new lints that aren't quite ready yet)
* `clippy::style` (code that should be written in a more idiomatic way)
* `clippy::complexity` (code that does something simple but in a complex way)
* `clippy::perf` (code that can be written in a faster way)
* `clippy::cargo` (checks against the cargo manifest)
* **`clippy::correctness`** (code that is just outright wrong or very very useless)
More to come, please [file an issue](https://github.com/rust-lang-nursery/rust-clippy/issues) if you have ideas!
@ -106,26 +106,18 @@ define the `CLIPPY_DISABLE_DOCS_LINKS` environment variable.
You can add options to `allow`/`warn`/`deny`:
* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy)]`)
* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy::all)]`)
* all lints using both the `clippy` and `clippy_pedantic` lint groups (`#![deny(clippy)]`,
`#![deny(clippy_pedantic)]`). Note that `clippy_pedantic` contains some very aggressive
* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![deny(clippy::all)]`,
`#![deny(clippy::pedantic)]`). Note that `clippy::pedantic` contains some very aggressive
lints prone to false positives.
* only some lints (`#![deny(single_match, box_vec)]`, etc)
* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc)
* `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc
Note: `deny` produces errors instead of warnings.
For convenience, `cargo clippy` automatically defines a `cargo-clippy`
feature. This lets you set lint levels and compile with or without Clippy
transparently:
```rust
#[cfg_attr(feature = "cargo-clippy", allow(needless_lifetimes))]
```
## Updating rustc
Sometimes, rustc moves forward without Clippy catching up. Therefore updating

View file

@ -7,6 +7,7 @@ remark -f *.md > /dev/null
# build clippy in debug mode and run tests
cargo build --features debugging
cargo test --features debugging
cd clippy_lints && cargo test && cd ..
mkdir -p ~/rust/cargo/bin
cp target/debug/cargo-clippy ~/rust/cargo/bin/cargo-clippy
cp target/debug/clippy-driver ~/rust/cargo/bin/clippy-driver

View file

@ -1,7 +1,7 @@
use crate::utils::span_lint;
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use std::f64::consts as f64;
use syntax::ast::{FloatTy, Lit, LitKind};
use syntax::symbol;

View file

@ -1,7 +1,7 @@
use crate::utils::span_lint;
use rustc::hir;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::source_map::Span;
/// **What it does:** Checks for plain integer arithmetic.

View file

@ -2,8 +2,8 @@ use crate::utils::{get_trait_def_id, implements_trait, snippet_opt, span_lint_an
use crate::utils::{higher, sugg};
use rustc::hir;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use syntax::ast;
@ -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);
@ -133,7 +133,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
// the crate node is the only one that is not in the map
if_chain! {
if parent_impl != ast::CRATE_NODE_ID;
if let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl);
if let hir::Node::Item(item) = cx.tcx.hir.get(parent_impl);
if let hir::ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) =
item.node;
if trait_ref.path.def.def_id() == trait_id;

View file

@ -6,8 +6,8 @@ use crate::utils::{
without_block_comments,
};
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty::{self, TyCtxt};
use semver::Version;

View file

@ -1,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use syntax::ast::LitKind;
use syntax::source_map::Span;

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use crate::utils::span_lint;

View file

@ -1,6 +1,6 @@
use matches::matches;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint, lint_array};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use crate::utils::*;

View file

@ -1,5 +1,5 @@
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint, lint_array};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use rustc::hir::intravisit::*;
use syntax::ast::{LitKind, NodeId, DUMMY_NODE_ID};
@ -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,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty;
use syntax::ast::{Name, UintTy};

View file

@ -12,8 +12,8 @@
//!
//! This lint is **warn** by default
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use syntax::ast;

View file

@ -1,6 +1,6 @@
use syntax::ast::*;
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_lint, lint_array};
use rustc::{declare_tool_lint, lint_array};
use crate::utils::{in_macro, snippet, span_lint_and_then};
/// **What it does:** Checks for constants with an explicit `'static` lifetime.

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};
@ -16,22 +15,6 @@ use syntax::ast::{FloatTy, LitKind};
use syntax::ptr::P;
use crate::utils::{sext, unsext, clip};
#[derive(Debug, Copy, Clone)]
pub enum FloatWidth {
F32,
F64,
Any,
}
impl From<FloatTy> for FloatWidth {
fn from(ty: FloatTy) -> Self {
match ty {
FloatTy::F32 => FloatWidth::F32,
FloatTy::F64 => FloatWidth::F64,
}
}
}
/// A `LitKind`-like enum to fold constant `Expr`s into.
#[derive(Debug, Clone)]
pub enum Constant {

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::ty::Ty;
use rustc::hir::*;
use std::collections::HashMap;

View file

@ -1,7 +1,7 @@
use crate::utils::{is_copy, match_path, paths, span_note_and_lint};
use rustc::hir::{Item, ItemKind};
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
/// **What it does:** Checks for types that implement `Copy` as well as
/// `Iterator`.

View file

@ -1,8 +1,8 @@
//! calculate cyclomatic complexity and warn about overly complex functions
use rustc::cfg::CFG;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, LintContext};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use rustc::ty;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
@ -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

@ -1,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty::TyKind;

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty::{self, Ty};
use rustc::hir::*;

View file

@ -1,7 +1,7 @@
use itertools::Itertools;
use pulldown_cmark;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast;
use syntax::source_map::{BytePos, Span};
use syntax_pos::Pos;
@ -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

@ -1,8 +1,8 @@
//! Lint on unnecessary double comparisons. Some examples:
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::source_map::Span;
use crate::utils::{snippet, span_lint_and_sugg, SpanlessEq};

View file

@ -1,6 +1,6 @@
use syntax::ast::*;
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
use rustc::{declare_lint, lint_array};
use rustc::{declare_tool_lint, lint_array};
/// **What it does:** Checks for unnecessary double parentheses.
///

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty;
use rustc::hir::*;

View file

@ -1,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use syntax::source_map::Spanned;

View file

@ -1,7 +1,7 @@
//! lint on if expressions with an else if, but without a final else branch
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast::*;
use crate::utils::span_lint_and_sugg;

View file

@ -1,7 +1,7 @@
//! lint when there is an enum with no variants
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use crate::utils::span_lint_and_then;

View file

@ -1,7 +1,7 @@
use rustc::hir::*;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use syntax::source_map::Span;
use crate::utils::SpanlessEq;

View file

@ -1,8 +1,8 @@
//! lint on C-like enums that are `repr(isize/usize)` and have values that
//! don't fit into an `i32`
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use rustc::ty;
use rustc::ty::subst::Substs;
@ -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

@ -3,7 +3,7 @@
use rustc::hir::*;
use rustc::hir::def::Def;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint, lint_array};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast::NodeId;
use syntax::source_map::Span;
use crate::utils::span_lint;

View file

@ -1,7 +1,7 @@
//! lint on enum variants that are prefixed or suffixed by the same characters
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, Lint};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast::*;
use syntax::source_map::Span;
use syntax::symbol::LocalInternedString;
@ -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

@ -1,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use crate::utils::{in_macro, implements_trait, is_copy, multispan_sugg, snippet, span_lint, span_lint_and_then, SpanlessEq};
/// **What it does:** Checks for equal operands to comparison, logical and
@ -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

@ -1,7 +1,7 @@
use crate::consts::{constant_simple, Constant};
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::source_map::Span;
use crate::utils::{in_macro, span_lint};

View file

@ -1,8 +1,7 @@
use rustc::hir::*;
use rustc::hir::intravisit as visit;
use rustc::hir::map::Node::{NodeExpr, NodeStmt};
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::middle::expr_use_visitor::*;
use rustc::middle::mem_categorization::{cmt_, Categorization};
use rustc::ty::{self, Ty};
@ -100,7 +99,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
let map = &self.cx.tcx.hir;
if map.is_argument(consume_pat.id) {
// Skip closure arguments
if let Some(NodeExpr(..)) = map.find(map.get_parent_node(consume_pat.id)) {
if let Some(Node::Expr(..)) = map.find(map.get_parent_node(consume_pat.id)) {
return;
}
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
@ -110,7 +109,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
}
if let Categorization::Rvalue(..) = cmt.cat {
let id = map.hir_to_node_id(cmt.hir_id);
if let Some(NodeStmt(st)) = map.find(map.get_parent_node(id)) {
if let Some(Node::Stmt(st)) = map.find(map.get_parent_node(id)) {
if let StmtKind::Decl(ref decl, _) = st.node {
if let DeclKind::Local(ref loc) = decl.node {
if let Some(ref ex) = loc.init {

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::ty;
use rustc::hir::*;
use crate::utils::{is_adjusted, iter_input_pats, snippet_opt, span_lint_and_then};

View file

@ -1,8 +1,8 @@
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::hir::*;
use rustc::ty;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use syntax::ast;
use crate::utils::{get_parent_expr, span_lint, span_note_and_lint};
@ -109,7 +109,9 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
self.visit_expr(e);
for arm in arms {
if let Some(ref guard) = arm.guard {
self.visit_expr(guard);
match guard {
Guard::If(if_expr) => self.visit_expr(if_expr),
}
}
// make sure top level arm expressions aren't linted
self.maybe_walk_expr(&*arm.body);
@ -189,9 +191,9 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) {
};
let stop_early = match parent_node {
map::Node::NodeExpr(expr) => check_expr(vis, expr),
map::Node::NodeStmt(stmt) => check_stmt(vis, stmt),
map::Node::NodeItem(_) => {
Node::Expr(expr) => check_expr(vis, expr),
Node::Stmt(stmt) => check_stmt(vis, stmt),
Node::Item(_) => {
// We reached the top of the function, stop.
break;
},

View file

@ -1,6 +1,6 @@
use rustc::hir;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty::TyKind;
use std::f32;

View file

@ -1,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use crate::utils::{is_expn_of, match_def_path, resolve_node, span_lint};
use crate::utils::opt_def_id;

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::hir;
use rustc::ty;

View file

@ -1,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty;
use syntax::ast::LitKind;

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast;
use crate::utils::{differing_macro_contexts, in_macro, snippet_opt, span_note_and_lint};
use syntax::ptr::P;

View file

@ -1,8 +1,8 @@
use matches::matches;
use rustc::hir::intravisit;
use rustc::hir;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::ty;
use rustc::hir::def::Def;
use std::collections::HashSet;
@ -85,9 +85,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
span: Span,
nodeid: ast::NodeId,
) {
use rustc::hir::map::Node::*;
let is_impl = if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) {
let is_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) {
matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _))
} else {
false

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use syntax::ast::NodeId;
use crate::utils::{in_macro, match_def_path, match_trait_method, same_tys, snippet, span_lint_and_then};

View file

@ -1,7 +1,7 @@
use crate::consts::{constant_simple, Constant};
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::source_map::Span;
use crate::utils::{in_macro, snippet, span_lint, unsext, clip};
use rustc::ty;
@ -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

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use crate::utils::{match_qpath, paths, snippet, span_lint_and_then};

View file

@ -1,8 +1,8 @@
//! lint on if branches that could be swapped so no `!` operation is necessary
//! on the condition
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast::*;
use crate::utils::span_help_and_lint;

View file

@ -5,8 +5,8 @@ use crate::utils;
use crate::utils::higher;
use crate::utils::higher::Range;
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::ty;
use syntax::ast::RangeLimits;

View file

@ -1,7 +1,7 @@
use super::utils::{get_arg_name, match_var, remove_blocks, snippet, span_lint_and_sugg};
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
/// **What it does:** Checks for matches being used to destructure a single-variant enum

View file

@ -1,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use crate::utils::{get_trait_def_id, higher, implements_trait, match_qpath, paths, span_lint};
/// **What it does:** Checks for iteration that is guaranteed to be infinite.

View file

@ -1,11 +1,12 @@
//! lint on inherent implementations
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use std::collections::HashMap;
use std::default::Default;
use syntax_pos::Span;
use crate::utils::span_lint_and_then;
/// **What it does:** Checks for multiple inherent implementations of a struct
///
@ -81,12 +82,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
.map(|(span, _)| span);
if let Some(initial_span) = impl_spans.nth(0) {
impl_spans.for_each(|additional_span| {
cx.span_lint_note(
span_lint_and_then(
cx,
MULTIPLE_INHERENT_IMPL,
*additional_span,
"Multiple implementations of this structure",
|db| {
db.span_note(
*initial_span,
"First implementation here",
);
},
)
})
}

View file

@ -1,7 +1,7 @@
//! checks for `#[inline]` on trait methods without bodies
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use syntax::ast::{Attribute, Name};
use crate::utils::span_lint_and_then;

View file

@ -1,7 +1,7 @@
//! lint on blocks unnecessarily using >= with a + 1 or - 1
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast::*;
use crate::utils::{snippet_opt, span_lint_and_then};
@ -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

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty;
use rustc::hir::*;

View file

@ -1,8 +1,8 @@
//! lint when items are used after statements
use matches::matches;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast::*;
use crate::utils::{in_macro, span_lint};

View file

@ -1,7 +1,7 @@
//! lint when there is a large size difference between variants on an enum
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use crate::utils::{snippet_opt, span_lint_and_then};
use rustc::ty::layout::LayoutOf;

View file

@ -1,7 +1,7 @@
use rustc::hir::def_id::DefId;
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::ty;
use std::collections::HashSet;
use syntax::ast::{Lit, LitKind, Name};

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::hir;
use rustc::hir::BindingAnnotation;

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;
@ -17,40 +18,40 @@ use rustc;
macro_rules! declare_clippy_lint {
{ pub $name:tt, style, $description:tt } => {
declare_lint! { pub $name, Warn, $description, report_in_external_macro: true }
declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
};
{ pub $name:tt, correctness, $description:tt } => {
declare_lint! { pub $name, Deny, $description, report_in_external_macro: true }
declare_tool_lint! { pub clippy::$name, Deny, $description, report_in_external_macro: true }
};
{ pub $name:tt, complexity, $description:tt } => {
declare_lint! { pub $name, Warn, $description, report_in_external_macro: true }
declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
};
{ pub $name:tt, perf, $description:tt } => {
declare_lint! { pub $name, Warn, $description, report_in_external_macro: true }
declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
};
{ pub $name:tt, pedantic, $description:tt } => {
declare_lint! { pub $name, Allow, $description, report_in_external_macro: true }
declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
};
{ pub $name:tt, restriction, $description:tt } => {
declare_lint! { pub $name, Allow, $description, report_in_external_macro: true }
declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
};
{ pub $name:tt, cargo, $description:tt } => {
declare_lint! { pub $name, Allow, $description, report_in_external_macro: true }
declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
};
{ pub $name:tt, nursery, $description:tt } => {
declare_lint! { pub $name, Allow, $description, report_in_external_macro: true }
declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
};
{ pub $name:tt, internal, $description:tt } => {
declare_lint! { pub $name, Allow, $description, report_in_external_macro: true }
declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true }
};
{ pub $name:tt, internal_warn, $description:tt } => {
declare_lint! { pub $name, Warn, $description, report_in_external_macro: true }
declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true }
};
}
pub mod consts;
mod consts;
#[macro_use]
pub mod utils;
mod utils;
// begin lints modules, do not remove this comment, its used in `update_lints`
pub mod approx_const;
@ -142,6 +143,7 @@ pub mod panic_unimplemented;
pub mod partialeq_ne_impl;
pub mod precedence;
pub mod ptr;
pub mod ptr_offset_with_cast;
pub mod question_mark;
pub mod ranges;
pub mod redundant_field_names;
@ -408,8 +410,9 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
reg.register_late_lint_pass(box default_trait_access::DefaultTraitAccess);
reg.register_late_lint_pass(box indexing_slicing::IndexingSlicing);
reg.register_late_lint_pass(box non_copy_const::NonCopyConst);
reg.register_late_lint_pass(box ptr_offset_with_cast::Pass);
reg.register_lint_group("clippy_restriction", vec![
reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
arithmetic::FLOAT_ARITHMETIC,
arithmetic::INTEGER_ARITHMETIC,
else_if_without_else::ELSE_IF_WITHOUT_ELSE,
@ -432,7 +435,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
write::USE_DEBUG,
]);
reg.register_lint_group("clippy_pedantic", vec![
reg.register_lint_group("clippy::pedantic", Some("clippy_pedantic"), vec![
attrs::INLINE_ALWAYS,
copies::MATCH_SAME_ARMS,
copy_iterator::COPY_ITERATOR,
@ -470,13 +473,13 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
use_self::USE_SELF,
]);
reg.register_lint_group("clippy_internal", vec![
reg.register_lint_group("clippy::internal", Some("clippy_internal"), vec![
utils::internal_lints::CLIPPY_LINTS_INTERNAL,
utils::internal_lints::LINT_WITHOUT_LINT_PASS,
utils::internal_lints::DEFAULT_HASH_TYPES,
]);
reg.register_lint_group("clippy", vec![
reg.register_lint_group("clippy::all", Some("clippy"), vec![
approx_const::APPROX_CONSTANT,
assign_ops::ASSIGN_OP_PATTERN,
assign_ops::MISREFACTORED_ASSIGN_OP,
@ -631,6 +634,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
ptr::CMP_NULL,
ptr::MUT_FROM_REF,
ptr::PTR_ARG,
ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
question_mark::QUESTION_MARK,
ranges::ITERATOR_STEP_BY_ZERO,
ranges::RANGE_MINUS_ONE,
@ -690,7 +694,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
zero_div_zero::ZERO_DIVIDED_BY_ZERO,
]);
reg.register_lint_group("clippy_style", vec![
reg.register_lint_group("clippy::style", Some("clippy_style"), vec![
assign_ops::ASSIGN_OP_PATTERN,
bit_mask::VERBOSE_BIT_MASK,
blacklisted_name::BLACKLISTED_NAME,
@ -774,7 +778,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
write::WRITELN_EMPTY_STRING,
]);
reg.register_lint_group("clippy_complexity", vec![
reg.register_lint_group("clippy::complexity", Some("clippy_complexity"), vec![
assign_ops::MISREFACTORED_ASSIGN_OP,
booleans::NONMINIMAL_BOOL,
cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
@ -815,6 +819,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
partialeq_ne_impl::PARTIALEQ_NE_IMPL,
precedence::PRECEDENCE,
ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
ranges::RANGE_MINUS_ONE,
ranges::RANGE_PLUS_ONE,
ranges::RANGE_ZIP_WITH_LEN,
@ -841,7 +846,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
zero_div_zero::ZERO_DIVIDED_BY_ZERO,
]);
reg.register_lint_group("clippy_correctness", vec![
reg.register_lint_group("clippy::correctness", Some("clippy_correctness"), vec![
approx_const::APPROX_CONSTANT,
attrs::DEPRECATED_SEMVER,
attrs::USELESS_ATTRIBUTE,
@ -895,7 +900,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
unused_io_amount::UNUSED_IO_AMOUNT,
]);
reg.register_lint_group("clippy_perf", vec![
reg.register_lint_group("clippy::perf", Some("clippy_perf"), vec![
bytecount::NAIVE_BYTECOUNT,
entry::MAP_ENTRY,
escape::BOXED_LOCAL,
@ -913,11 +918,11 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
vec::USELESS_VEC,
]);
reg.register_lint_group("clippy_cargo", vec![
reg.register_lint_group("clippy::cargo", Some("clippy_cargo"), vec![
multiple_crate_versions::MULTIPLE_CRATE_VERSIONS,
]);
reg.register_lint_group("clippy_nursery", vec![
reg.register_lint_group("clippy::nursery", Some("clippy_nursery"), vec![
attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
fallible_impl_from::FALLIBLE_IMPL_FROM,
mutex_atomic::MUTEX_INTEGER,
@ -929,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

@ -1,7 +1,7 @@
use crate::reexport::*;
use matches::matches;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::def::Def;
use rustc::hir::*;
use rustc::hir::intravisit::*;

View file

@ -1,8 +1,8 @@
//! Lints concerned with the grouping of digits with underscores in integral or
//! floating-point literal expressions.
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use syntax::ast::*;
use syntax_pos;

View file

@ -4,9 +4,8 @@ use rustc::hir::*;
use rustc::hir::def::Def;
use rustc::hir::def_id;
use rustc::hir::intravisit::{walk_block, walk_decl, walk_expr, walk_pat, walk_stmt, NestedVisitorMap, Visitor};
use rustc::hir::map::Node::{NodeBlock, NodeExpr, NodeStmt};
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::middle::region;
// use rustc::middle::region::CodeExtent;
@ -1330,7 +1329,7 @@ fn check_for_loop_explicit_counter<'a, 'tcx>(
let parent_scope = map.get_enclosing_scope(expr.id)
.and_then(|id| map.get_enclosing_scope(id));
if let Some(parent_id) = parent_scope {
if let NodeBlock(block) = map.get(parent_id) {
if let Node::Block(block) = map.get(parent_id) {
for (id, _) in visitor
.states
.iter()
@ -1506,7 +1505,7 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<NodeId
if let Def::Local(node_id) = def {
let node_str = cx.tcx.hir.get(node_id);
if_chain! {
if let map::Node::NodeBinding(pat) = node_str;
if let Node::Binding(pat) = node_str;
if let PatKind::Binding(bind_ann, _, _, _) = pat.node;
if let BindingAnnotation::Mutable = bind_ann;
then {
@ -2047,7 +2046,7 @@ fn is_conditional(expr: &Expr) -> bool {
fn is_nested(cx: &LateContext<'_, '_>, match_expr: &Expr, iter_expr: &Expr) -> bool {
if_chain! {
if let Some(loop_block) = get_enclosing_block(cx, match_expr.id);
if let Some(map::Node::NodeExpr(loop_expr)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(loop_block.id));
if let Some(Node::Expr(loop_expr)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(loop_block.id));
then {
return is_loop_nested(cx, loop_expr, iter_expr)
}
@ -2068,13 +2067,13 @@ fn is_loop_nested(cx: &LateContext<'_, '_>, loop_expr: &Expr, iter_expr: &Expr)
return false;
}
match cx.tcx.hir.find(parent) {
Some(NodeExpr(expr)) => match expr.node {
Some(Node::Expr(expr)) => match expr.node {
ExprKind::Loop(..) | ExprKind::While(..) => {
return true;
},
_ => (),
},
Some(NodeBlock(block)) => {
Some(Node::Block(block)) => {
let mut block_visitor = LoopNestVisitor {
id,
iterator: iter_name,
@ -2085,7 +2084,7 @@ fn is_loop_nested(cx: &LateContext<'_, '_>, loop_expr: &Expr, iter_expr: &Expr)
return false;
}
},
Some(NodeStmt(_)) => (),
Some(Node::Stmt(_)) => (),
_ => {
return false;
},

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::ty;

View file

@ -1,6 +1,6 @@
use rustc::hir;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty;
use rustc_errors::Applicability;

View file

@ -1,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty::{self, Ty};
use std::cmp::Ordering;

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::{Expr, ExprKind};
use crate::utils::{match_def_path, opt_def_id, paths, span_lint};

View file

@ -1,7 +1,7 @@
use matches::matches;
use rustc::hir;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, Lint, LintContext};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty::{self, Ty};
use rustc::hir::def::Def;
@ -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,
@ -1145,14 +1145,14 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
if let ty::Ref(..) = cx.tables.expr_ty(arg).sty {
let parent = cx.tcx.hir.get_parent_node(expr.id);
match cx.tcx.hir.get(parent) {
hir::map::NodeExpr(parent) => match parent.node {
hir::Node::Expr(parent) => match parent.node {
// &*x is a nop, &x.clone() is not
hir::ExprKind::AddrOf(..) |
// (*x).func() is useless, x.clone().func() can work in case func borrows mutably
hir::ExprKind::MethodCall(..) => return,
_ => {},
}
hir::map::NodeStmt(stmt) => {
hir::Node::Stmt(stmt) => {
if let hir::StmtKind::Decl(ref decl, _) = stmt.node {
if let hir::DeclKind::Local(ref loc) = decl.node {
if let hir::PatKind::Ref(..) = loc.pat.node {

View file

@ -1,8 +1,8 @@
use crate::consts::{constant_simple, Constant};
use crate::utils::{match_def_path, opt_def_id, paths, span_lint};
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use std::cmp::Ordering;
/// **What it does:** Checks for expressions where `std::cmp::min` and `max` are

View file

@ -2,8 +2,8 @@ use crate::reexport::*;
use matches::matches;
use rustc::hir::*;
use rustc::hir::intravisit::FnKind;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty;
use syntax::source_map::{ExpnFormat, Span};
@ -522,7 +522,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
let parent_fn = cx.tcx.hir.get_parent(expr.id);
let parent_impl = cx.tcx.hir.get_parent(parent_fn);
if parent_impl != CRATE_NODE_ID {
if let map::NodeItem(item) = cx.tcx.hir.get(parent_impl) {
if let Node::Item(item) = cx.tcx.hir.get(parent_impl) {
if let ItemKind::Impl(.., Some(ref trait_ref), _, _) = item.node {
if trait_ref.path.def.def_id() == partial_eq_trait_id {
// we are implementing PartialEq, don't suggest not doing `to_owned`, otherwise

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, LintContext, in_external_macro};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use std::collections::HashMap;
use std::char;

View file

@ -19,13 +19,13 @@
//
use rustc::hir;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, LintContext};
use rustc::{declare_tool_lint, lint_array};
use rustc::ty;
use syntax::ast;
use syntax::attr;
use syntax::source_map::Span;
use crate::utils::in_macro;
use crate::utils::{span_lint, in_macro};
/// **What it does:** Warns if there is missing doc for any documentable item
/// (public or private).
@ -87,7 +87,8 @@ impl MissingDoc {
.iter()
.any(|a| a.is_value_str() && a.name() == "doc");
if !has_doc {
cx.span_lint(
span_lint(
cx,
MISSING_DOCS_IN_PRIVATE_ITEMS,
sp,
&format!("missing documentation for {}", desc),

View file

@ -10,10 +10,11 @@
//
use rustc::hir;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast;
use syntax::source_map::Span;
use crate::utils::span_lint;
/// **What it does:** it lints if an exported function, method, trait method with default impl,
/// or trait method impl is not `#[inline]`.
@ -74,7 +75,8 @@ fn check_missing_inline_attrs(cx: &LateContext<'_, '_>,
.iter()
.any(|a| a.name() == "inline" );
if !has_inline {
cx.span_lint(
span_lint(
cx,
MISSING_INLINE_IN_PUBLIC_ITEMS,
sp,
&format!("missing `#[inline]` for {}", desc),

View file

@ -1,8 +1,9 @@
//! lint on multiple versions of a crate being used
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast::*;
use crate::utils::span_lint;
use cargo_metadata;
use itertools::Itertools;
@ -43,7 +44,8 @@ impl EarlyLintPass for Pass {
let metadata = match cargo_metadata::metadata_deps(None, true) {
Ok(metadata) => metadata,
Err(_) => {
cx.span_lint(
span_lint(
cx,
MULTIPLE_CRATE_VERSIONS,
krate.span,
"could not read cargo metadata"
@ -62,7 +64,8 @@ impl EarlyLintPass for Pass {
if group.len() > 1 {
let versions = group.into_iter().map(|p| p.version).join(", ");
cx.span_lint(
span_lint(
cx,
MULTIPLE_CRATE_VERSIONS,
krate.span,
&format!("multiple versions for dependency `{}`: {}", name, versions),

View file

@ -1,7 +1,7 @@
use rustc::hir;
use rustc::hir::intravisit;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext};
use rustc::{declare_tool_lint, lint_array};
use rustc::ty;
use crate::utils::{higher, span_lint};

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::ty::{self, Ty};
use rustc::ty::subst::Subst;
use rustc::hir::*;

View file

@ -3,7 +3,7 @@
//! This lint is **warn** by default
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint, lint_array};
use rustc::{declare_tool_lint, lint_array};
use rustc::ty::{self, Ty};
use rustc::hir::Expr;
use syntax::ast;

View file

@ -2,8 +2,8 @@
//!
//! This lint is **warn** by default
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use syntax::ast::LitKind;
use syntax::source_map::Spanned;

View file

@ -2,8 +2,8 @@
//!
//! This lint is **warn** by default
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::hir::{BindingAnnotation, Expr, ExprKind, MutImmutable, Pat, PatKind};
use rustc::ty;

View file

@ -2,8 +2,8 @@
//!
//! This lint is **warn** by default
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::hir::{BindingAnnotation, MutImmutable, Pat, PatKind};
use crate::utils::{in_macro, snippet, span_lint_and_then};

View file

@ -27,8 +27,8 @@
//! ```
//!
//! This lint is **warn** by default.
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast;
use syntax::source_map::{original_sp, DUMMY_SP};
use std::borrow::Cow;

View file

@ -1,9 +1,8 @@
use matches::matches;
use rustc::hir::*;
use rustc::hir::map::*;
use rustc::hir::intravisit::FnKind;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty::{self, RegionKind, TypeFoldable};
use rustc::traits;
@ -90,7 +89,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
}
// Exclude non-inherent impls
if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) {
if let Some(Node::Item(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) {
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
ItemKind::Trait(..))
{
@ -340,7 +339,7 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> {
if let Some(node) = self.cx.tcx.hir.find(id) {
match node {
map::Node::NodeExpr(e) => {
Node::Expr(e) => {
// `match` and `if let`
if let ExprKind::Match(ref c, ..) = e.node {
self.spans_need_deref
@ -350,7 +349,7 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> {
}
},
map::Node::NodeStmt(s) => {
Node::Stmt(s) => {
// `let <pat> = x;`
if_chain! {
if let StmtKind::Decl(ref decl, _) = s.node;

View file

@ -1,5 +1,5 @@
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint, lint_array};
use rustc::{declare_tool_lint, lint_array};
use rustc::ty;
use rustc::hir::{Expr, ExprKind};
use crate::utils::span_lint;

View file

@ -1,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use crate::utils::{self, paths, span_lint};

View file

@ -1,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use syntax::source_map::{Span, Spanned};
@ -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

@ -1,7 +1,7 @@
use rustc::hir::def_id::DefId;
use rustc::hir;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty::{self, Ty};
use syntax::source_map::Span;

View file

@ -1,5 +1,5 @@
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint, lint_array};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::def::Def;
use rustc::hir::{BinOpKind, BlockCheckMode, Expr, ExprKind, Stmt, StmtKind, UnsafeSource};
use crate::utils::{has_drop, in_macro, snippet_opt, span_lint, span_lint_and_sugg};

View file

@ -3,7 +3,7 @@
//! This lint is **deny** by default.
use rustc::lint::{LateContext, LateLintPass, Lint, LintArray, LintPass};
use rustc::{declare_lint, lint_array};
use rustc::{declare_tool_lint, lint_array};
use rustc::hir::*;
use rustc::hir::def::Def;
use rustc::ty::{self, TypeFlags};
@ -212,7 +212,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {
if parent_id == cur_expr.id {
break;
}
if let Some(map::NodeExpr(parent_expr)) = cx.tcx.hir.find(parent_id) {
if let Some(Node::Expr(parent_expr)) = cx.tcx.hir.find(parent_id) {
match &parent_expr.node {
ExprKind::AddrOf(..) => {
// `&e` => `e` must be referenced

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LintArray, LintPass, EarlyContext, EarlyLintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::source_map::Span;
use syntax::symbol::LocalInternedString;
use syntax::ast::*;
@ -114,6 +114,9 @@ impl<'a, 'tcx: 'a, 'b> Visitor<'tcx> for SimilarNamesNameVisitor<'a, 'tcx, 'b> {
_ => walk_pat(self, pat),
}
}
fn visit_mac(&mut self, _mac: &Mac) {
// do not check macs
}
}
fn get_whitelist(interned_name: &str) -> Option<&'static [&'static str]> {

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::hir::*;
use crate::utils::{match_type, method_chain_args, paths, snippet, span_help_and_lint};

View file

@ -1,6 +1,6 @@
use rustc::hir::{Expr, ExprKind};
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast::LitKind;
use syntax::source_map::{Span, Spanned};
use crate::utils::{match_type, paths, span_lint, walk_ptrs_ty};

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::hir::*;
use crate::utils::{span_lint, SpanlessEq};

View file

@ -1,6 +1,6 @@
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use syntax::ast::LitKind;
use syntax::ptr::P;

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::hir::*;
use crate::utils::{is_automatically_derived, span_lint};

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast::*;
use syntax::source_map::Spanned;
use crate::utils::{in_macro, snippet, span_lint_and_sugg};

View file

@ -2,10 +2,9 @@
use std::borrow::Cow;
use rustc::hir::*;
use rustc::hir::map::NodeItem;
use rustc::hir::QPath;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::ty;
use syntax::ast::NodeId;
@ -112,7 +111,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass {
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
if let ImplItemKind::Method(ref sig, body_id) = item.node {
if let Some(NodeItem(it)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(item.id)) {
if let Some(Node::Item(it)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(item.id)) {
if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.node {
return; // ignore trait impls
}

View file

@ -0,0 +1,151 @@
use rustc::{declare_tool_lint, hir, lint, lint_array};
use crate::utils;
use std::fmt;
/// **What it does:** Checks for usage of the `offset` pointer method with a `usize` casted to an
/// `isize`.
///
/// **Why is this bad?** If were always increasing the pointer address, we can avoid the numeric
/// cast by using the `add` method instead.
///
/// **Known problems:** None
///
/// **Example:**
/// ```rust
/// let vec = vec![b'a', b'b', b'c'];
/// let ptr = vec.as_ptr();
/// let offset = 1_usize;
///
/// unsafe { ptr.offset(offset as isize); }
/// ```
///
/// Could be written:
///
/// ```rust
/// let vec = vec![b'a', b'b', b'c'];
/// let ptr = vec.as_ptr();
/// let offset = 1_usize;
///
/// unsafe { ptr.add(offset); }
/// ```
declare_clippy_lint! {
pub PTR_OFFSET_WITH_CAST,
complexity,
"uneeded pointer offset cast"
}
#[derive(Copy, Clone, Debug)]
pub struct Pass;
impl lint::LintPass for Pass {
fn get_lints(&self) -> lint::LintArray {
lint_array!(PTR_OFFSET_WITH_CAST)
}
}
impl<'a, 'tcx> lint::LateLintPass<'a, 'tcx> for Pass {
fn check_expr(&mut self, cx: &lint::LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
// Check if the expressions is a ptr.offset or ptr.wrapping_offset method call
let (receiver_expr, arg_expr, method) = match expr_as_ptr_offset_call(cx, expr) {
Some(call_arg) => call_arg,
None => return,
};
// Check if the argument to the method call is a cast from usize
let cast_lhs_expr = match expr_as_cast_from_usize(cx, arg_expr) {
Some(cast_lhs_expr) => cast_lhs_expr,
None => return,
};
let msg = format!("use of `{}` with a `usize` casted to an `isize`", method);
if let Some(sugg) = build_suggestion(cx, method, receiver_expr, cast_lhs_expr) {
utils::span_lint_and_sugg(cx, PTR_OFFSET_WITH_CAST, expr.span, &msg, "try", sugg);
} else {
utils::span_lint(cx, PTR_OFFSET_WITH_CAST, expr.span, &msg);
}
}
}
// If the given expression is a cast from a usize, return the lhs of the cast
fn expr_as_cast_from_usize<'a, 'tcx>(
cx: &lint::LateContext<'a, 'tcx>,
expr: &'tcx hir::Expr,
) -> Option<&'tcx hir::Expr> {
if let hir::ExprKind::Cast(ref cast_lhs_expr, _) = expr.node {
if is_expr_ty_usize(cx, &cast_lhs_expr) {
return Some(cast_lhs_expr);
}
}
None
}
// If the given expression is a ptr::offset or ptr::wrapping_offset method call, return the
// receiver, the arg of the method call, and the method.
fn expr_as_ptr_offset_call<'a, 'tcx>(
cx: &lint::LateContext<'a, 'tcx>,
expr: &'tcx hir::Expr,
) -> Option<(&'tcx hir::Expr, &'tcx hir::Expr, Method)> {
if let hir::ExprKind::MethodCall(ref path_segment, _, ref args) = expr.node {
if is_expr_ty_raw_ptr(cx, &args[0]) {
if path_segment.ident.name == "offset" {
return Some((&args[0], &args[1], Method::Offset));
}
if path_segment.ident.name == "wrapping_offset" {
return Some((&args[0], &args[1], Method::WrappingOffset));
}
}
}
None
}
// Is the type of the expression a usize?
fn is_expr_ty_usize<'a, 'tcx>(
cx: &lint::LateContext<'a, 'tcx>,
expr: &hir::Expr,
) -> bool {
cx.tables.expr_ty(expr) == cx.tcx.types.usize
}
// Is the type of the expression a raw pointer?
fn is_expr_ty_raw_ptr<'a, 'tcx>(
cx: &lint::LateContext<'a, 'tcx>,
expr: &hir::Expr,
) -> bool {
cx.tables.expr_ty(expr).is_unsafe_ptr()
}
fn build_suggestion<'a, 'tcx>(
cx: &lint::LateContext<'a, 'tcx>,
method: Method,
receiver_expr: &hir::Expr,
cast_lhs_expr: &hir::Expr,
) -> Option<String> {
let receiver = utils::snippet_opt(cx, receiver_expr.span)?;
let cast_lhs = utils::snippet_opt(cx, cast_lhs_expr.span)?;
Some(format!("{}.{}({})", receiver, method.suggestion(), cast_lhs))
}
#[derive(Copy, Clone)]
enum Method {
Offset,
WrappingOffset,
}
impl Method {
fn suggestion(self) -> &'static str {
match self {
Method::Offset => "add",
Method::WrappingOffset => "wrapping_add",
}
}
}
impl fmt::Display for Method {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Method::Offset => write!(f, "offset"),
Method::WrappingOffset => write!(f, "wrapping_offset"),
}
}
}

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::hir::def::Def;

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use rustc::hir::*;
use syntax::ast::RangeLimits;

View file

@ -1,5 +1,5 @@
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use syntax::ast::*;
use crate::utils::{span_lint_and_sugg};

View file

@ -1,6 +1,6 @@
use syntax::ast::{Expr, ExprKind, UnOp};
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use crate::utils::{snippet, span_lint_and_sugg};

View file

@ -1,7 +1,7 @@
use regex_syntax;
use rustc::hir::*;
use rustc::lint::*;
use rustc::{declare_lint, lint_array};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array};
use if_chain::if_chain;
use std::collections::HashSet;
use syntax::ast::{LitKind, NodeId, StrStyle};

Some files were not shown because too many files have changed in this diff Show more