Fix clippy.
This commit is contained in:
parent
01662d3a23
commit
8ab3224b3b
@ -3,12 +3,13 @@
|
||||
span_lint_and_sugg, walk_ptrs_ty,
|
||||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::{Name, UintTy};
|
||||
use rustc_ast::ast::{UintTy};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty;
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::Symbol;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for naive byte counts
|
||||
@ -95,11 +96,11 @@ fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_arg(name: Name, arg: Name, needle: &Expr<'_>) -> bool {
|
||||
fn check_arg(name: Symbol, arg: Symbol, needle: &Expr<'_>) -> bool {
|
||||
name == arg && !contains_name(name, needle)
|
||||
}
|
||||
|
||||
fn get_path_name(expr: &Expr<'_>) -> Option<Name> {
|
||||
fn get_path_name(expr: &Expr<'_>) -> Option<Symbol> {
|
||||
match expr.kind {
|
||||
ExprKind::Box(ref e) | ExprKind::AddrOf(BorrowKind::Ref, _, ref e) | ExprKind::Unary(UnOp::UnDeref, ref e) => {
|
||||
get_path_name(e)
|
||||
|
@ -2,11 +2,12 @@
|
||||
|
||||
use crate::utils::span_lint_and_then;
|
||||
use crate::utils::sugg::DiagnosticBuilderExt;
|
||||
use rustc_ast::ast::{Attribute, Name};
|
||||
use rustc_ast::ast::Attribute;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{TraitFn, TraitItem, TraitItemKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::Symbol;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for `#[inline]` on trait methods without bodies
|
||||
@ -38,7 +39,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem
|
||||
}
|
||||
}
|
||||
|
||||
fn check_attrs(cx: &LateContext<'_, '_>, name: Name, attrs: &[Attribute]) {
|
||||
fn check_attrs(cx: &LateContext<'_, '_>, name: Symbol, attrs: &[Attribute]) {
|
||||
for attr in attrs {
|
||||
if !attr.check_name(sym!(inline)) {
|
||||
continue;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::utils::{get_item_name, snippet_with_applicability, span_lint, span_lint_and_sugg, walk_ptrs_ty};
|
||||
use rustc_ast::ast::{LitKind, Name};
|
||||
use rustc_ast::ast::LitKind;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -7,7 +7,7 @@
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty;
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::{Span, Spanned};
|
||||
use rustc_span::source_map::{Span, Spanned, Symbol};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for getting the length of something via `.len()`
|
||||
@ -226,7 +226,7 @@ fn check_cmp(cx: &LateContext<'_, '_>, span: Span, method: &Expr<'_>, lit: &Expr
|
||||
fn check_len(
|
||||
cx: &LateContext<'_, '_>,
|
||||
span: Span,
|
||||
method_name: Name,
|
||||
method_name: Symbol,
|
||||
args: &[Expr<'_>],
|
||||
lit: &LitKind,
|
||||
op: &str,
|
||||
|
@ -335,7 +335,7 @@ macro_rules! declare_clippy_lint {
|
||||
pub use crate::utils::conf::Conf;
|
||||
|
||||
mod reexport {
|
||||
pub use rustc_ast::ast::Name;
|
||||
pub use rustc_span::Symbol as Name;
|
||||
}
|
||||
|
||||
/// Register all pre expansion lints
|
||||
|
@ -3,14 +3,14 @@
|
||||
is_copy, is_type_diagnostic_item, match_trait_method, remove_blocks, snippet_with_applicability, span_lint_and_sugg,
|
||||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::Ident;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::mir::Mutability;
|
||||
use rustc_middle::ty;
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::Ident;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for usage of `iterator.map(|x| x.clone())` and suggests
|
||||
|
@ -1,13 +1,13 @@
|
||||
use crate::utils::{span_lint, span_lint_and_then};
|
||||
use rustc_ast::ast::{
|
||||
Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Ident, Item, ItemKind, Local, MacCall, Pat, PatKind,
|
||||
Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Item, ItemKind, Local, MacCall, 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 rustc_span::symbol::{Ident, SymbolStr};
|
||||
use std::cmp::Ordering;
|
||||
|
||||
declare_clippy_lint! {
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::utils::span_lint;
|
||||
use rustc_ast::ast::{Ident, Item, ItemKind, UseTree, UseTreeKind};
|
||||
use rustc_ast::ast::{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 rustc_span::symbol::{Ident, SymbolStr};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for imports that remove "unsafe" from an item's
|
||||
|
@ -1,6 +1,5 @@
|
||||
use crate::consts::{constant_context, constant_simple};
|
||||
use crate::utils::differing_macro_contexts;
|
||||
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,6 +9,7 @@
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ich::StableHashingContextProvider;
|
||||
use rustc_middle::ty::TypeckTables;
|
||||
use rustc_span::Symbol;
|
||||
use std::hash::Hash;
|
||||
|
||||
/// Type used to check whether two ast are the same. This is different from the
|
||||
@ -544,7 +544,7 @@ pub fn hash_exprs(&mut self, e: &[Expr<'_>]) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hash_name(&mut self, n: Name) {
|
||||
pub fn hash_name(&mut self, n: Symbol) {
|
||||
n.as_str().hash(&mut self.s);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
span_lint_and_help, span_lint_and_sugg, walk_ptrs_ty,
|
||||
};
|
||||
use if_chain::if_chain;
|
||||
use rustc_ast::ast::{Crate as AstCrate, ItemKind, LitKind, Name, NodeId};
|
||||
use rustc_ast::ast::{Crate as AstCrate, ItemKind, LitKind, NodeId};
|
||||
use rustc_ast::visit::FnKind;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::Applicability;
|
||||
@ -17,7 +17,7 @@
|
||||
use rustc_middle::hir::map::Map;
|
||||
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 rustc_span::symbol::{Symbol, SymbolStr};
|
||||
|
||||
use std::borrow::{Borrow, Cow};
|
||||
|
||||
@ -245,8 +245,8 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &AstCrate) {
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct LintWithoutLintPass {
|
||||
declared_lints: FxHashMap<Name, Span>,
|
||||
registered_lints: FxHashSet<Name>,
|
||||
declared_lints: FxHashMap<Symbol, Span>,
|
||||
registered_lints: FxHashSet<Symbol>,
|
||||
}
|
||||
|
||||
impl_lint_pass!(LintWithoutLintPass => [DEFAULT_LINT, LINT_WITHOUT_LINT_PASS]);
|
||||
@ -357,7 +357,7 @@ fn is_lint_ref_type<'tcx>(cx: &LateContext<'_, 'tcx>, ty: &Ty<'_>) -> bool {
|
||||
}
|
||||
|
||||
struct LintCollector<'a, 'tcx> {
|
||||
output: &'a mut FxHashSet<Name>,
|
||||
output: &'a mut FxHashSet<Symbol>,
|
||||
cx: &'a LateContext<'a, 'tcx>,
|
||||
}
|
||||
|
||||
|
@ -1077,7 +1077,7 @@ pub fn is_allowed(cx: &LateContext<'_, '_>, lint: &'static Lint, id: HirId) -> b
|
||||
cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow
|
||||
}
|
||||
|
||||
pub fn get_arg_name(pat: &Pat<'_>) -> Option<ast::Name> {
|
||||
pub fn get_arg_name(pat: &Pat<'_>) -> Option<Name> {
|
||||
match pat.kind {
|
||||
PatKind::Binding(.., ident, None) => Some(ident.name),
|
||||
PatKind::Ref(ref subpat, _) => get_arg_name(subpat),
|
||||
|
@ -1,10 +1,9 @@
|
||||
use crate::utils::{get_pat_name, match_var, snippet};
|
||||
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_middle::hir::map::Map;
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use std::borrow::Cow;
|
||||
|
||||
pub fn get_spans(
|
||||
@ -25,7 +24,7 @@ pub fn get_spans(
|
||||
|
||||
fn extract_clone_suggestions<'a, 'tcx>(
|
||||
cx: &LateContext<'a, 'tcx>,
|
||||
name: Name,
|
||||
name: Symbol,
|
||||
replace: &[(&'static str, &'static str)],
|
||||
body: &'tcx Body<'_>,
|
||||
) -> Option<Vec<(Span, Cow<'static, str>)>> {
|
||||
@ -46,7 +45,7 @@ fn extract_clone_suggestions<'a, 'tcx>(
|
||||
|
||||
struct PtrCloneVisitor<'a, 'tcx> {
|
||||
cx: &'a LateContext<'a, 'tcx>,
|
||||
name: Name,
|
||||
name: Symbol,
|
||||
replace: &'a [(&'static str, &'static str)],
|
||||
spans: Vec<(Span, Cow<'static, str>)>,
|
||||
abort: bool,
|
||||
@ -83,6 +82,6 @@ fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_binding_name(arg: &Param<'_>) -> Option<Name> {
|
||||
fn get_binding_name(arg: &Param<'_>) -> Option<Symbol> {
|
||||
get_pat_name(&arg.pat)
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::utils::match_var;
|
||||
use rustc_ast::ast;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
|
||||
@ -8,7 +7,7 @@
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::hir::map::Map;
|
||||
use rustc_middle::ty;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::symbol::{Ident, Symbol};
|
||||
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Place, PlaceBase};
|
||||
|
||||
/// Returns a set of mutated local variable IDs, or `None` if mutations could not be determined.
|
||||
@ -78,7 +77,7 @@ fn mutate(&mut self, cmt: &Place<'tcx>) {
|
||||
}
|
||||
|
||||
pub struct UsedVisitor {
|
||||
pub var: ast::Name, // var to look for
|
||||
pub var: Symbol, // var to look for
|
||||
pub used: bool, // has the var been used otherwise?
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user