mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Merge branch 'master' of github.com:rust-lang/rust-clippy
This commit is contained in:
commit
91a1cd562a
85 changed files with 116 additions and 114 deletions
3
.github/workflows/clippy_bors.yml
vendored
3
.github/workflows/clippy_bors.yml
vendored
|
@ -231,7 +231,8 @@ jobs:
|
|||
matrix:
|
||||
integration:
|
||||
- 'rust-lang/cargo'
|
||||
- 'rust-lang/rls'
|
||||
# FIXME: Re-enable once we can test with rls again.
|
||||
# - 'rust-lang/rls'
|
||||
- 'rust-lang/chalk'
|
||||
- 'rust-lang/rustfmt'
|
||||
- 'Marwes/combine'
|
||||
|
|
|
@ -13,7 +13,7 @@ pub fn create(pass: Option<&str>, lint_name: Option<&str>, category: Option<&str
|
|||
match open_files(lint_name) {
|
||||
Ok((mut test_file, mut lint_file)) => {
|
||||
let (pass_type, pass_lifetimes, pass_import, context_import) = match pass {
|
||||
"early" => ("EarlyLintPass", "", "use syntax::ast::*;", "EarlyContext"),
|
||||
"early" => ("EarlyLintPass", "", "use rustc_ast::ast::*;", "EarlyContext"),
|
||||
"late" => ("LateLintPass", "<'_, '_>", "use rustc_hir::*;", "LateContext"),
|
||||
_ => {
|
||||
unreachable!("`pass_type` should only ever be `early` or `late`!");
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::utils::span_lint;
|
||||
use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
|
||||
use rustc_hir::{Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::symbol;
|
||||
use std::f64::consts as f64;
|
||||
use syntax::ast::{FloatTy, LitFloatType, LitKind};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for floating point literals that approximate
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use rustc::lint::in_external_macro;
|
||||
use rustc_ast::ast::{Expr, ExprKind};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{Expr, ExprKind};
|
||||
|
||||
use crate::utils::span_lint_and_help;
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ use crate::consts::{constant, Constant};
|
|||
use crate::utils::paths;
|
||||
use crate::utils::{is_direct_expn_of, is_expn_of, match_function_call, snippet_opt, span_lint_and_help};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_hir::{Expr, ExprKind, PatKind, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for `assert!(true)` and `assert!(false)` calls.
|
||||
|
|
|
@ -8,6 +8,8 @@ use crate::utils::{
|
|||
use if_chain::if_chain;
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc::ty;
|
||||
use rustc_ast::ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
|
||||
use rustc_ast::util::lev_distance::find_best_match_for_name;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{
|
||||
Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitItem, TraitItemKind, TraitMethod,
|
||||
|
@ -17,8 +19,6 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
|
|||
use rustc_span::source_map::Span;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use semver::Version;
|
||||
use syntax::ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
|
||||
use syntax::util::lev_distance::find_best_match_for_name;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for items annotated with `#[inline(always)]`,
|
||||
|
|
|
@ -2,12 +2,12 @@ use crate::consts::{constant, Constant};
|
|||
use crate::utils::sugg::Sugg;
|
||||
use crate::utils::{span_lint, span_lint_and_then};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::source_map::Span;
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for incompatible bit masks in comparisons.
|
||||
|
|
|
@ -4,13 +4,13 @@ use crate::utils::{
|
|||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, HirId, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for boolean expressions that can be written more
|
||||
|
|
|
@ -4,11 +4,11 @@ use crate::utils::{
|
|||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc::ty;
|
||||
use rustc_ast::ast::{Name, UintTy};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{Name, UintTy};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for naive byte counts
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use crate::utils::span_lint;
|
||||
use rustc_ast::ast::Crate;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::DUMMY_SP;
|
||||
use syntax::ast::Crate;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks to see if all common metadata is defined in
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
use if_chain::if_chain;
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOp, BinOpKind, Expr, ExprKind, QPath, TyKind};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
use crate::utils::{snippet_with_applicability, span_lint_and_sugg, SpanlessEq};
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
//! calculate cognitive complexity and warn about overly complex functions
|
||||
|
||||
use rustc::hir::map::Map;
|
||||
use rustc_ast::ast::Attribute;
|
||||
use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::BytePos;
|
||||
use syntax::ast::Attribute;
|
||||
|
||||
use crate::utils::{match_type, paths, snippet_opt, span_lint_and_help, LimitStack};
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
//! This lint is **warn** by default
|
||||
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast;
|
||||
|
||||
use crate::utils::sugg::Sugg;
|
||||
use crate::utils::{snippet_block, snippet_block_with_applicability, span_lint_and_sugg, span_lint_and_then};
|
||||
|
|
|
@ -5,6 +5,7 @@ use if_chain::if_chain;
|
|||
use rustc::ty::subst::{Subst, SubstsRef};
|
||||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
use rustc::{bug, span_bug};
|
||||
use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::{BinOp, BinOpKind, Block, Expr, ExprKind, HirId, QPath, UnOp};
|
||||
|
@ -13,7 +14,6 @@ use rustc_span::symbol::Symbol;
|
|||
use std::cmp::Ordering::{self, Equal};
|
||||
use std::convert::TryInto;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use syntax::ast::{FloatTy, LitFloatType, LitKind};
|
||||
|
||||
/// A `LitKind`-like enum to fold constant `Expr`s into.
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::utils::{snippet_opt, span_lint_and_help, span_lint_and_sugg};
|
||||
use rustc_ast::ast;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use syntax::ast;
|
||||
use syntax::tokenstream::TokenStream;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for usage of dbg!() macro.
|
||||
|
|
|
@ -3,6 +3,7 @@ use if_chain::if_chain;
|
|||
use itertools::Itertools;
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc::ty;
|
||||
use rustc_ast::ast::{AttrKind, Attribute};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
|
@ -10,7 +11,6 @@ use rustc_session::{declare_tool_lint, impl_lint_pass};
|
|||
use rustc_span::source_map::{BytePos, MultiSpan, Span};
|
||||
use rustc_span::Pos;
|
||||
use std::ops::Range;
|
||||
use syntax::ast::{AttrKind, Attribute};
|
||||
use url::Url;
|
||||
|
||||
declare_clippy_lint! {
|
||||
|
@ -251,8 +251,8 @@ fn lint_for_missing_headers<'a, 'tcx>(
|
|||
|
||||
/// Cleanup documentation decoration (`///` and such).
|
||||
///
|
||||
/// We can't use `syntax::attr::AttributeMethods::with_desugared_doc` or
|
||||
/// `syntax::parse::lexer::comments::strip_doc_comment_decoration` because we
|
||||
/// We can't use `rustc_ast::attr::AttributeMethods::with_desugared_doc` or
|
||||
/// `rustc_ast::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(clippy::cast_possible_truncation)]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::utils::span_lint;
|
||||
use rustc_ast::ast::{Expr, ExprKind};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{Expr, ExprKind};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for unnecessary double parentheses.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//! Lint on if expressions with an else if, but without a final else branch.
|
||||
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc_ast::ast::{Expr, ExprKind};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{Expr, ExprKind};
|
||||
|
||||
use crate::utils::span_lint_and_help;
|
||||
|
||||
|
|
|
@ -5,11 +5,11 @@ use crate::consts::{miri_to_const, Constant};
|
|||
use crate::utils::span_lint;
|
||||
use rustc::ty;
|
||||
use rustc::ty::util::IntTypeExt;
|
||||
use rustc_ast::ast::{IntTy, UintTy};
|
||||
use rustc_hir::{Item, ItemKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use std::convert::TryFrom;
|
||||
use syntax::ast::{IntTy, UintTy};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for C-like enumerations that are
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
use crate::utils::{camel_case, is_present_in_source};
|
||||
use crate::utils::{span_lint, span_lint_and_help};
|
||||
use rustc_ast::ast::{EnumDef, Item, ItemKind, VisibilityKind};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, Lint};
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use syntax::ast::{EnumDef, Item, ItemKind, VisibilityKind};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Detects enumeration variants that are prefixed or suffixed
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::utils::{attr_by_name, in_macro, match_path_ast, span_lint_and_help};
|
||||
use rustc_ast::ast::{AssocItemKind, Extern, FnSig, Item, ItemKind, Ty, TyKind};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::Span;
|
||||
use syntax::ast::{AssocItemKind, Extern, FnSig, Item, ItemKind, Ty, TyKind};
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::utils::{is_expn_of, match_function_call, paths, span_lint, span_lint_and_sugg};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BorrowKind, Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for usage of `write!()` / `writeln()!` which can be
|
||||
|
|
|
@ -2,12 +2,12 @@ use crate::utils::span_lint_and_sugg;
|
|||
use crate::utils::sugg::format_numeric_literal;
|
||||
use if_chain::if_chain;
|
||||
use rustc::ty;
|
||||
use rustc_ast::ast::{FloatTy, LitFloatType, LitKind};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use std::{f32, f64, fmt};
|
||||
use syntax::ast::{FloatTy, LitFloatType, LitKind};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for float literals with a precision greater
|
||||
|
|
|
@ -11,6 +11,7 @@ use rustc_lint::{LateContext, LateLintPass};
|
|||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Spanned;
|
||||
|
||||
use rustc_ast::ast;
|
||||
use std::f32::consts as f32_consts;
|
||||
use std::f64::consts as f64_consts;
|
||||
use sugg::{format_numeric_literal, Sugg};
|
||||
|
|
|
@ -4,12 +4,12 @@ use crate::utils::{
|
|||
walk_ptrs_ty,
|
||||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Arm, BorrowKind, Expr, ExprKind, MatchSource, PatKind};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for the use of `format!("string literal with no
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::utils::{differing_macro_contexts, snippet_opt, span_lint_and_help, span_lint_and_note};
|
||||
use if_chain::if_chain;
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc_ast::ast::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use syntax::ast::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for use of the non-existent `=*`, `=!` and `=-`
|
||||
|
|
|
@ -6,6 +6,7 @@ use crate::utils::{
|
|||
use rustc::hir::map::Map;
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc_ast::ast::Attribute;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
@ -15,7 +16,6 @@ use rustc_lint::{LateContext, LateLintPass, LintContext};
|
|||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::ast::Attribute;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for functions with too many parameters.
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
use crate::utils::{is_type_diagnostic_item, snippet_with_applicability, span_lint_and_sugg, SpanlessEq};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for using `x.get(x.len() - 1)` instead of
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
//! on the condition
|
||||
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc_ast::ast::{BinOpKind, Expr, ExprKind, UnOp};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{BinOpKind, Expr, ExprKind, UnOp};
|
||||
|
||||
use crate::utils::span_lint_and_help;
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
use crate::consts::{constant, Constant};
|
||||
use crate::utils::{higher, span_lint, span_lint_and_help};
|
||||
use rustc::ty;
|
||||
use rustc_ast::ast::RangeLimits;
|
||||
use rustc_hir::{Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::RangeLimits;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for out of bounds array indexing with a constant
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
use crate::utils::span_lint_and_then;
|
||||
use crate::utils::sugg::DiagnosticBuilderExt;
|
||||
use rustc_ast::ast::{Attribute, Name};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{TraitItem, TraitItemKind, TraitMethod};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{Attribute, Name};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for `#[inline]` on trait methods without bodies
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//! lint on blocks unnecessarily using >= with a + 1 or - 1
|
||||
|
||||
use rustc_ast::ast::{BinOpKind, Expr, ExprKind, Lit, LitKind};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{BinOpKind, Expr, ExprKind, Lit, LitKind};
|
||||
|
||||
use crate::utils::{snippet_opt, span_lint_and_then};
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
use crate::utils::span_lint;
|
||||
use matches::matches;
|
||||
use rustc_ast::ast::{Block, ItemKind, StmtKind};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{Block, ItemKind, StmtKind};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for items declared after some statement in a block.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::utils::{get_item_name, snippet_with_applicability, span_lint, span_lint_and_sugg, walk_ptrs_ty};
|
||||
use rustc::ty;
|
||||
use rustc_ast::ast::{LitKind, Name};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def_id::DefId;
|
||||
|
@ -7,7 +8,6 @@ use rustc_hir::{AssocItemKind, BinOpKind, Expr, ExprKind, ImplItemRef, Item, Ite
|
|||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::{Span, Spanned};
|
||||
use syntax::ast::{LitKind, Name};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for getting the length of something via `.len()`
|
||||
|
|
|
@ -19,6 +19,8 @@ extern crate fmt_macros;
|
|||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_ast;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_ast_pretty;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_attr;
|
||||
|
@ -50,8 +52,6 @@ extern crate rustc_span;
|
|||
extern crate rustc_target;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate rustc_typeck;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate syntax;
|
||||
|
||||
use rustc::session::Session;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
|
@ -318,7 +318,7 @@ pub mod zero_div_zero;
|
|||
pub use crate::utils::conf::Conf;
|
||||
|
||||
mod reexport {
|
||||
crate use syntax::ast::Name;
|
||||
crate use rustc_ast::ast::Name;
|
||||
}
|
||||
|
||||
/// Register all pre expansion lints
|
||||
|
@ -341,7 +341,7 @@ pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, conf: &Co
|
|||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub fn read_conf(args: &[syntax::ast::NestedMetaItem], sess: &Session) -> Conf {
|
||||
pub fn read_conf(args: &[rustc_ast::ast::NestedMetaItem], sess: &Session) -> Conf {
|
||||
use std::path::Path;
|
||||
match utils::conf::file_from_args(args) {
|
||||
Ok(file_name) => {
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
use crate::utils::{in_macro, snippet_opt, span_lint_and_sugg};
|
||||
use if_chain::if_chain;
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc_ast::ast::{Expr, ExprKind, Lit, LitFloatType, LitIntType, LitKind};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
|
||||
use syntax::ast::{Expr, ExprKind, Lit, LitFloatType, LitIntType, LitKind};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Warns if a long integral or floating-point constant does
|
||||
|
|
|
@ -15,6 +15,7 @@ use rustc::hir::map::Map;
|
|||
use rustc::lint::in_external_macro;
|
||||
use rustc::middle::region;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc_ast::ast;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
|
@ -31,7 +32,6 @@ use rustc_span::{BytePos, Symbol};
|
|||
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Place, PlaceBase};
|
||||
use std::iter::{once, Iterator};
|
||||
use std::mem;
|
||||
use syntax::ast;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for for-loops that manually copy items between
|
||||
|
|
|
@ -4,12 +4,12 @@ use crate::utils::{
|
|||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc::ty;
|
||||
use rustc_ast::ast::Ident;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use syntax::ast::Ident;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for usage of `iterator.map(|x| x.clone())` and suggests
|
||||
|
|
|
@ -10,6 +10,7 @@ use crate::utils::{
|
|||
use if_chain::if_chain;
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::CtorKind;
|
||||
use rustc_hir::{
|
||||
|
@ -21,7 +22,6 @@ use rustc_session::{declare_tool_lint, impl_lint_pass};
|
|||
use rustc_span::source_map::Span;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::Bound;
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for matches with a single arm where an `if let`
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::utils::{match_qpath, snippet_with_applicability, span_lint_and_sugg};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_target::abi::LayoutOf;
|
||||
use syntax::ast;
|
||||
|
||||
pub fn lint(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, args: &[&[hir::Expr<'_>]], arith: &str) {
|
||||
let unwrap_arg = &args[0][1];
|
||||
|
|
|
@ -12,6 +12,7 @@ use matches::matches;
|
|||
use rustc::hir::map::Map;
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc::ty::{self, Predicate, Ty};
|
||||
use rustc_ast::ast;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
|
@ -19,7 +20,6 @@ use rustc_lint::{LateContext, LateLintPass, Lint, LintContext};
|
|||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::symbol::{sym, Symbol, SymbolStr};
|
||||
use syntax::ast;
|
||||
|
||||
use crate::consts::{constant, Constant};
|
||||
use crate::utils::usage::mutated_variables;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use if_chain::if_chain;
|
||||
use matches::matches;
|
||||
use rustc::ty;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_hir::{
|
||||
|
@ -10,7 +11,6 @@ use rustc_hir::{
|
|||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::{ExpnKind, Span};
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
use crate::consts::{constant, Constant};
|
||||
use crate::utils::sugg::Sugg;
|
||||
|
|
|
@ -4,16 +4,16 @@ use crate::utils::{
|
|||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc_ast::ast::{
|
||||
Block, Expr, ExprKind, GenericParamKind, Generics, Lit, LitFloatType, LitIntType, LitKind, NodeId, Pat, PatKind,
|
||||
StmtKind, UnOp,
|
||||
};
|
||||
use rustc_ast::visit::{walk_expr, FnKind, Visitor};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use syntax::ast::{
|
||||
Block, Expr, ExprKind, GenericParamKind, Generics, Lit, LitFloatType, LitIntType, LitKind, NodeId, Pat, PatKind,
|
||||
StmtKind, UnOp,
|
||||
};
|
||||
use syntax::visit::{walk_expr, FnKind, Visitor};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for structure field patterns bound to wildcards.
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
use crate::utils::span_lint;
|
||||
use if_chain::if_chain;
|
||||
use rustc::ty;
|
||||
use rustc_ast::ast::{self, MetaItem, MetaItemKind};
|
||||
use rustc_ast::attr;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::source_map::Span;
|
||||
use syntax::ast::{self, MetaItem, MetaItemKind};
|
||||
use syntax::attr;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Warns if there is missing doc for any documentable item
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::utils::span_lint;
|
||||
use rustc_ast::ast;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::{self, LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use syntax::ast;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** it lints if an exported function, method, trait method with default impl,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//! lint on multiple versions of a crate being used
|
||||
|
||||
use crate::utils::span_lint;
|
||||
use rustc_ast::ast::Crate;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::DUMMY_SP;
|
||||
use syntax::ast::Crate;
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
use crate::utils::{match_type, paths, span_lint};
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc_ast::ast;
|
||||
use rustc_hir::Expr;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for usages of `Mutex<X>` where an atomic will do.
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
use crate::utils::sugg::Sugg;
|
||||
use crate::utils::{higher, parent_node_is_if_expr, span_lint, span_lint_and_sugg};
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOpKind, Block, Expr, ExprKind, StmtKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for expressions of the form `if c { true } else {
|
||||
|
|
|
@ -33,11 +33,11 @@
|
|||
//! ```
|
||||
//!
|
||||
//! This lint is **warn** by default.
|
||||
use rustc_ast::ast;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::{original_sp, DUMMY_SP};
|
||||
use rustc_span::Span;
|
||||
use syntax::ast;
|
||||
|
||||
use crate::utils::{indent_of, snippet, snippet_block, span_lint_and_help};
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use crate::utils::{
|
|||
use if_chain::if_chain;
|
||||
use matches::matches;
|
||||
use rustc::ty::{self, TypeFoldable};
|
||||
use rustc_ast::ast::Attribute;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
|
@ -19,7 +20,6 @@ use rustc_span::{Span, Symbol};
|
|||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_typeck::expr_use_visitor as euv;
|
||||
use std::borrow::Cow;
|
||||
use syntax::ast::Attribute;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for functions taking arguments by value, but not
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use crate::utils::{span_lint, span_lint_and_then};
|
||||
use rustc_ast::ast::{
|
||||
Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Ident, Item, ItemKind, Local, Mac, Pat, PatKind,
|
||||
};
|
||||
use rustc_ast::attr;
|
||||
use rustc_ast::visit::{walk_block, walk_expr, walk_pat, Visitor};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::symbol::SymbolStr;
|
||||
use std::cmp::Ordering;
|
||||
use syntax::ast::{
|
||||
Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Ident, Item, ItemKind, Local, Mac, Pat, PatKind,
|
||||
};
|
||||
use syntax::attr;
|
||||
use syntax::visit::{walk_block, walk_expr, walk_pat, Visitor};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for names that are very similar and thus confusing.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::utils::{match_type, paths, span_lint, walk_ptrs_ty};
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_hir::{Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::{Span, Spanned};
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for duplicate open options as well as combinations
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::utils::{is_direct_expn_of, span_lint_and_help};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::{Expr, ExprKind};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{Expr, ExprKind};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for usage of `option_env!(...).unwrap()` and
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::utils::{is_direct_expn_of, is_expn_of, match_function_call, paths, span_lint};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_hir::{Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::Span;
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for missing parameters in `panic!`.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use crate::utils::{match_type, paths, span_lint_and_sugg, walk_ptrs_ty};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use std::path::{Component, Path};
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:*** Checks for [push](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.push)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::utils::{snippet_with_applicability, span_lint_and_sugg};
|
||||
use rustc_ast::ast::{BinOpKind, Expr, ExprKind, LitKind, UnOp};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use syntax::ast::{BinOpKind, Expr, ExprKind, LitKind, UnOp};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for operations where precedence may be unclear
|
||||
|
@ -123,7 +123,7 @@ fn is_arith_expr(expr: &Expr) -> bool {
|
|||
|
||||
#[must_use]
|
||||
fn is_bit_op(op: BinOpKind) -> bool {
|
||||
use syntax::ast::BinOpKind::{BitAnd, BitOr, BitXor, Shl, Shr};
|
||||
use rustc_ast::ast::BinOpKind::{BitAnd, BitOr, BitXor, Shl, Shr};
|
||||
match op {
|
||||
BitXor | BitAnd | BitOr | Shl | Shr => true,
|
||||
_ => false,
|
||||
|
@ -132,7 +132,7 @@ fn is_bit_op(op: BinOpKind) -> bool {
|
|||
|
||||
#[must_use]
|
||||
fn is_arith_op(op: BinOpKind) -> bool {
|
||||
use syntax::ast::BinOpKind::{Add, Div, Mul, Rem, Sub};
|
||||
use rustc_ast::ast::BinOpKind::{Add, Div, Mul, Rem, Sub};
|
||||
match op {
|
||||
Add | Sub | Mul | Div | Rem => true,
|
||||
_ => false,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::RangeLimits;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOpKind, Expr, ExprKind, QPath};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use syntax::ast::RangeLimits;
|
||||
|
||||
use crate::utils::sugg::Sugg;
|
||||
use crate::utils::{higher, SpanlessEq};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::utils::span_lint_and_sugg;
|
||||
use rustc_ast::ast::{Expr, ExprKind};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{Expr, ExprKind};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for fields in struct literals where shorthands
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::utils::{match_qpath, paths, snippet, span_lint_and_then};
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Arm, Expr, ExprKind, MatchSource, PatKind, QPath};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Lint for redundant pattern matching over `Result` or
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::utils::{snippet, span_lint_and_then};
|
||||
use rustc_ast::ast::{Item, ItemKind, Ty, TyKind};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{Item, ItemKind, Ty, TyKind};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for constants and statics with an explicit `'static` lifetime.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::utils::{in_macro, snippet_with_applicability, span_lint_and_sugg};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::{Expr, ExprKind, UnOp};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{Expr, ExprKind, UnOp};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for usage of `*&` and `*&mut` in expressions.
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use crate::consts::{constant, Constant};
|
||||
use crate::utils::{is_expn_of, match_def_path, match_type, paths, span_lint, span_lint_and_help};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::{LitKind, StrStyle};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir::{Block, BorrowKind, Crate, Expr, ExprKind, HirId};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::source_map::{BytePos, Span};
|
||||
use std::convert::TryFrom;
|
||||
use syntax::ast::{LitKind, StrStyle};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks [regex](https://crates.io/crates/regex) creation
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use if_chain::if_chain;
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc_ast::ast;
|
||||
use rustc_ast::visit::FnKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::BytePos;
|
||||
use syntax::ast;
|
||||
use syntax::visit::FnKind;
|
||||
|
||||
use crate::utils::{in_macro, match_path_ast, snippet_opt, span_lint_and_then};
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::utils::{in_macro, span_lint_and_sugg};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::{Item, ItemKind, UseTreeKind};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::edition::Edition;
|
||||
use syntax::ast::{Item, ItemKind, UseTreeKind};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checking for imports with single component use path.
|
||||
|
|
|
@ -2,13 +2,13 @@ use crate::utils::sugg::Sugg;
|
|||
use crate::utils::{get_enclosing_block, match_qpath, span_lint_and_then, SpanlessEq};
|
||||
use if_chain::if_chain;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::{walk_block, walk_expr, walk_stmt, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, PatKind, QPath, Stmt, StmtKind};
|
||||
use rustc_lint::{LateContext, LateLintPass, Lint};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks slow zero-filled vector initialization
|
||||
|
|
|
@ -153,7 +153,7 @@ declare_lint_pass!(StringLitAsBytes => [STRING_LIT_AS_BYTES]);
|
|||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) {
|
||||
use crate::utils::{snippet, snippet_with_applicability};
|
||||
use syntax::ast::LitKind;
|
||||
use rustc_ast::ast::LitKind;
|
||||
|
||||
if_chain! {
|
||||
if let ExprKind::MethodCall(path, _, args) = &e.kind;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::utils::span_lint_and_sugg;
|
||||
use rustc_ast::ast;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::{BytePos, Span};
|
||||
use std::convert::TryFrom;
|
||||
use syntax::ast;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks doc comments for usage of tab characters.
|
||||
|
|
|
@ -3,12 +3,12 @@ use crate::utils::{
|
|||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc::ty::{self, Ty};
|
||||
use rustc_ast::ast;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind, GenericArg, Mutability, QPath, TyKind, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use std::borrow::Cow;
|
||||
use syntax::ast;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for transmutes that can't ever be correct on any
|
||||
|
|
|
@ -2,10 +2,10 @@ use crate::consts::{constant_context, Constant};
|
|||
use crate::utils::{match_qpath, paths, span_lint};
|
||||
use if_chain::if_chain;
|
||||
use rustc::lint::in_external_macro;
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_hir::{Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::LitKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for transmute calls which would receive a null pointer.
|
||||
|
|
|
@ -9,6 +9,7 @@ use rustc::hir::map::Map;
|
|||
use rustc::lint::in_external_macro;
|
||||
use rustc::ty::layout::LayoutOf;
|
||||
use rustc::ty::{self, InferTy, Ty, TyCtxt, TypeckTables};
|
||||
use rustc_ast::ast::{FloatTy, IntTy, LitFloatType, LitIntType, LitKind, UintTy};
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{walk_body, walk_expr, walk_ty, FnKind, NestedVisitorMap, Visitor};
|
||||
|
@ -24,7 +25,6 @@ use rustc_span::source_map::Span;
|
|||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_typeck::hir_ty_to_ty;
|
||||
use syntax::ast::{FloatTy, IntTy, LitFloatType, LitIntType, LitKind, UintTy};
|
||||
|
||||
use crate::consts::{constant, Constant};
|
||||
use crate::utils::paths;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::utils::{is_allowed, snippet, span_lint_and_sugg};
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind, HirId};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use syntax::ast::LitKind;
|
||||
use unicode_normalization::UnicodeNormalization;
|
||||
|
||||
declare_clippy_lint! {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::utils::span_lint;
|
||||
use rustc_ast::ast::{Ident, Item, ItemKind, UseTree, UseTreeKind};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::symbol::SymbolStr;
|
||||
use syntax::ast::{Ident, Item, ItemKind, UseTree, UseTreeKind};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for imports that remove "unsafe" from an item's
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use rustc::session::Session;
|
||||
use rustc_ast::ast;
|
||||
use rustc_errors::Applicability;
|
||||
use std::str::FromStr;
|
||||
use syntax::ast;
|
||||
|
||||
/// Deprecation status of attributes known by Clippy.
|
||||
#[allow(dead_code)]
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
use crate::utils::{get_attr, higher};
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::session::Session;
|
||||
use rustc_ast::ast::{Attribute, LitFloatType, LitKind};
|
||||
use rustc_ast::walk_list;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::{NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, Pat, PatKind, QPath, Stmt, StmtKind, TyKind};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::{Attribute, LitFloatType, LitKind};
|
||||
use syntax::walk_list;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Generates clippy code that detects the offending pattern
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
#![deny(clippy::missing_docs_in_private_items)]
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use rustc_ast::ast::{LitKind, MetaItemKind, NestedMetaItem};
|
||||
use rustc_span::source_map;
|
||||
use source_map::Span;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Mutex;
|
||||
use std::{env, fmt, fs, io};
|
||||
use syntax::ast::{LitKind, MetaItemKind, NestedMetaItem};
|
||||
|
||||
/// Gets the configuration file from arguments.
|
||||
pub fn file_from_args(args: &[NestedMetaItem]) -> Result<Option<PathBuf>, (&'static str, Span)> {
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
use crate::utils::{is_expn_of, match_def_path, match_qpath, paths};
|
||||
use if_chain::if_chain;
|
||||
use rustc::ty;
|
||||
use rustc_ast::ast;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
use syntax::ast;
|
||||
|
||||
/// Converts a hir binary operator to the corresponding `ast` type.
|
||||
#[must_use]
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::consts::{constant_context, constant_simple};
|
|||
use crate::utils::differing_macro_contexts;
|
||||
use rustc::ich::StableHashingContextProvider;
|
||||
use rustc::ty::TypeckTables;
|
||||
use rustc_ast::ast::Name;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_hir::{
|
||||
BinOpKind, Block, BlockCheckMode, BodyId, BorrowKind, CaptureBy, Expr, ExprKind, Field, FnRetTy, GenericArg,
|
||||
|
@ -10,7 +11,6 @@ use rustc_hir::{
|
|||
};
|
||||
use rustc_lint::LateContext;
|
||||
use std::hash::Hash;
|
||||
use syntax::ast::Name;
|
||||
|
||||
/// Type used to check whether two ast are the same. This is different from the
|
||||
/// operator
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
use crate::utils::get_attr;
|
||||
use rustc::session::Session;
|
||||
use rustc_ast::ast::Attribute;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::print;
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use syntax::ast::Attribute;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Dumps every ast/hir node which has the `#[clippy::dump]`
|
||||
|
|
|
@ -4,6 +4,8 @@ use crate::utils::{
|
|||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc_ast::ast::{Crate as AstCrate, ItemKind, LitKind, Name, NodeId};
|
||||
use rustc_ast::visit::FnKind;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
@ -14,8 +16,6 @@ use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass};
|
|||
use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::source_map::{Span, Spanned};
|
||||
use rustc_span::symbol::SymbolStr;
|
||||
use syntax::ast::{Crate as AstCrate, ItemKind, LitKind, Name, NodeId};
|
||||
use syntax::visit::FnKind;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for various things we like to keep tidy in clippy.
|
||||
|
|
|
@ -33,6 +33,7 @@ use rustc::ty::{
|
|||
subst::GenericArg,
|
||||
Binder, Ty, TyCtxt,
|
||||
};
|
||||
use rustc_ast::ast::{self, Attribute, LitKind};
|
||||
use rustc_attr as attr;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
@ -52,7 +53,6 @@ use rustc_span::source_map::original_sp;
|
|||
use rustc_span::symbol::{self, kw, Symbol};
|
||||
use rustc_span::{BytePos, Pos, Span, DUMMY_SP};
|
||||
use smallvec::SmallVec;
|
||||
use syntax::ast::{self, Attribute, LitKind};
|
||||
|
||||
use crate::consts::{constant, Constant};
|
||||
use crate::reexport::Name;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use crate::utils::{get_pat_name, match_var, snippet};
|
||||
use rustc::hir::map::Map;
|
||||
use rustc_ast::ast::Name;
|
||||
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{Body, BodyId, Expr, ExprKind, Param};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::source_map::Span;
|
||||
use std::borrow::Cow;
|
||||
use syntax::ast::Name;
|
||||
|
||||
pub fn get_spans(
|
||||
cx: &LateContext<'_, '_>,
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
use crate::utils::{higher, snippet, snippet_opt, snippet_with_macro_callsite};
|
||||
use matches::matches;
|
||||
use rustc_ast::util::parser::AssocOp;
|
||||
use rustc_ast::{ast, token};
|
||||
use rustc_ast_pretty::pprust::token_kind_to_string;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
|
@ -12,8 +14,6 @@ use rustc_span::{BytePos, Pos};
|
|||
use std::borrow::Cow;
|
||||
use std::convert::TryInto;
|
||||
use std::fmt::Display;
|
||||
use syntax::util::parser::AssocOp;
|
||||
use syntax::{ast, token};
|
||||
|
||||
pub use crate::literal_representation::format_numeric_literal;
|
||||
|
||||
|
@ -132,7 +132,7 @@ impl<'a> Sugg<'a> {
|
|||
|
||||
/// Prepare a suggestion from an expression.
|
||||
pub fn ast(cx: &EarlyContext<'_>, expr: &ast::Expr, default: &'a str) -> Self {
|
||||
use syntax::ast::RangeLimits;
|
||||
use rustc_ast::ast::RangeLimits;
|
||||
|
||||
let snippet = snippet(cx, expr.span, default);
|
||||
|
||||
|
@ -426,7 +426,7 @@ enum Associativity {
|
|||
/// associative.
|
||||
#[must_use]
|
||||
fn associativity(op: &AssocOp) -> Associativity {
|
||||
use syntax::util::parser::AssocOp::{
|
||||
use rustc_ast::util::parser::AssocOp::{
|
||||
Add, As, Assign, AssignOp, BitAnd, BitOr, BitXor, Colon, Divide, DotDot, DotDotEq, Equal, Greater,
|
||||
GreaterEqual, LAnd, LOr, Less, LessEqual, Modulus, Multiply, NotEqual, ShiftLeft, ShiftRight, Subtract,
|
||||
};
|
||||
|
@ -442,7 +442,7 @@ fn associativity(op: &AssocOp) -> Associativity {
|
|||
|
||||
/// Converts a `hir::BinOp` to the corresponding assigning binary operator.
|
||||
fn hirbinop2assignop(op: hir::BinOp) -> AssocOp {
|
||||
use syntax::token::BinOpToken::{And, Caret, Minus, Or, Percent, Plus, Shl, Shr, Slash, Star};
|
||||
use rustc_ast::token::BinOpToken::{And, Caret, Minus, Or, Percent, Plus, Shl, Shr, Slash, Star};
|
||||
|
||||
AssocOp::AssignOp(match op.node {
|
||||
hir::BinOpKind::Add => Plus,
|
||||
|
@ -469,10 +469,10 @@ fn hirbinop2assignop(op: hir::BinOp) -> AssocOp {
|
|||
|
||||
/// Converts an `ast::BinOp` to the corresponding assigning binary operator.
|
||||
fn astbinop2assignop(op: ast::BinOp) -> AssocOp {
|
||||
use syntax::ast::BinOpKind::{
|
||||
use rustc_ast::ast::BinOpKind::{
|
||||
Add, And, BitAnd, BitOr, BitXor, Div, Eq, Ge, Gt, Le, Lt, Mul, Ne, Or, Rem, Shl, Shr, Sub,
|
||||
};
|
||||
use syntax::token::BinOpToken;
|
||||
use rustc_ast::token::BinOpToken;
|
||||
|
||||
AssocOp::AssignOp(match op.node {
|
||||
Add => BinOpToken::Plus,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::utils::match_var;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::ty;
|
||||
use rustc_ast::ast;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||
|
@ -9,7 +10,6 @@ use rustc_infer::infer::TyCtxtInferExt;
|
|||
use rustc_lint::LateContext;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Place, PlaceBase};
|
||||
use syntax::ast;
|
||||
|
||||
/// Returns a set of mutated local variable IDs, or `None` if mutations could not be determined.
|
||||
pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr<'_>, cx: &'a LateContext<'a, 'tcx>) -> Option<FxHashSet<HirId>> {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::utils::span_lint;
|
||||
use rustc_ast::ast::Crate;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::DUMMY_SP;
|
||||
use syntax::ast::Crate;
|
||||
|
||||
use if_chain::if_chain;
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@ use std::borrow::Cow;
|
|||
use std::ops::Range;
|
||||
|
||||
use crate::utils::{snippet_with_applicability, span_lint, span_lint_and_sugg, span_lint_and_then};
|
||||
use rustc_ast::ast::{Expr, ExprKind, Mac, StrLit, StrStyle};
|
||||
use rustc_ast::token;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lexer::unescape::{self, EscapeError};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
|
@ -9,9 +12,6 @@ use rustc_parse::parser;
|
|||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::{BytePos, Span};
|
||||
use syntax::ast::{Expr, ExprKind, Mac, StrLit, StrStyle};
|
||||
use syntax::token;
|
||||
use syntax::tokenstream::TokenStream;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** This lint warns when you use `println!("")` to
|
||||
|
@ -349,7 +349,7 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &TokenStream, is_write: bool) -> (O
|
|||
if let Piece::NextArgument(arg) = piece {
|
||||
if arg.format.ty == "?" {
|
||||
// FIXME: modify rustc's fmt string parser to give us the current span
|
||||
span_lint(cx, USE_DEBUG, parser.prev_span, "use of `Debug`-based formatting");
|
||||
span_lint(cx, USE_DEBUG, parser.prev_token.span, "use of `Debug`-based formatting");
|
||||
}
|
||||
args.push(arg);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue