Merge pull request #3166 from flip1995/travis_internal
Run internal lints on the Clippy code base
This commit is contained in:
commit
07cb45bc85
17 changed files with 70 additions and 68 deletions
|
|
@ -8,8 +8,8 @@ use rustc::{declare_tool_lint, lint_array};
|
|||
use rustc::hir;
|
||||
use rustc::hir::{Expr, ExprKind, QPath, TyKind, Pat, PatKind, BindingAnnotation, StmtKind, DeclKind, Stmt};
|
||||
use rustc::hir::intravisit::{NestedVisitorMap, Visitor};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use syntax::ast::{Attribute, LitKind, DUMMY_NODE_ID};
|
||||
use std::collections::HashMap;
|
||||
use crate::utils::get_attr;
|
||||
|
||||
/// **What it does:** Generates clippy code that detects the offending pattern
|
||||
|
|
@ -154,7 +154,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||
impl PrintVisitor {
|
||||
fn new(s: &'static str) -> Self {
|
||||
Self {
|
||||
ids: HashMap::new(),
|
||||
ids: FxHashMap::default(),
|
||||
current: s.to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ impl PrintVisitor {
|
|||
struct PrintVisitor {
|
||||
/// Fields are the current index that needs to be appended to pattern
|
||||
/// binding names
|
||||
ids: HashMap<&'static str, usize>,
|
||||
ids: FxHashMap<&'static str, usize>,
|
||||
/// the name that needs to be destructured
|
||||
current: String,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,11 @@ use rustc::{declare_tool_lint, lint_array};
|
|||
use rustc::hir::*;
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use crate::utils::{match_qpath, paths, span_lint, span_lint_and_sugg};
|
||||
use syntax::symbol::LocalInternedString;
|
||||
use syntax::ast::{Crate as AstCrate, Ident, ItemKind, Name};
|
||||
use syntax::source_map::Span;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
|
||||
/// **What it does:** Checks for various things we like to keep tidy in clippy.
|
||||
|
|
@ -114,12 +113,10 @@ impl EarlyLintPass for Clippy {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct LintWithoutLintPass {
|
||||
declared_lints: HashMap<Name, Span>,
|
||||
registered_lints: HashSet<Name>,
|
||||
declared_lints: FxHashMap<Name, Span>,
|
||||
registered_lints: FxHashSet<Name>,
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -129,7 +126,6 @@ impl LintPass for LintWithoutLintPass {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if let hir::ItemKind::Static(ref ty, MutImmutable, body_id) = item.node {
|
||||
|
|
@ -202,7 +198,7 @@ fn is_lint_array_type(ty: &Ty) -> bool {
|
|||
}
|
||||
|
||||
struct LintCollector<'a, 'tcx: 'a> {
|
||||
output: &'a mut HashSet<Name>,
|
||||
output: &'a mut FxHashSet<Name>,
|
||||
cx: &'a LateContext<'a, 'tcx>,
|
||||
}
|
||||
|
||||
|
|
@ -221,8 +217,6 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for LintCollector<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub struct DefaultHashTypes {
|
||||
map: FxHashMap<String, String>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ pub const IO_READ: [&str; 3] = ["std", "io", "Read"];
|
|||
pub const IO_WRITE: [&str; 3] = ["std", "io", "Write"];
|
||||
pub const ITERATOR: [&str; 4] = ["core", "iter", "iterator", "Iterator"];
|
||||
pub const LINKED_LIST: [&str; 4] = ["alloc", "collections", "linked_list", "LinkedList"];
|
||||
pub const LINT: [&str; 2] = ["lint", "Lint"];
|
||||
pub const LINT_ARRAY: [&str; 2] = ["lint", "LintArray"];
|
||||
pub const LINT: [&str; 3] = ["rustc", "lint", "Lint"];
|
||||
pub const LINT_ARRAY: [&str; 3] = ["rustc", "lint", "LintArray"];
|
||||
pub const MEM_FORGET: [&str; 3] = ["core", "mem", "forget"];
|
||||
pub const MEM_UNINIT: [&str; 3] = ["core", "mem", "uninitialized"];
|
||||
pub const MEM_ZEROED: [&str; 3] = ["core", "mem", "zeroed"];
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ use rustc::middle::expr_use_visitor::*;
|
|||
use rustc::middle::mem_categorization::cmt_;
|
||||
use rustc::middle::mem_categorization::Categorization;
|
||||
use rustc::ty;
|
||||
use std::collections::HashSet;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use syntax::ast::NodeId;
|
||||
use syntax::source_map::Span;
|
||||
|
||||
/// Returns a set of mutated local variable ids or None if mutations could not be determined.
|
||||
pub fn mutated_variables<'a, 'tcx: 'a>(expr: &'tcx Expr, cx: &'a LateContext<'a, 'tcx>) -> Option<HashSet<NodeId>> {
|
||||
pub fn mutated_variables<'a, 'tcx: 'a>(expr: &'tcx Expr, cx: &'a LateContext<'a, 'tcx>) -> Option<FxHashSet<NodeId>> {
|
||||
let mut delegate = MutVarsDelegate {
|
||||
used_mutably: HashSet::new(),
|
||||
used_mutably: FxHashSet::default(),
|
||||
skip: false,
|
||||
};
|
||||
let def_id = def_id::DefId::local(expr.hir_id.owner);
|
||||
|
|
@ -39,7 +39,7 @@ pub fn is_potentially_mutated<'a, 'tcx: 'a>(
|
|||
}
|
||||
|
||||
struct MutVarsDelegate {
|
||||
used_mutably: HashSet<NodeId>,
|
||||
used_mutably: FxHashSet<NodeId>,
|
||||
skip: bool,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue