From 00081be73d2ba5203a2317708d912d497e2e3b0c Mon Sep 17 00:00:00 2001 From: sinkuu Date: Tue, 7 Nov 2017 06:32:12 +0900 Subject: [PATCH 1/2] Rustup --- clippy_lints/src/strings.rs | 1 - tests/ui/unicode.stderr | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 17514d9d658..b7c671c0c48 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -144,7 +144,6 @@ impl LintPass for StringLitAsBytes { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { - use std::ascii::AsciiExt; use syntax::ast::LitKind; use utils::{in_macro, snippet}; diff --git a/tests/ui/unicode.stderr b/tests/ui/unicode.stderr index 73599235ea8..870a12ee4c4 100644 --- a/tests/ui/unicode.stderr +++ b/tests/ui/unicode.stderr @@ -2,7 +2,7 @@ error: zero-width space detected --> $DIR/unicode.rs:6:12 | 6 | print!("Here >​< is a ZWS, and ​another"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D zero-width-space` implied by `-D warnings` = help: Consider replacing the string with: @@ -12,7 +12,7 @@ error: non-nfc unicode sequence detected --> $DIR/unicode.rs:12:12 | 12 | print!("̀àh?"); - | ^^^^^^^ + | ^^^^^ | = note: `-D unicode-not-nfc` implied by `-D warnings` = help: Consider replacing the string with: From 6fb736bd42d487947d97a477e95b0b3f1ab7c8a6 Mon Sep 17 00:00:00 2001 From: sinkuu Date: Tue, 7 Nov 2017 06:33:25 +0900 Subject: [PATCH 2/2] Fix false positive in needless_pass_by_value trait methods --- clippy_lints/src/needless_pass_by_value.rs | 4 +++- tests/ui/needless_pass_by_value.rs | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 81edd58af57..c7410d29df4 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -87,7 +87,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { // Exclude non-inherent impls if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) { - if matches!(item.node, ItemImpl(_, _, _, _, Some(_), _, _) | ItemAutoImpl(..)) { + if matches!(item.node, ItemImpl(_, _, _, _, Some(_), _, _) | ItemAutoImpl(..) | + ItemTrait(..)) + { return; } } diff --git a/tests/ui/needless_pass_by_value.rs b/tests/ui/needless_pass_by_value.rs index f4d490b214f..84c7e832951 100644 --- a/tests/ui/needless_pass_by_value.rs +++ b/tests/ui/needless_pass_by_value.rs @@ -103,4 +103,11 @@ impl S { } } +trait FalsePositive { + fn visit_str(s: &str); + fn visit_string(s: String) { + Self::visit_str(&s); + } +} + fn main() {}