Skip to content

Commit 82b0325

Browse files
committed
Auto merge of #4946 - lzutao:take, r=flip1995
a few minor cleanups changelog: none
2 parents 37b7970 + f5b8964 commit 82b0325

17 files changed

+45
-74
lines changed

clippy_dev/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Lint {
5050
name: name.to_lowercase(),
5151
group: group.to_string(),
5252
desc: NL_ESCAPE_RE.replace(&desc.replace("\\\"", "\""), "").to_string(),
53-
deprecation: deprecation.map(std::string::ToString::to_string),
53+
deprecation: deprecation.map(ToString::to_string),
5454
module: module.to_string(),
5555
}
5656
}

clippy_lints/src/cargo_common_metadata.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
88
use rustc_session::declare_tool_lint;
99
use syntax::{ast::*, source_map::DUMMY_SP};
1010

11-
use cargo_metadata;
12-
1311
declare_clippy_lint! {
1412
/// **What it does:** Checks to see if all common metadata is defined in
1513
/// `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 {
5654

5755
fn is_empty_vec(value: &[String]) -> bool {
5856
// This works because empty iterators return true
59-
value.iter().all(std::string::String::is_empty)
57+
value.iter().all(String::is_empty)
6058
}
6159

6260
declare_lint_pass!(CargoCommonMetadata => [CARGO_COMMON_METADATA]);

clippy_lints/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
253253
let res = self.tables.qpath_res(qpath, callee.hir_id);
254254
if let Some(def_id) = res.opt_def_id();
255255
let def_path: Vec<_> = self.lcx.get_def_path(def_id).into_iter().map(Symbol::as_str).collect();
256-
let def_path: Vec<&str> = def_path.iter().map(|s| &**s).collect();
256+
let def_path: Vec<&str> = def_path.iter().take(4).map(|s| &**s).collect();
257257
if let ["core", "num", int_impl, "max_value"] = *def_path;
258258
then {
259259
let value = match int_impl {

clippy_lints/src/doc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::utils::{match_type, paths, return_ty, span_lint};
22
use itertools::Itertools;
3-
use pulldown_cmark;
43
use rustc::hir;
54
use rustc::impl_lint_pass;
65
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

clippy_lints/src/eta_reduction.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,7 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) {
146146
}
147147

148148
/// Tries to determine the type for universal function call to be used instead of the closure
149-
fn get_ufcs_type_name(
150-
cx: &LateContext<'_, '_>,
151-
method_def_id: def_id::DefId,
152-
self_arg: &Expr,
153-
) -> std::option::Option<String> {
149+
fn get_ufcs_type_name(cx: &LateContext<'_, '_>, method_def_id: def_id::DefId, self_arg: &Expr) -> Option<String> {
154150
let expected_type_of_self = &cx.tcx.fn_sig(method_def_id).inputs_and_output().skip_binder()[0];
155151
let actual_type_of_self = &cx.tables.node_type(self_arg.hir_id);
156152

clippy_lints/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ extern crate syntax_pos;
4747
use rustc::lint::{self, LintId};
4848
use rustc::session::Session;
4949
use rustc_data_structures::fx::FxHashSet;
50-
use toml;
50+
51+
use std::path::Path;
5152

5253
/// Macro used to declare a Clippy lint.
5354
///
@@ -349,16 +350,16 @@ pub fn read_conf(args: &[syntax::ast::NestedMetaItem], sess: &Session) -> Conf {
349350
let file_name = file_name.map(|file_name| {
350351
if file_name.is_relative() {
351352
sess.local_crate_source_file
352-
.as_ref()
353-
.and_then(|file| std::path::Path::new(&file).parent().map(std::path::Path::to_path_buf))
354-
.unwrap_or_default()
353+
.as_deref()
354+
.and_then(Path::parent)
355+
.unwrap_or_else(|| Path::new(""))
355356
.join(file_name)
356357
} else {
357358
file_name
358359
}
359360
});
360361

361-
let (conf, errors) = utils::conf::read(file_name.as_ref().map(std::convert::AsRef::as_ref));
362+
let (conf, errors) = utils::conf::read(file_name.as_ref().map(AsRef::as_ref));
362363

363364
// all conf errors are non-fatal, we just use the default conf in case of error
364365
for error in errors {

clippy_lints/src/literal_representation.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc::{declare_lint_pass, impl_lint_pass};
88
use rustc_errors::Applicability;
99
use rustc_session::declare_tool_lint;
1010
use syntax::ast::*;
11-
use syntax_pos;
1211

1312
declare_clippy_lint! {
1413
/// **What it does:** Warns if a long integral or floating-point constant does

clippy_lints/src/multiple_crate_versions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
66
use rustc_session::declare_tool_lint;
77
use syntax::{ast::*, source_map::DUMMY_SP};
88

9-
use cargo_metadata;
109
use itertools::Itertools;
1110

1211
declare_clippy_lint! {

clippy_lints/src/regex.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::consts::{constant, Constant};
22
use crate::utils::{is_expn_of, match_def_path, match_type, paths, span_help_and_lint, span_lint};
33
use if_chain::if_chain;
4-
use regex_syntax;
54
use rustc::hir::*;
65
use rustc::impl_lint_pass;
76
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};

clippy_lints/src/utils/conf.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::io::Read;
88
use std::sync::Mutex;
99
use std::{env, fmt, fs, io, path};
1010
use syntax::{ast, source_map};
11-
use toml;
1211

1312
/// Gets the configuration file from arguments.
1413
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 {
7776
}
7877
$(
7978
mod $rust_name {
80-
use serde;
8179
use serde::Deserialize;
8280
crate fn deserialize<'de, D: serde::Deserializer<'de>>(deserializer: D)
8381
-> Result<define_Conf!(TY $($ty)+), D::Error> {

0 commit comments

Comments
 (0)