From e4be2b4e6411d1b144305adab6b8874d7d3448d9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 21 Nov 2018 01:58:27 -0800 Subject: [PATCH] Downgrade needless_pass_by_value to allow by default I noticed that I suppress this lint in many of my projects. https://github.com/search?q=needless_pass_by_value+user%3Adtolnay&type=Code https://github.com/search?q=needless_pass_by_value+user%3Aserde-rs&type=Code Upon further inspection, this lint has a *long* history of false positives (and several remaining). Generally I feel that this lint is the definition of pedantic and should not be linted by default. #[derive(Debug)] enum How { ThisWay, ThatWay, } // Are we really better off forcing the call sites to write f(&_)...? fn f(how: How) { println!("You want to do it {:?}", how); } fn main() { f(How::ThatWay); } --- clippy_lints/src/lib.rs | 3 +-- clippy_lints/src/needless_pass_by_value.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 3debe567cda1..2dbe448c950a 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -509,6 +509,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { misc_early::UNSEPARATED_LITERAL_SUFFIX, mut_mut::MUT_MUT, needless_continue::NEEDLESS_CONTINUE, + needless_pass_by_value::NEEDLESS_PASS_BY_VALUE, non_expressive_names::SIMILAR_NAMES, replace_consts::REPLACE_CONSTS, shadow::SHADOW_UNRELATED, @@ -671,7 +672,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { needless_bool::BOOL_COMPARISON, needless_bool::NEEDLESS_BOOL, needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE, - needless_pass_by_value::NEEDLESS_PASS_BY_VALUE, needless_update::NEEDLESS_UPDATE, neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD, neg_multiply::NEG_MULTIPLY, @@ -809,7 +809,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { misc_early::MIXED_CASE_HEX_LITERALS, misc_early::UNNEEDED_FIELD_PATTERN, mut_reference::UNNECESSARY_MUT_PASSED, - needless_pass_by_value::NEEDLESS_PASS_BY_VALUE, neg_multiply::NEG_MULTIPLY, new_without_default::NEW_WITHOUT_DEFAULT, new_without_default::NEW_WITHOUT_DEFAULT_DERIVE, diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index d4257fd1aa95..ff8e0cc0e6ec 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -54,7 +54,7 @@ use crate::rustc_errors::Applicability; /// ``` declare_clippy_lint! { pub NEEDLESS_PASS_BY_VALUE, - style, + pedantic, "functions taking arguments by value, but not consuming them in its body" }