Rustfmt all the things

This commit is contained in:
Oliver Scherer 2019-05-14 10:06:21 +02:00
parent af80c53450
commit dfbc74b08b
57 changed files with 242 additions and 209 deletions

View File

@ -1,5 +1,6 @@
use crate::utils::span_lint;
use crate::utils::sym;
use lazy_static::lazy_static;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};
@ -7,7 +8,6 @@ use std::f64::consts as f64;
use syntax::ast::{FloatTy, LitKind};
use syntax::symbol;
use syntax::symbol::Symbol;
use lazy_static::lazy_static;
declare_clippy_lint! {
/// **What it does:** Checks for floating point literals that approximate

View File

@ -5,8 +5,8 @@ use rustc::{declare_lint_pass, declare_tool_lint};
use syntax_pos::Span;
use crate::consts::{constant, Constant};
use crate::utils::{in_macro_or_desugar, is_direct_expn_of, span_help_and_lint};
use crate::utils::sym;
use crate::utils::{in_macro_or_desugar, is_direct_expn_of, span_help_and_lint};
declare_clippy_lint! {
/// **What it does:** Checks for `assert!(true)` and `assert!(false)` calls.

View File

@ -1,11 +1,11 @@
//! checks for attributes
use crate::reexport::*;
use crate::utils::{
in_macro_or_desugar, is_present_in_source, last_line_of_span, paths, snippet_opt, span_lint, span_lint_and_sugg,
span_lint_and_then, without_block_comments, match_def_path
};
use crate::utils::sym;
use crate::utils::{
in_macro_or_desugar, is_present_in_source, last_line_of_span, match_def_path, paths, snippet_opt, span_lint,
span_lint_and_sugg, span_lint_and_then, without_block_comments,
};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::lint::{
@ -245,7 +245,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes {
for lint in lint_list {
match item.node {
ItemKind::Use(..) => {
if is_word(lint, *sym::unused_imports) || is_word(lint, *sym::deprecated) {
if is_word(lint, *sym::unused_imports)
|| is_word(lint, *sym::deprecated)
{
return;
}
},

View File

@ -1,8 +1,9 @@
use crate::utils::sym;
use crate::utils::{
get_trait_def_id, implements_trait, in_macro, in_macro_or_desugar, match_type, paths, snippet_opt,
span_lint_and_then, SpanlessEq,
};
use crate::utils::sym;
use lazy_static::lazy_static;
use rustc::hir::intravisit::*;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@ -12,7 +13,6 @@ use rustc_errors::Applicability;
use syntax::ast::LitKind;
use syntax::source_map::{dummy_spanned, Span, DUMMY_SP};
use syntax::symbol::Symbol;
use lazy_static::lazy_static;
declare_clippy_lint! {
/// **What it does:** Checks for boolean expressions that can be written more

View File

@ -1,8 +1,8 @@
use crate::utils::sym;
use crate::utils::{
contains_name, get_pat_name, match_type, paths, single_segment_path, snippet_with_applicability,
span_lint_and_sugg, walk_ptrs_ty,
};
use crate::utils::sym;
use if_chain::if_chain;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

View File

@ -1,5 +1,5 @@
use crate::utils::{snippet_opt, span_help_and_lint, span_lint_and_sugg};
use crate::utils::sym;
use crate::utils::{snippet_opt, span_help_and_lint, span_lint_and_sugg};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};
use rustc_errors::Applicability;

View File

@ -5,7 +5,7 @@ use rustc::ty;
use rustc::{declare_lint_pass, declare_tool_lint};
use rustc_errors::Applicability;
use crate::utils::{any_parent_is_automatically_derived, paths, span_lint_and_sugg, match_def_path};
use crate::utils::{any_parent_is_automatically_derived, match_def_path, paths, span_lint_and_sugg};
declare_clippy_lint! {
/// **What it does:** Checks for literal calls to `Default::default()`.

View File

@ -1,4 +1,4 @@
use crate::utils::{paths, span_lint, match_def_path};
use crate::utils::{match_def_path, paths, span_lint};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::lint::{LateLintPass, LintArray, LintPass};

View File

@ -1,4 +1,4 @@
use crate::utils::{is_copy, paths, span_note_and_lint, match_def_path};
use crate::utils::{is_copy, match_def_path, paths, span_note_and_lint};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

View File

@ -1,5 +1,5 @@
use crate::utils::SpanlessEq;
use crate::utils::sym;
use crate::utils::SpanlessEq;
use crate::utils::{get_item_name, higher, match_type, paths, snippet, span_lint_and_then, walk_ptrs_ty};
use if_chain::if_chain;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};

View File

@ -1,5 +1,5 @@
use crate::utils::{is_expn_of, resolve_node, span_lint, span_lint_and_sugg, match_def_path};
use crate::utils::sym;
use crate::utils::{is_expn_of, match_def_path, paths, resolve_node, span_lint, span_lint_and_sugg};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@ -42,11 +42,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitWrite {
if write_args.len() > 0;
if let ExprKind::Call(ref dest_fun, _) = write_args[0].node;
if let ExprKind::Path(ref qpath) = dest_fun.node;
if let Some(dest_fun_id) =
resolve_node(cx, qpath, dest_fun.hir_id).opt_def_id();
if let Some(dest_name) = if match_def_path(cx, dest_fun_id, &[*sym::std, *sym::io, *sym::stdio, *sym::stdout]) {
if let Some(dest_fun_id) = resolve_node(cx, qpath, dest_fun.hir_id).opt_def_id();
if let Some(dest_name) = if match_def_path(cx, dest_fun_id, &*paths::STDOUT) {
Some("stdout")
} else if match_def_path(cx, dest_fun_id, &[*sym::std, *sym::io, *sym::stdio, *sym::stderr]) {
} else if match_def_path(cx, dest_fun_id, &*paths::STDERR) {
Some("stderr")
} else {
None

View File

@ -1,13 +1,13 @@
use crate::utils::paths::{BEGIN_PANIC, BEGIN_PANIC_FMT, FROM_TRAIT, OPTION, RESULT};
use crate::utils::{is_expn_of, method_chain_args, span_lint_and_then, walk_ptrs_ty, match_def_path};
use crate::utils::sym;
use crate::utils::{is_expn_of, match_def_path, method_chain_args, span_lint_and_then, walk_ptrs_ty};
use if_chain::if_chain;
use rustc::hir;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::ty::{self, Ty};
use rustc::{declare_lint_pass, declare_tool_lint};
use syntax_pos::Span;
use syntax::symbol::Symbol;
use syntax_pos::Span;
declare_clippy_lint! {
/// **What it does:** Checks for impls of `From<..>` that contain `panic!()` or `unwrap()`

View File

@ -1,8 +1,8 @@
use crate::utils::paths;
use crate::utils::sym;
use crate::utils::{
in_macro_or_desugar, is_expn_of, last_path_segment, match_type, resolve_node, snippet, span_lint_and_then,
walk_ptrs_ty, match_def_path,
in_macro_or_desugar, is_expn_of, last_path_segment, match_def_path, match_type, resolve_node, snippet,
span_lint_and_then, walk_ptrs_ty,
};
use if_chain::if_chain;
use rustc::hir::*;

View File

@ -1,6 +1,6 @@
use crate::utils::{
in_macro_or_desugar, match_trait_method, same_tys, snippet, snippet_with_macro_callsite, span_lint_and_then,
match_def_path,
in_macro_or_desugar, match_def_path, match_trait_method, same_tys, snippet, snippet_with_macro_callsite,
span_lint_and_then,
};
use crate::utils::{paths, resolve_node};
use rustc::hir::*;

View File

@ -1,5 +1,5 @@
use crate::utils::{in_macro_or_desugar, is_expn_of, snippet_opt, span_lint_and_then};
use crate::utils::sym;
use crate::utils::{in_macro_or_desugar, is_expn_of, snippet_opt, span_lint_and_then};
use rustc::hir::{intravisit::FnKind, Body, ExprKind, FnDecl, HirId, MatchSource};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};

View File

@ -2,10 +2,10 @@ use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};
use crate::utils::{get_trait_def_id, higher, implements_trait, match_qpath, match_type, paths, span_lint};
use crate::utils::sym;
use syntax::symbol::Symbol;
use crate::utils::{get_trait_def_id, higher, implements_trait, match_qpath, match_type, paths, span_lint};
use lazy_static::lazy_static;
use syntax::symbol::Symbol;
declare_clippy_lint! {
/// **What it does:** Checks for iteration that is guaranteed to be infinite.

View File

@ -1,4 +1,4 @@
use crate::utils::{paths, span_help_and_lint, match_def_path};
use crate::utils::{match_def_path, paths, span_help_and_lint};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

View File

@ -1,7 +1,7 @@
use crate::utils::sym;
use crate::utils::{
get_item_name, in_macro_or_desugar, snippet_with_applicability, span_lint, span_lint_and_sugg, walk_ptrs_ty,
};
use crate::utils::sym;
use rustc::hir::def_id::DefId;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@ -141,7 +141,8 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item, trait_items
}
}
if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, *sym::len)) {
if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, *sym::len))
{
let mut current_and_super_traits = FxHashSet::default();
let visited_trait_def_id = cx.tcx.hir().local_def_id_from_hir_id(visited_trait.hir_id);
fill_trait_set(visited_trait_def_id, &mut current_and_super_traits, cx);

View File

@ -476,7 +476,9 @@ struct BodyLifetimeChecker {
impl<'tcx> Visitor<'tcx> for BodyLifetimeChecker {
// for lifetimes as parameters of generics
fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
if lifetime.name.ident().name != keywords::Invalid.name() && lifetime.name.ident().name != syntax::symbol::keywords::StaticLifetime.name() {
if lifetime.name.ident().name != keywords::Invalid.name()
&& lifetime.name.ident().name != syntax::symbol::keywords::StaticLifetime.name()
{
self.lifetimes_used_in_body = true;
}
}

View File

@ -10,9 +10,9 @@ use rustc::middle::region;
use rustc::{declare_lint_pass, declare_tool_lint};
// use rustc::middle::region::CodeExtent;
use crate::consts::{constant, Constant};
use crate::utils::sym;
use crate::utils::usage::mutated_variables;
use crate::utils::{in_macro_or_desugar, sext, sugg};
use crate::utils::sym;
use rustc::middle::expr_use_visitor::*;
use rustc::middle::mem_categorization::cmt_;
use rustc::middle::mem_categorization::Categorization;
@ -594,7 +594,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Loops {
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
if let StmtKind::Semi(ref expr) = stmt.node {
if let ExprKind::MethodCall(ref method, _, ref args) = expr.node {
if args.len() == 1 && method.ident.name == *sym::collect && match_trait_method(cx, expr, &*paths::ITERATOR) {
if args.len() == 1
&& method.ident.name == *sym::collect
&& match_trait_method(cx, expr, &*paths::ITERATOR)
{
span_lint(
cx,
UNUSED_COLLECT,

View File

@ -1,7 +1,7 @@
use crate::consts::{constant, Constant};
use crate::utils::paths;
use crate::utils::sym;
use crate::utils::sugg::Sugg;
use crate::utils::sym;
use crate::utils::{
expr_block, in_macro_or_desugar, is_allowed, is_expn_of, match_qpath, match_type, multispan_sugg, remove_blocks,
snippet, snippet_with_applicability, span_lint_and_sugg, span_lint_and_then, span_note_and_lint, walk_ptrs_ty,

View File

@ -1,4 +1,4 @@
use crate::utils::{paths, snippet, span_lint_and_then, walk_ptrs_ty_depth, match_def_path};
use crate::utils::{match_def_path, paths, snippet, span_lint_and_then, walk_ptrs_ty_depth};
use if_chain::if_chain;
use rustc::hir::{Expr, ExprKind};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

View File

@ -1,4 +1,4 @@
use crate::utils::{paths, span_lint, match_def_path};
use crate::utils::{match_def_path, paths, span_lint};
use rustc::hir::{Expr, ExprKind};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};

View File

@ -1,4 +1,4 @@
use crate::utils::{match_qpath, paths, snippet_with_applicability, span_lint_and_sugg, match_def_path};
use crate::utils::{match_def_path, match_qpath, paths, snippet_with_applicability, span_lint_and_sugg};
use if_chain::if_chain;
use rustc::hir::{Expr, ExprKind, MutMutable, QPath};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

View File

@ -6,6 +6,7 @@ use std::fmt;
use std::iter;
use if_chain::if_chain;
use lazy_static::lazy_static;
use matches::matches;
use rustc::hir;
use rustc::hir::def::{DefKind, Res};
@ -16,18 +17,16 @@ use rustc_errors::Applicability;
use syntax::ast;
use syntax::source_map::{BytePos, Span};
use syntax::symbol::{LocalInternedString, Symbol};
use lazy_static::lazy_static;
use crate::utils::paths;
use crate::utils::sugg;
use crate::utils::sym;
use crate::utils::{
get_arg_name, get_parent_expr, get_trait_def_id, has_iter_method, implements_trait, in_macro, is_copy,
is_ctor_function, is_expn_of, is_self, is_self_ty, iter_input_pats, last_path_segment, match_path, match_qpath,
match_trait_method, match_type, match_var, method_calls, method_chain_args, remove_blocks, return_ty, same_tys,
single_segment_path, snippet, snippet_with_applicability, snippet_with_macro_callsite, span_lint,
is_ctor_function, is_expn_of, is_self, is_self_ty, iter_input_pats, last_path_segment, match_def_path, match_path,
match_qpath, match_trait_method, match_type, match_var, method_calls, method_chain_args, remove_blocks, return_ty,
same_tys, single_segment_path, snippet, snippet_with_applicability, snippet_with_macro_callsite, span_lint,
span_lint_and_sugg, span_lint_and_then, span_note_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth, SpanlessEq,
match_def_path,
};
declare_clippy_lint! {
@ -1068,7 +1067,8 @@ fn lint_or_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: Spa
if ["default", "new"].contains(&path) {
let arg_ty = cx.tables.expr_ty(arg);
let default_trait_id = if let Some(default_trait_id) = get_trait_def_id(cx, &*paths::DEFAULT_TRAIT) {
let default_trait_id = if let Some(default_trait_id) = get_trait_def_id(cx, &*paths::DEFAULT_TRAIT)
{
default_trait_id
} else {
return false;
@ -2216,15 +2216,33 @@ fn lint_chars_cmp_with_unwrap<'a, 'tcx>(
/// Checks for the `CHARS_NEXT_CMP` lint with `unwrap()`.
fn lint_chars_next_cmp_with_unwrap<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, info: &BinaryExprInfo<'_>) -> bool {
lint_chars_cmp_with_unwrap(cx, info, &[*sym::chars, *sym::next, *sym::unwrap], CHARS_NEXT_CMP, "starts_with")
lint_chars_cmp_with_unwrap(
cx,
info,
&[*sym::chars, *sym::next, *sym::unwrap],
CHARS_NEXT_CMP,
"starts_with",
)
}
/// Checks for the `CHARS_LAST_CMP` lint with `unwrap()`.
fn lint_chars_last_cmp_with_unwrap<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, info: &BinaryExprInfo<'_>) -> bool {
if lint_chars_cmp_with_unwrap(cx, info, &[*sym::chars, *sym::last, *sym::unwrap], CHARS_LAST_CMP, "ends_with") {
if lint_chars_cmp_with_unwrap(
cx,
info,
&[*sym::chars, *sym::last, *sym::unwrap],
CHARS_LAST_CMP,
"ends_with",
) {
true
} else {
lint_chars_cmp_with_unwrap(cx, info, &[*sym::chars, *sym::next_back, *sym::unwrap], CHARS_LAST_CMP, "ends_with")
lint_chars_cmp_with_unwrap(
cx,
info,
&[*sym::chars, *sym::next_back, *sym::unwrap],
CHARS_LAST_CMP,
"ends_with",
)
}
}
@ -2288,10 +2306,7 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr, call_name: &str, as_re
}
}
fn ty_has_iter_method(
cx: &LateContext<'_, '_>,
self_ref_ty: Ty<'_>,
) -> Option<(&'static Lint, Symbol, &'static str)> {
fn ty_has_iter_method(cx: &LateContext<'_, '_>, self_ref_ty: Ty<'_>) -> Option<(&'static Lint, Symbol, &'static str)> {
if let Some(ty_name) = has_iter_method(cx, self_ref_ty) {
let lint = if ty_name == *sym::array || ty_name == *sym::PathBuf {
INTO_ITER_ON_ARRAY

View File

@ -1,5 +1,5 @@
use crate::consts::{constant_simple, Constant};
use crate::utils::{paths, span_lint, match_def_path};
use crate::utils::{match_def_path, paths, span_lint};
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};

View File

@ -505,7 +505,8 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
},
ExprKind::Call(ref path, ref v) if v.len() == 1 => {
if let ExprKind::Path(ref path) = path.node {
if match_qpath(path, &[*sym::String, *sym::from_str]) || match_qpath(path, &[*sym::String, *sym::from]) {
if match_qpath(path, &[*sym::String, *sym::from_str]) || match_qpath(path, &[*sym::String, *sym::from])
{
(cx.tables.expr_ty_adjusted(&v[0]), snippet(cx, v[0].span, ".."))
} else {
return;

View File

@ -5,8 +5,8 @@
// [`missing_doc`]: https://github.com/rust-lang/rust/blob/d6d05904697d89099b55da3331155392f1db9c00/src/librustc_lint/builtin.rs#L246
//
use crate::utils::{in_macro_or_desugar, span_lint};
use crate::utils::sym;
use crate::utils::{in_macro_or_desugar, span_lint};
use if_chain::if_chain;
use rustc::hir;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};

View File

@ -2,8 +2,8 @@
//!
//! This lint is **warn** by default
use crate::utils::{in_macro_or_desugar, snippet_opt, span_lint_and_then};
use crate::utils::sym;
use crate::utils::{in_macro_or_desugar, snippet_opt, span_lint_and_then};
use if_chain::if_chain;
use rustc::hir::{BindingAnnotation, Expr, ExprKind, HirId, Item, MutImmutable, Pat, PatKind};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

View File

@ -1,6 +1,6 @@
use crate::utils::paths;
use crate::utils::sym;
use crate::utils::sugg::DiagnosticBuilderExt;
use crate::utils::sym;
use crate::utils::{get_trait_def_id, implements_trait, return_ty, same_tys, span_lint_hir_and_then};
use if_chain::if_chain;
use rustc::hir;

View File

@ -1,5 +1,5 @@
use crate::utils::{span_lint, span_lint_and_then};
use crate::utils::sym;
use crate::utils::{span_lint, span_lint_and_then};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, impl_lint_pass};
use syntax::ast::*;

View File

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

View File

@ -1,5 +1,5 @@
use crate::utils::{match_type, paths, span_lint, walk_ptrs_ty};
use crate::utils::sym;
use crate::utils::{match_type, paths, span_lint, walk_ptrs_ty};
use rustc::hir::{Expr, ExprKind};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};

View File

@ -1,5 +1,5 @@
use crate::utils::{is_direct_expn_of, is_expn_of, paths, resolve_node, span_lint, match_def_path};
use crate::utils::sym;
use crate::utils::{is_direct_expn_of, is_expn_of, match_def_path, paths, resolve_node, span_lint};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

View File

@ -1,5 +1,5 @@
use crate::utils::{is_automatically_derived, span_lint_hir};
use crate::utils::sym;
use crate::utils::{is_automatically_derived, span_lint_hir};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

View File

@ -1,5 +1,5 @@
use crate::utils::{match_type, paths, span_lint_and_sugg, walk_ptrs_ty};
use crate::utils::sym;
use crate::utils::{match_type, paths, span_lint_and_sugg, walk_ptrs_ty};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

View File

@ -194,7 +194,12 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: HirId, opt_body_id:
);
}
} else if match_type(cx, ty, &*paths::STRING) {
if let Some(spans) = get_spans(cx, opt_body_id, idx, &[(*sym::clone, ".to_string()"), (*sym::as_str, "")]) {
if let Some(spans) = get_spans(
cx,
opt_body_id,
idx,
&[(*sym::clone, ".to_string()"), (*sym::as_str, "")],
) {
span_lint_and_then(
cx,
PTR_ARG,

View File

@ -7,9 +7,9 @@ use rustc_errors::Applicability;
use syntax::ptr::P;
use crate::utils::paths::*;
use crate::utils::sym;
use crate::utils::sugg::Sugg;
use crate::utils::{higher, match_type, span_lint_and_then, SpanlessEq, match_def_path};
use crate::utils::sym;
use crate::utils::{higher, match_def_path, match_type, span_lint_and_then, SpanlessEq};
declare_clippy_lint! {
/// **What it does:** Checks for expressions that could be replaced by the question mark operator.

View File

@ -213,7 +213,8 @@ fn has_step_by(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
// can't be called on a borrowed range.
let ty = cx.tables.expr_ty_adjusted(expr);
get_trait_def_id(cx, &*paths::ITERATOR).map_or(false, |iterator_trait| implements_trait(cx, ty, iterator_trait, &[]))
get_trait_def_id(cx, &*paths::ITERATOR)
.map_or(false, |iterator_trait| implements_trait(cx, ty, iterator_trait, &[]))
}
fn y_plus_one(expr: &Expr) -> Option<&Expr> {

View File

@ -1,6 +1,6 @@
use crate::utils::{
has_drop, in_macro_or_desugar, is_copy, match_type, paths, snippet_opt, span_lint_hir, span_lint_hir_and_then,
walk_ptrs_ty_depth, match_def_path,
has_drop, in_macro_or_desugar, is_copy, match_def_path, match_type, paths, snippet_opt, span_lint_hir,
span_lint_hir_and_then, walk_ptrs_ty_depth,
};
use if_chain::if_chain;
use matches::matches;
@ -96,7 +96,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
let from_borrow = match_def_path(cx, fn_def_id, &*paths::CLONE_TRAIT_METHOD)
|| match_def_path(cx, fn_def_id, &*paths::TO_OWNED_METHOD)
|| (match_def_path(cx, fn_def_id, &*paths::TO_STRING_METHOD) && match_type(cx, arg_ty, &*paths::STRING));
|| (match_def_path(cx, fn_def_id, &*paths::TO_STRING_METHOD)
&& match_type(cx, arg_ty, &*paths::STRING));
let from_deref = !from_borrow
&& (match_def_path(cx, fn_def_id, &*paths::PATH_TO_PATH_BUF)

View File

@ -1,6 +1,6 @@
use crate::consts::{constant, Constant};
use crate::utils::{is_expn_of, match_type, paths, span_help_and_lint, span_lint, match_def_path};
use crate::utils::sym;
use crate::utils::{is_expn_of, match_def_path, match_type, paths, span_help_and_lint, span_lint};
use if_chain::if_chain;
use regex_syntax;
use rustc::hir::*;

View File

@ -1,13 +1,13 @@
use crate::utils::{span_lint_and_sugg, match_def_path};
use crate::utils::sym;
use crate::utils::{match_def_path, span_lint_and_sugg};
use if_chain::if_chain;
use lazy_static::lazy_static;
use rustc::hir;
use rustc::hir::def::{DefKind, Res};
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};
use rustc_errors::Applicability;
use syntax::symbol::Symbol;
use lazy_static::lazy_static;
declare_clippy_lint! {
/// **What it does:** Checks for usage of `ATOMIC_X_INIT`, `ONCE_INIT`, and

View File

@ -7,8 +7,8 @@ use syntax::source_map::Span;
use syntax::visit::FnKind;
use syntax_pos::BytePos;
use crate::utils::{in_macro_or_desugar, match_path_ast, snippet_opt, span_lint_and_then, span_note_and_lint};
use crate::utils::sym;
use crate::utils::{in_macro_or_desugar, match_path_ast, snippet_opt, span_lint_and_then, span_note_and_lint};
declare_clippy_lint! {
/// **What it does:** Checks for return statements at the end of a block.

View File

@ -1,6 +1,6 @@
use crate::utils::sugg::Sugg;
use crate::utils::{get_enclosing_block, match_qpath, span_lint_and_then, SpanlessEq};
use crate::utils::sym;
use crate::utils::{get_enclosing_block, match_qpath, span_lint_and_then, SpanlessEq};
use if_chain::if_chain;
use rustc::hir::intravisit::{walk_block, walk_expr, walk_stmt, NestedVisitorMap, Visitor};
use rustc::hir::*;

View File

@ -4,8 +4,8 @@ use rustc::{declare_lint_pass, declare_tool_lint};
use rustc_errors::Applicability;
use syntax::source_map::Spanned;
use crate::utils::SpanlessEq;
use crate::utils::sym;
use crate::utils::SpanlessEq;
use crate::utils::{get_parent_expr, is_allowed, match_type, paths, span_lint, span_lint_and_sugg, walk_ptrs_ty};
declare_clippy_lint! {

View File

@ -1,5 +1,5 @@
use crate::utils::{get_trait_def_id, span_lint, trait_ref_of_method};
use crate::utils::sym;
use crate::utils::{get_trait_def_id, span_lint, trait_ref_of_method};
use if_chain::if_chain;
use rustc::hir;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};

View File

@ -1,4 +1,4 @@
use crate::utils::{last_path_segment, paths, snippet, span_lint, span_lint_and_then, sugg, match_def_path};
use crate::utils::{last_path_segment, match_def_path, paths, snippet, span_lint, span_lint_and_then, sugg};
use if_chain::if_chain;
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

View File

@ -1,5 +1,5 @@
use crate::consts::{constant_context, Constant};
use crate::utils::{paths, match_qpath, span_lint};
use crate::utils::{match_qpath, paths, span_lint};
use if_chain::if_chain;
use rustc::hir::{Expr, ExprKind};
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};

View File

@ -1,7 +1,7 @@
use std::cmp;
use crate::utils::{in_macro_or_desugar, is_copy, is_self_ty, snippet, span_lint_and_sugg};
use crate::utils::sym;
use crate::utils::{in_macro_or_desugar, is_copy, is_self_ty, snippet, span_lint_and_sugg};
use if_chain::if_chain;
use matches::matches;
use rustc::hir;

View File

@ -22,12 +22,12 @@ use syntax::symbol::Symbol;
use crate::consts::{constant, Constant};
use crate::utils::paths;
use crate::utils::sym;
use crate::utils::{
clip, comparisons, differing_macro_contexts, higher, in_constant, in_macro_or_desugar, int_bits, last_path_segment,
match_path, multispan_sugg, same_tys, sext, snippet, snippet_opt, snippet_with_applicability, span_help_and_lint,
span_lint, span_lint_and_sugg, span_lint_and_then, unsext, match_def_path,
match_def_path, match_path, multispan_sugg, same_tys, sext, snippet, snippet_opt, snippet_with_applicability,
span_help_and_lint, span_lint, span_lint_and_sugg, span_lint_and_then, unsext,
};
use crate::utils::sym;
declare_clippy_lint! {
/// **What it does:** Checks for use of `Box<Vec<_>>` anywhere in the code.

View File

@ -2,10 +2,10 @@ use if_chain::if_chain;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};
use crate::utils::sym;
use crate::utils::{
higher::if_block, in_macro_or_desugar, match_type, paths, span_lint_and_then, usage::is_potentially_mutated,
};
use crate::utils::sym;
use rustc::hir::intravisit::*;
use rustc::hir::*;
use syntax::source_map::Span;

View File

@ -2,8 +2,8 @@
#![deny(clippy::missing_docs_in_private_items)]
use lazy_static::lazy_static;
use crate::utils::sym;
use lazy_static::lazy_static;
use std::default::Default;
use std::io::Read;
use std::sync::Mutex;

View File

@ -3,8 +3,8 @@
#![deny(clippy::missing_docs_in_private_items)]
use crate::utils::{is_expn_of, match_def_path, match_qpath, paths, resolve_node};
use crate::utils::sym;
use crate::utils::{is_expn_of, match_def_path, match_qpath, paths, resolve_node};
use if_chain::if_chain;
use rustc::lint::LateContext;
use rustc::{hir, ty};
@ -102,7 +102,8 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O
},
hir::ExprKind::Call(ref path, ref args) => {
if let hir::ExprKind::Path(ref path) = path.node {
if match_qpath(path, &*paths::RANGE_INCLUSIVE_STD_NEW) || match_qpath(path, &*paths::RANGE_INCLUSIVE_NEW)
if match_qpath(path, &*paths::RANGE_INCLUSIVE_STD_NEW)
|| match_qpath(path, &*paths::RANGE_INCLUSIVE_NEW)
{
Some(Range {
start: Some(&args[0]),
@ -129,7 +130,8 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O
end: Some(get_field(*sym::end, fields)?),
limits: ast::RangeLimits::HalfOpen,
})
} else if match_qpath(path, &*paths::RANGE_TO_INCLUSIVE_STD) || match_qpath(path, &*paths::RANGE_TO_INCLUSIVE)
} else if match_qpath(path, &*paths::RANGE_TO_INCLUSIVE_STD)
|| match_qpath(path, &*paths::RANGE_TO_INCLUSIVE)
{
Some(Range {
start: None,

View File

@ -1,4 +1,4 @@
use crate::utils::{match_type, match_def_path, paths, span_help_and_lint, span_lint, walk_ptrs_ty};
use crate::utils::{match_def_path, match_type, paths, span_help_and_lint, span_lint, walk_ptrs_ty};
use if_chain::if_chain;
use rustc::hir;
use rustc::hir::def::{DefKind, Res};

View File

@ -4,118 +4,120 @@
#![allow(default_hash_types)] // we just look at symbol names, which is good enough everywhere else
use super::sym::{self, *};
use syntax::symbol::Symbol;
use lazy_static::lazy_static;
use syntax::symbol::Symbol;
lazy_static! {
pub static ref ANY_TRAIT: [Symbol; 3] = [*std, *any, *Any];
pub static ref ARC: [Symbol; 3] = [*alloc, *sync, *Arc];
pub static ref ASMUT_TRAIT: [Symbol; 3] = [*core, *convert, *sym::AsMut];
pub static ref ASREF_TRAIT: [Symbol; 3] = [*core, *convert, *sym::AsRef];
pub static ref BEGIN_PANIC: [Symbol; 3] = [*std, *panicking, *begin_panic];
pub static ref BEGIN_PANIC_FMT: [Symbol; 3] = [*std, *panicking, *begin_panic_fmt];
pub static ref BINARY_HEAP: [Symbol; 4] = [*alloc, *collections, *binary_heap, *BinaryHeap];
pub static ref BORROW_TRAIT: [Symbol; 3] = [*core, *borrow, *Borrow];
pub static ref BTREEMAP: [Symbol; 5] = [*alloc, *collections, *btree, *map, *BTreeMap];
pub static ref BTREEMAP_ENTRY: [Symbol; 5] = [*alloc, *collections, *btree, *map, *Entry];
pub static ref BTREESET: [Symbol; 5] = [*alloc, *collections, *btree, *set, *BTreeSet];
pub static ref CLONE_TRAIT: [Symbol; 3] = [*core, *clone, *sym::Clone];
pub static ref CLONE_TRAIT_METHOD: [Symbol; 4] = [*core, *clone, *sym::Clone, *clone];
pub static ref CMP_MAX: [Symbol; 3] = [*core, *cmp, *max];
pub static ref CMP_MIN: [Symbol; 3] = [*core, *cmp, *min];
pub static ref COW: [Symbol; 3] = [*alloc, *borrow, *Cow];
pub static ref CSTRING_NEW: [Symbol; 5] = [*std, *ffi, *c_str, *CString, *new];
pub static ref DEFAULT_TRAIT: [Symbol; 3] = [*core, *default, *sym::Default];
pub static ref DEFAULT_TRAIT_METHOD: [Symbol; 4] = [*core, *default, *sym::Default, *default];
pub static ref DEREF_TRAIT_METHOD: [Symbol; 5] = [*core, *ops, *deref, *Deref, *deref];
pub static ref DISPLAY_FMT_METHOD: [Symbol; 4] = [*core, *fmt, *Display, *fmt];
pub static ref DOUBLE_ENDED_ITERATOR: [Symbol; 4] = [*core, *iter, *traits, *sym::DoubleEndedIterator];
pub static ref DROP: [Symbol; 3] = [*core, *mem, *drop];
pub static ref DROP_TRAIT: [Symbol; 4] = [*core, *ops, *drop, *sym::Drop];
pub static ref DURATION: [Symbol; 3] = [*core, *time, *Duration];
pub static ref EARLY_CONTEXT: [Symbol; 4] = [*rustc, *lint, *context, *EarlyContext];
pub static ref FMT_ARGUMENTS_NEWV1: [Symbol; 4] = [*core, *fmt, *Arguments, *new_v1];
pub static ref FMT_ARGUMENTS_NEWV1FORMATTED: [Symbol; 4] = [*core, *fmt, *Arguments, *new_v1_formatted];
pub static ref FROM_FROM: [Symbol; 4] = [*core, *convert, *sym::From, *from];
pub static ref FROM_TRAIT: [Symbol; 3] = [*core, *convert, *sym::From];
pub static ref HASH: [Symbol; 2] = [*hash, *Hash];
pub static ref HASHMAP: [Symbol; 5] = [*std, *collections, *hash, *map, *HashMap];
pub static ref HASHMAP_ENTRY: [Symbol; 5] = [*std, *collections, *hash, *map, *Entry];
pub static ref HASHSET: [Symbol; 5] = [*std, *collections, *hash, *set, *HashSet];
pub static ref INDEX: [Symbol; 3] = [*core, *ops, *Index];
pub static ref INDEX_MUT: [Symbol; 3] = [*core, *ops, *IndexMut];
pub static ref INIT: [Symbol; 4] = [*core, *intrinsics, *empty_symbol, *init];
pub static ref INTO: [Symbol; 3] = [*core, *convert, *sym::Into];
pub static ref INTO_ITERATOR: [Symbol; 5] = [*core, *iter, *traits, *collect, *sym::IntoIterator];
pub static ref IO_READ: [Symbol; 3] = [*std, *io, *Read];
pub static ref IO_WRITE: [Symbol; 3] = [*std, *io, *Write];
pub static ref ITERATOR: [Symbol; 5] = [*core, *iter, *traits, *iterator, *sym::Iterator];
pub static ref LATE_CONTEXT: [Symbol; 4] = [*rustc, *lint, *context, *LateContext];
pub static ref LINKED_LIST: [Symbol; 4] = [*alloc, *collections, *linked_list, *LinkedList];
pub static ref LINT: [Symbol; 3] = [*rustc, *lint, *Lint];
pub static ref LINT_PASS: [Symbol; 3] = [*rustc, *lint, *LintPass];
pub static ref MEM_DISCRIMINANT: [Symbol; 3] = [*core, *mem, *discriminant];
pub static ref MEM_FORGET: [Symbol; 3] = [*core, *mem, *forget];
pub static ref MEM_REPLACE: [Symbol; 3] = [*core, *mem, *replace];
pub static ref MEM_UNINIT: [Symbol; 3] = [*core, *mem, *uninitialized];
pub static ref MEM_ZEROED: [Symbol; 3] = [*core, *mem, *zeroed];
pub static ref MUTEX: [Symbol; 4] = [*std, *sync, *mutex, *Mutex];
pub static ref OPEN_OPTIONS: [Symbol; 3] = [*std, *fs, *OpenOptions];
pub static ref OPS_MODULE: [Symbol; 2] = [*core, *ops];
pub static ref OPTION: [Symbol; 3] = [*core, *option, *sym::Option];
pub static ref OPTION_NONE: [Symbol; 4] = [*core, *option, *sym::Option, *sym::None];
pub static ref OPTION_SOME: [Symbol; 4] = [*core, *option, *sym::Option, *sym::Some];
pub static ref ORD: [Symbol; 3] = [*core, *cmp, *sym::Ord];
pub static ref OS_STRING: [Symbol; 4] = [*std, *ffi, *os_str, *OsString];
pub static ref OS_STR_TO_OS_STRING: [Symbol; 5] = [*std, *ffi, *os_str, *OsStr, *to_os_string];
pub static ref PARTIAL_ORD: [Symbol; 3] = [*core, *cmp, *sym::PartialOrd];
pub static ref PATH: [Symbol; 3] = [*std, *path, *Path];
pub static ref PATH_BUF: [Symbol; 3] = [*std, *path, *PathBuf];
pub static ref PATH_TO_PATH_BUF: [Symbol; 4] = [*std, *path, *Path, *to_path_buf];
pub static ref PTR_NULL: [Symbol; 2] = [*ptr, *null];
pub static ref PTR_NULL_MUT: [Symbol; 2] = [*ptr, *null_mut];
pub static ref RANGE: [Symbol; 3] = [*core, *ops, *Range];
pub static ref RANGE_ARGUMENT_TRAIT: [Symbol; 3] = [*core, *ops, *RangeBounds];
pub static ref RANGE_FROM: [Symbol; 3] = [*core, *ops, *RangeFrom];
pub static ref RANGE_FROM_STD: [Symbol; 3] = [*std, *ops, *RangeFrom];
pub static ref RANGE_FULL: [Symbol; 3] = [*core, *ops, *RangeFull];
pub static ref RANGE_FULL_STD: [Symbol; 3] = [*std, *ops, *RangeFull];
pub static ref RANGE_INCLUSIVE_NEW: [Symbol; 4] = [*core, *ops, *RangeInclusive, *new];
pub static ref RANGE_INCLUSIVE_STD_NEW: [Symbol; 4] = [*std, *ops, *RangeInclusive, *new];
pub static ref RANGE_STD: [Symbol; 3] = [*std, *ops, *Range];
pub static ref RANGE_TO: [Symbol; 3] = [*core, *ops, *RangeTo];
pub static ref RANGE_TO_INCLUSIVE: [Symbol; 3] = [*core, *ops, *RangeToInclusive];
pub static ref RANGE_TO_INCLUSIVE_STD: [Symbol; 3] = [*std, *ops, *RangeToInclusive];
pub static ref RANGE_TO_STD: [Symbol; 3] = [*std, *ops, *RangeTo];
pub static ref RC: [Symbol; 3] = [*alloc, *rc, *Rc];
pub static ref RECEIVER: [Symbol; 4] = [*std, *sync, *mpsc, *Receiver];
pub static ref REGEX: [Symbol; 3] = [*regex, *re_unicode, *Regex];
pub static ref REGEX_BUILDER_NEW: [Symbol; 5] = [*regex, *re_builder, *unicode, *RegexBuilder, *new];
pub static ref REGEX_BYTES_BUILDER_NEW: [Symbol; 5] = [*regex, *re_builder, *bytes, *RegexBuilder, *new];
pub static ref REGEX_BYTES_NEW: [Symbol; 4] = [*regex, *re_bytes, *Regex, *new];
pub static ref REGEX_BYTES_SET_NEW: [Symbol; 5] = [*regex, *re_set, *bytes, *RegexSet, *new];
pub static ref REGEX_NEW: [Symbol; 4] = [*regex, *re_unicode, *Regex, *new];
pub static ref REGEX_SET_NEW: [Symbol; 5] = [*regex, *re_set, *unicode, *RegexSet, *new];
pub static ref REPEAT: [Symbol; 3] = [*core, *iter, *repeat];
pub static ref RESULT: [Symbol; 3] = [*core, *result, *sym::Result];
pub static ref RESULT_ERR: [Symbol; 4] = [*core, *result, *sym::Result, *sym::Err];
pub static ref RESULT_OK: [Symbol; 4] = [*core, *result, *sym::Result, *sym::Ok];
pub static ref SERDE_DE_VISITOR: [Symbol; 3] = [*serde, *de, *Visitor];
pub static ref SLICE_INTO_VEC: [Symbol; 4] = [*alloc, *slice, *impl_slice_t, *into_vec];
pub static ref SLICE_ITER: [Symbol; 3] = [*core, *slice, *Iter];
pub static ref STD_MEM_TRANSMUTE: [Symbol; 3] = [*std, *mem, *transmute];
pub static ref STD_PTR_NULL: [Symbol; 3] = [*std, *ptr, *null];
pub static ref STRING: [Symbol; 3] = [*alloc, *string, *sym::String];
pub static ref TO_OWNED: [Symbol; 3] = [*alloc, *borrow, *sym::ToOwned];
pub static ref TO_OWNED_METHOD: [Symbol; 4] = [*alloc, *borrow, *sym::ToOwned, *to_owned];
pub static ref TO_STRING: [Symbol; 3] = [*alloc, *string, *sym::ToString];
pub static ref TO_STRING_METHOD: [Symbol; 4] = [*alloc, *string, *sym::ToString, *to_string];
pub static ref TRANSMUTE: [Symbol; 4] = [*core, *intrinsics, *empty_symbol, *transmute];
pub static ref TRY_INTO_RESULT: [Symbol; 4] = [*std, *ops, *Try, *into_result];
pub static ref UNINIT: [Symbol; 4] = [*core, *intrinsics, *empty_symbol, *uninit];
pub static ref VEC: [Symbol; 3] = [*alloc, *vec, *sym::Vec];
pub static ref VEC_DEQUE: [Symbol; 4] = [*alloc, *collections, *vec_deque, *VecDeque];
pub static ref VEC_FROM_ELEM: [Symbol; 3] = [*alloc, *vec, *from_elem];
pub static ref WEAK_ARC: [Symbol; 3] = [*alloc, *sync, *Weak];
pub static ref WEAK_RC: [Symbol; 3] = [*alloc, *rc, *Weak];
pub static ref ANY_TRAIT: [Symbol; 3] = [*std, *any, *Any];
pub static ref ARC: [Symbol; 3] = [*alloc, *sync, *Arc];
pub static ref ASMUT_TRAIT: [Symbol; 3] = [*core, *convert, *sym::AsMut];
pub static ref ASREF_TRAIT: [Symbol; 3] = [*core, *convert, *sym::AsRef];
pub static ref BEGIN_PANIC: [Symbol; 3] = [*std, *panicking, *begin_panic];
pub static ref BEGIN_PANIC_FMT: [Symbol; 3] = [*std, *panicking, *begin_panic_fmt];
pub static ref BINARY_HEAP: [Symbol; 4] = [*alloc, *collections, *binary_heap, *BinaryHeap];
pub static ref BORROW_TRAIT: [Symbol; 3] = [*core, *borrow, *Borrow];
pub static ref BTREEMAP: [Symbol; 5] = [*alloc, *collections, *btree, *map, *BTreeMap];
pub static ref BTREEMAP_ENTRY: [Symbol; 5] = [*alloc, *collections, *btree, *map, *Entry];
pub static ref BTREESET: [Symbol; 5] = [*alloc, *collections, *btree, *set, *BTreeSet];
pub static ref CLONE_TRAIT: [Symbol; 3] = [*core, *clone, *sym::Clone];
pub static ref CLONE_TRAIT_METHOD: [Symbol; 4] = [*core, *clone, *sym::Clone, *clone];
pub static ref CMP_MAX: [Symbol; 3] = [*core, *cmp, *max];
pub static ref CMP_MIN: [Symbol; 3] = [*core, *cmp, *min];
pub static ref COW: [Symbol; 3] = [*alloc, *borrow, *Cow];
pub static ref CSTRING_NEW: [Symbol; 5] = [*std, *ffi, *c_str, *CString, *new];
pub static ref DEFAULT_TRAIT: [Symbol; 3] = [*core, *default, *sym::Default];
pub static ref DEFAULT_TRAIT_METHOD: [Symbol; 4] = [*core, *default, *sym::Default, *default];
pub static ref DEREF_TRAIT_METHOD: [Symbol; 5] = [*core, *ops, *deref, *Deref, *deref];
pub static ref DISPLAY_FMT_METHOD: [Symbol; 4] = [*core, *fmt, *Display, *fmt];
pub static ref DOUBLE_ENDED_ITERATOR: [Symbol; 4] = [*core, *iter, *traits, *sym::DoubleEndedIterator];
pub static ref DROP: [Symbol; 3] = [*core, *mem, *drop];
pub static ref DROP_TRAIT: [Symbol; 4] = [*core, *ops, *drop, *sym::Drop];
pub static ref DURATION: [Symbol; 3] = [*core, *time, *Duration];
pub static ref EARLY_CONTEXT: [Symbol; 4] = [*rustc, *lint, *context, *EarlyContext];
pub static ref FMT_ARGUMENTS_NEWV1: [Symbol; 4] = [*core, *fmt, *Arguments, *new_v1];
pub static ref FMT_ARGUMENTS_NEWV1FORMATTED: [Symbol; 4] = [*core, *fmt, *Arguments, *new_v1_formatted];
pub static ref FROM_FROM: [Symbol; 4] = [*core, *convert, *sym::From, *from];
pub static ref FROM_TRAIT: [Symbol; 3] = [*core, *convert, *sym::From];
pub static ref HASH: [Symbol; 2] = [*hash, *Hash];
pub static ref HASHMAP: [Symbol; 5] = [*std, *collections, *hash, *map, *HashMap];
pub static ref HASHMAP_ENTRY: [Symbol; 5] = [*std, *collections, *hash, *map, *Entry];
pub static ref HASHSET: [Symbol; 5] = [*std, *collections, *hash, *set, *HashSet];
pub static ref INDEX: [Symbol; 3] = [*core, *ops, *Index];
pub static ref INDEX_MUT: [Symbol; 3] = [*core, *ops, *IndexMut];
pub static ref INIT: [Symbol; 4] = [*core, *intrinsics, *empty_symbol, *init];
pub static ref INTO: [Symbol; 3] = [*core, *convert, *sym::Into];
pub static ref INTO_ITERATOR: [Symbol; 5] = [*core, *iter, *traits, *collect, *sym::IntoIterator];
pub static ref IO_READ: [Symbol; 3] = [*std, *io, *Read];
pub static ref IO_WRITE: [Symbol; 3] = [*std, *io, *Write];
pub static ref ITERATOR: [Symbol; 5] = [*core, *iter, *traits, *iterator, *sym::Iterator];
pub static ref LATE_CONTEXT: [Symbol; 4] = [*rustc, *lint, *context, *LateContext];
pub static ref LINKED_LIST: [Symbol; 4] = [*alloc, *collections, *linked_list, *LinkedList];
pub static ref LINT: [Symbol; 3] = [*rustc, *lint, *Lint];
pub static ref LINT_PASS: [Symbol; 3] = [*rustc, *lint, *LintPass];
pub static ref MEM_DISCRIMINANT: [Symbol; 3] = [*core, *mem, *discriminant];
pub static ref MEM_FORGET: [Symbol; 3] = [*core, *mem, *forget];
pub static ref MEM_REPLACE: [Symbol; 3] = [*core, *mem, *replace];
pub static ref MEM_UNINIT: [Symbol; 3] = [*core, *mem, *uninitialized];
pub static ref MEM_ZEROED: [Symbol; 3] = [*core, *mem, *zeroed];
pub static ref MUTEX: [Symbol; 4] = [*std, *sync, *mutex, *Mutex];
pub static ref OPEN_OPTIONS: [Symbol; 3] = [*std, *fs, *OpenOptions];
pub static ref OPS_MODULE: [Symbol; 2] = [*core, *ops];
pub static ref OPTION: [Symbol; 3] = [*core, *option, *sym::Option];
pub static ref OPTION_NONE: [Symbol; 4] = [*core, *option, *sym::Option, *sym::None];
pub static ref OPTION_SOME: [Symbol; 4] = [*core, *option, *sym::Option, *sym::Some];
pub static ref ORD: [Symbol; 3] = [*core, *cmp, *sym::Ord];
pub static ref OS_STRING: [Symbol; 4] = [*std, *ffi, *os_str, *OsString];
pub static ref OS_STR_TO_OS_STRING: [Symbol; 5] = [*std, *ffi, *os_str, *OsStr, *to_os_string];
pub static ref PARTIAL_ORD: [Symbol; 3] = [*core, *cmp, *sym::PartialOrd];
pub static ref PATH: [Symbol; 3] = [*std, *path, *Path];
pub static ref PATH_BUF: [Symbol; 3] = [*std, *path, *PathBuf];
pub static ref PATH_TO_PATH_BUF: [Symbol; 4] = [*std, *path, *Path, *to_path_buf];
pub static ref PTR_NULL: [Symbol; 2] = [*ptr, *null];
pub static ref PTR_NULL_MUT: [Symbol; 2] = [*ptr, *null_mut];
pub static ref RANGE: [Symbol; 3] = [*core, *ops, *Range];
pub static ref RANGE_ARGUMENT_TRAIT: [Symbol; 3] = [*core, *ops, *RangeBounds];
pub static ref RANGE_FROM: [Symbol; 3] = [*core, *ops, *RangeFrom];
pub static ref RANGE_FROM_STD: [Symbol; 3] = [*std, *ops, *RangeFrom];
pub static ref RANGE_FULL: [Symbol; 3] = [*core, *ops, *RangeFull];
pub static ref RANGE_FULL_STD: [Symbol; 3] = [*std, *ops, *RangeFull];
pub static ref RANGE_INCLUSIVE_NEW: [Symbol; 4] = [*core, *ops, *RangeInclusive, *new];
pub static ref RANGE_INCLUSIVE_STD_NEW: [Symbol; 4] = [*std, *ops, *RangeInclusive, *new];
pub static ref RANGE_STD: [Symbol; 3] = [*std, *ops, *Range];
pub static ref RANGE_TO: [Symbol; 3] = [*core, *ops, *RangeTo];
pub static ref RANGE_TO_INCLUSIVE: [Symbol; 3] = [*core, *ops, *RangeToInclusive];
pub static ref RANGE_TO_INCLUSIVE_STD: [Symbol; 3] = [*std, *ops, *RangeToInclusive];
pub static ref RANGE_TO_STD: [Symbol; 3] = [*std, *ops, *RangeTo];
pub static ref RC: [Symbol; 3] = [*alloc, *rc, *Rc];
pub static ref RECEIVER: [Symbol; 4] = [*std, *sync, *mpsc, *Receiver];
pub static ref REGEX: [Symbol; 3] = [*regex, *re_unicode, *Regex];
pub static ref REGEX_BUILDER_NEW: [Symbol; 5] = [*regex, *re_builder, *unicode, *RegexBuilder, *new];
pub static ref REGEX_BYTES_BUILDER_NEW: [Symbol; 5] = [*regex, *re_builder, *bytes, *RegexBuilder, *new];
pub static ref REGEX_BYTES_NEW: [Symbol; 4] = [*regex, *re_bytes, *Regex, *new];
pub static ref REGEX_BYTES_SET_NEW: [Symbol; 5] = [*regex, *re_set, *bytes, *RegexSet, *new];
pub static ref REGEX_NEW: [Symbol; 4] = [*regex, *re_unicode, *Regex, *new];
pub static ref REGEX_SET_NEW: [Symbol; 5] = [*regex, *re_set, *unicode, *RegexSet, *new];
pub static ref REPEAT: [Symbol; 3] = [*core, *iter, *repeat];
pub static ref RESULT: [Symbol; 3] = [*core, *result, *sym::Result];
pub static ref RESULT_ERR: [Symbol; 4] = [*core, *result, *sym::Result, *sym::Err];
pub static ref RESULT_OK: [Symbol; 4] = [*core, *result, *sym::Result, *sym::Ok];
pub static ref SERDE_DE_VISITOR: [Symbol; 3] = [*serde, *de, *Visitor];
pub static ref SLICE_INTO_VEC: [Symbol; 4] = [*alloc, *slice, *impl_slice_t, *into_vec];
pub static ref SLICE_ITER: [Symbol; 3] = [*core, *slice, *Iter];
pub static ref STD_MEM_TRANSMUTE: [Symbol; 3] = [*std, *mem, *transmute];
pub static ref STD_PTR_NULL: [Symbol; 3] = [*std, *ptr, *null];
pub static ref STDERR: [Symbol; 4] = [*std, *io, *stdio, *stderr];
pub static ref STDOUT: [Symbol; 4] = [*std, *io, *stdio, *stdout];
pub static ref STRING: [Symbol; 3] = [*alloc, *string, *sym::String];
pub static ref TO_OWNED: [Symbol; 3] = [*alloc, *borrow, *sym::ToOwned];
pub static ref TO_OWNED_METHOD: [Symbol; 4] = [*alloc, *borrow, *sym::ToOwned, *to_owned];
pub static ref TO_STRING: [Symbol; 3] = [*alloc, *string, *sym::ToString];
pub static ref TO_STRING_METHOD: [Symbol; 4] = [*alloc, *string, *sym::ToString, *to_string];
pub static ref TRANSMUTE: [Symbol; 4] = [*core, *intrinsics, *empty_symbol, *transmute];
pub static ref TRY_INTO_RESULT: [Symbol; 4] = [*std, *ops, *Try, *into_result];
pub static ref UNINIT: [Symbol; 4] = [*core, *intrinsics, *empty_symbol, *uninit];
pub static ref VEC: [Symbol; 3] = [*alloc, *vec, *sym::Vec];
pub static ref VEC_DEQUE: [Symbol; 4] = [*alloc, *collections, *vec_deque, *VecDeque];
pub static ref VEC_FROM_ELEM: [Symbol; 3] = [*alloc, *vec, *from_elem];
pub static ref WEAK_ARC: [Symbol; 3] = [*alloc, *sync, *Weak];
pub static ref WEAK_RC: [Symbol; 3] = [*alloc, *rc, *Weak];
}

View File

@ -1,5 +1,5 @@
use crate::utils::{get_pat_name, match_var, snippet};
use crate::utils::sym;
use crate::utils::{get_pat_name, match_var, snippet};
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::hir::*;
use rustc::lint::LateContext;

View File

@ -1,7 +1,7 @@
#![allow(default_hash_types, non_upper_case_globals)]
use syntax::symbol::Symbol;
use lazy_static::lazy_static;
use syntax::symbol::Symbol;
macro_rules! symbols_simple {
($($ident:ident,)*) => {
@ -26,17 +26,17 @@ macro_rules! symbols_init {
// exists because concat_idents is flaky
pub mod assign {
pub(crate) use super::AddAssign as Add;
pub(crate) use super::SubAssign as Sub;
pub(crate) use super::MulAssign as Mul;
pub(crate) use super::DivAssign as Div;
pub(crate) use super::RemAssign as Rem;
pub(crate) use super::AndAssign as And;
pub(crate) use super::OrAssign as Or;
pub(crate) use super::BitAndAssign as BitAnd;
pub(crate) use super::BitOrAssign as BitOr;
pub(crate) use super::BitXorAssign as BitXor;
pub(crate) use super::ShrAssign as Shr;
pub(crate) use super::DivAssign as Div;
pub(crate) use super::MulAssign as Mul;
pub(crate) use super::OrAssign as Or;
pub(crate) use super::RemAssign as Rem;
pub(crate) use super::ShlAssign as Shl;
pub(crate) use super::ShrAssign as Shr;
pub(crate) use super::SubAssign as Sub;
}
symbols_simple! {
@ -387,7 +387,6 @@ symbols_simple! {
zip,
}
symbols_init! {
impl_slice_t: "<impl [T]>",
empty_symbol: "",