do minor cleanups
* ToString and AsRef are in prelude, no need to import them
This commit is contained in:
parent
37b7970a7c
commit
f5b896451a
17 changed files with 44 additions and 73 deletions
|
|
@ -8,8 +8,6 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
|
|||
use rustc_session::declare_tool_lint;
|
||||
use syntax::{ast::*, source_map::DUMMY_SP};
|
||||
|
||||
use cargo_metadata;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks to see if all common metadata is defined in
|
||||
/// `Cargo.toml`. See: https://rust-lang-nursery.github.io/api-guidelines/documentation.html#cargotoml-includes-all-common-metadata-c-metadata
|
||||
|
|
@ -56,7 +54,7 @@ fn is_empty_path(value: &Option<PathBuf>) -> bool {
|
|||
|
||||
fn is_empty_vec(value: &[String]) -> bool {
|
||||
// This works because empty iterators return true
|
||||
value.iter().all(std::string::String::is_empty)
|
||||
value.iter().all(String::is_empty)
|
||||
}
|
||||
|
||||
declare_lint_pass!(CargoCommonMetadata => [CARGO_COMMON_METADATA]);
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||
let res = self.tables.qpath_res(qpath, callee.hir_id);
|
||||
if let Some(def_id) = res.opt_def_id();
|
||||
let def_path: Vec<_> = self.lcx.get_def_path(def_id).into_iter().map(Symbol::as_str).collect();
|
||||
let def_path: Vec<&str> = def_path.iter().map(|s| &**s).collect();
|
||||
let def_path: Vec<&str> = def_path.iter().take(4).map(|s| &**s).collect();
|
||||
if let ["core", "num", int_impl, "max_value"] = *def_path;
|
||||
then {
|
||||
let value = match int_impl {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use crate::utils::{match_type, paths, return_ty, span_lint};
|
||||
use itertools::Itertools;
|
||||
use pulldown_cmark;
|
||||
use rustc::hir;
|
||||
use rustc::impl_lint_pass;
|
||||
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
||||
|
|
|
|||
|
|
@ -146,11 +146,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
|
|||
}
|
||||
|
||||
/// Tries to determine the type for universal function call to be used instead of the closure
|
||||
fn get_ufcs_type_name(
|
||||
cx: &LateContext<'_, '_>,
|
||||
method_def_id: def_id::DefId,
|
||||
self_arg: &Expr,
|
||||
) -> std::option::Option<String> {
|
||||
fn get_ufcs_type_name(cx: &LateContext<'_, '_>, method_def_id: def_id::DefId, self_arg: &Expr) -> Option<String> {
|
||||
let expected_type_of_self = &cx.tcx.fn_sig(method_def_id).inputs_and_output().skip_binder()[0];
|
||||
let actual_type_of_self = &cx.tables.node_type(self_arg.hir_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ extern crate syntax_pos;
|
|||
use rustc::lint::{self, LintId};
|
||||
use rustc::session::Session;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use toml;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
/// Macro used to declare a Clippy lint.
|
||||
///
|
||||
|
|
@ -349,16 +350,16 @@ pub fn read_conf(args: &[syntax::ast::NestedMetaItem], sess: &Session) -> Conf {
|
|||
let file_name = file_name.map(|file_name| {
|
||||
if file_name.is_relative() {
|
||||
sess.local_crate_source_file
|
||||
.as_ref()
|
||||
.and_then(|file| std::path::Path::new(&file).parent().map(std::path::Path::to_path_buf))
|
||||
.unwrap_or_default()
|
||||
.as_deref()
|
||||
.and_then(Path::parent)
|
||||
.unwrap_or_else(|| Path::new(""))
|
||||
.join(file_name)
|
||||
} else {
|
||||
file_name
|
||||
}
|
||||
});
|
||||
|
||||
let (conf, errors) = utils::conf::read(file_name.as_ref().map(std::convert::AsRef::as_ref));
|
||||
let (conf, errors) = utils::conf::read(file_name.as_ref().map(AsRef::as_ref));
|
||||
|
||||
// all conf errors are non-fatal, we just use the default conf in case of error
|
||||
for error in errors {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use rustc::{declare_lint_pass, impl_lint_pass};
|
|||
use rustc_errors::Applicability;
|
||||
use rustc_session::declare_tool_lint;
|
||||
use syntax::ast::*;
|
||||
use syntax_pos;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Warns if a long integral or floating-point constant does
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
|
|||
use rustc_session::declare_tool_lint;
|
||||
use syntax::{ast::*, source_map::DUMMY_SP};
|
||||
|
||||
use cargo_metadata;
|
||||
use itertools::Itertools;
|
||||
|
||||
declare_clippy_lint! {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use crate::consts::{constant, Constant};
|
||||
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::*;
|
||||
use rustc::impl_lint_pass;
|
||||
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use std::io::Read;
|
|||
use std::sync::Mutex;
|
||||
use std::{env, fmt, fs, io, path};
|
||||
use syntax::{ast, source_map};
|
||||
use toml;
|
||||
|
||||
/// Gets the configuration file from arguments.
|
||||
pub fn file_from_args(args: &[ast::NestedMetaItem]) -> Result<Option<path::PathBuf>, (&'static str, source_map::Span)> {
|
||||
|
|
@ -77,7 +76,6 @@ macro_rules! define_Conf {
|
|||
}
|
||||
$(
|
||||
mod $rust_name {
|
||||
use serde;
|
||||
use serde::Deserialize;
|
||||
crate fn deserialize<'de, D: serde::Deserializer<'de>>(deserializer: D)
|
||||
-> Result<define_Conf!(TY $($ty)+), D::Error> {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ use crate::utils::{higher, snippet, snippet_opt, snippet_with_macro_callsite};
|
|||
use matches::matches;
|
||||
use rustc::hir;
|
||||
use rustc::lint::{EarlyContext, LateContext, LintContext};
|
||||
use rustc_errors;
|
||||
use rustc_errors::Applicability;
|
||||
use std;
|
||||
use std::borrow::Cow;
|
||||
use std::convert::TryInto;
|
||||
use std::fmt::Display;
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
|
|||
use rustc_session::declare_tool_lint;
|
||||
use syntax::{ast::*, source_map::DUMMY_SP};
|
||||
|
||||
use cargo_metadata;
|
||||
use if_chain::if_chain;
|
||||
use semver;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for wildcard dependencies in the `Cargo.toml`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue