about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Krones <hello@philkrones.com>2020-04-08 15:50:16 +0200
committerGitHub <noreply@github.com>2020-04-08 15:50:16 +0200
commit935b45db61e9906c8371718af3fca101dc3ce376 (patch)
tree61c1f691821dbc9518d25fd18d55f2a78d391810
parent46337cb6a8bfe37474f4b7ef7bd0a99b36ce0b80 (diff)
parentadcaa1b86ddbf51659d5f7e4e7471427682649ba (diff)
downloadrust-935b45db61e9906c8371718af3fca101dc3ce376.tar.gz
rust-935b45db61e9906c8371718af3fca101dc3ce376.zip
Rollup merge of #5409 - dtolnay:letunit, r=flip1995
Downgrade let_unit_value to pedantic

Given that the false positive in #1502 is marked E-hard and I don't have much hope of it getting fixed, I think it would be wise to disable this lint by default. I have had to suppress this lint in every substantial codebase (\>100k line) I have worked in. Any time this lint is being triggered, it's always the false positive case.

The motivation for this lint is documented as:

> A unit value cannot usefully be used anywhere. So binding one is kind of pointless.

with this example:

> ```rust
> let x = {
>     1;
> };
> ```

Sure, but the author would find this out via an unused_variable warning or from `x` not being the type that they need further down. If there ends up being a type error on `x`, clippy's advice isn't going to help get the code compiling because it can only run if the code already compiles.

changelog: Remove let_unit_value from default set of enabled lints
-rw-r--r--clippy_lints/src/lib.rs3
-rw-r--r--clippy_lints/src/types.rs2
-rw-r--r--src/lintlist/mod.rs2
-rw-r--r--tests/ui/doc_unsafe.rs1
-rw-r--r--tests/ui/redundant_pattern_matching.fixed2
-rw-r--r--tests/ui/redundant_pattern_matching.rs2
-rw-r--r--tests/ui/uninit.rs1
-rw-r--r--tests/ui/uninit.stderr4
8 files changed, 7 insertions, 10 deletions
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index b24110fc184..c1b629305f9 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -1131,6 +1131,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
         LintId::of(&types::CAST_PRECISION_LOSS),
         LintId::of(&types::CAST_SIGN_LOSS),
         LintId::of(&types::INVALID_UPCAST_COMPARISONS),
+        LintId::of(&types::LET_UNIT_VALUE),
         LintId::of(&types::LINKEDLIST),
         LintId::of(&types::OPTION_OPTION),
         LintId::of(&unicode::NON_ASCII_LITERAL),
@@ -1382,7 +1383,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
         LintId::of(&types::FN_TO_NUMERIC_CAST),
         LintId::of(&types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION),
         LintId::of(&types::IMPLICIT_HASHER),
-        LintId::of(&types::LET_UNIT_VALUE),
         LintId::of(&types::REDUNDANT_ALLOCATION),
         LintId::of(&types::TYPE_COMPLEXITY),
         LintId::of(&types::UNIT_ARG),
@@ -1495,7 +1495,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
         LintId::of(&types::FN_TO_NUMERIC_CAST),
         LintId::of(&types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION),
         LintId::of(&types::IMPLICIT_HASHER),
-        LintId::of(&types::LET_UNIT_VALUE),
         LintId::of(&unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME),
         LintId::of(&write::PRINTLN_EMPTY_STRING),
         LintId::of(&write::PRINT_LITERAL),
diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs
index 732725e1794..e2b16079f8f 100644
--- a/clippy_lints/src/types.rs
+++ b/clippy_lints/src/types.rs
@@ -593,7 +593,7 @@ declare_clippy_lint! {
     /// };
     /// ```
     pub LET_UNIT_VALUE,
-    style,
+    pedantic,
     "creating a `let` binding to a value of unit type, which usually can't be used afterwards"
 }
 
diff --git a/src/lintlist/mod.rs b/src/lintlist/mod.rs
index 0e5757fe588..0ecccd33962 100644
--- a/src/lintlist/mod.rs
+++ b/src/lintlist/mod.rs
@@ -999,7 +999,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
     },
     Lint {
         name: "let_unit_value",
-        group: "style",
+        group: "pedantic",
         desc: "creating a `let` binding to a value of unit type, which usually can\'t be used afterwards",
         deprecation: None,
         module: "types",
diff --git a/tests/ui/doc_unsafe.rs b/tests/ui/doc_unsafe.rs
index c44f3c62a98..484aa72d59a 100644
--- a/tests/ui/doc_unsafe.rs
+++ b/tests/ui/doc_unsafe.rs
@@ -88,7 +88,6 @@ very_unsafe!();
 // we don't lint code from external macros
 undocd_unsafe!();
 
-#[allow(clippy::let_unit_value)]
 fn main() {
     unsafe {
         you_dont_see_me();
diff --git a/tests/ui/redundant_pattern_matching.fixed b/tests/ui/redundant_pattern_matching.fixed
index 776c9444566..538fa1ed9cb 100644
--- a/tests/ui/redundant_pattern_matching.fixed
+++ b/tests/ui/redundant_pattern_matching.fixed
@@ -2,7 +2,7 @@
 
 #![warn(clippy::all)]
 #![warn(clippy::redundant_pattern_matching)]
-#![allow(clippy::unit_arg, clippy::let_unit_value, unused_must_use)]
+#![allow(clippy::unit_arg, unused_must_use)]
 
 fn main() {
     Ok::<i32, i32>(42).is_ok();
diff --git a/tests/ui/redundant_pattern_matching.rs b/tests/ui/redundant_pattern_matching.rs
index 2b2d5b1c1ec..34d2cd62e54 100644
--- a/tests/ui/redundant_pattern_matching.rs
+++ b/tests/ui/redundant_pattern_matching.rs
@@ -2,7 +2,7 @@
 
 #![warn(clippy::all)]
 #![warn(clippy::redundant_pattern_matching)]
-#![allow(clippy::unit_arg, clippy::let_unit_value, unused_must_use)]
+#![allow(clippy::unit_arg, unused_must_use)]
 
 fn main() {
     if let Ok(_) = Ok::<i32, i32>(42) {}
diff --git a/tests/ui/uninit.rs b/tests/ui/uninit.rs
index a4424c490e7..f42b884e0f0 100644
--- a/tests/ui/uninit.rs
+++ b/tests/ui/uninit.rs
@@ -2,7 +2,6 @@
 
 use std::mem::MaybeUninit;
 
-#[allow(clippy::let_unit_value)]
 fn main() {
     let _: usize = unsafe { MaybeUninit::uninit().assume_init() };
 
diff --git a/tests/ui/uninit.stderr b/tests/ui/uninit.stderr
index f4c45354aef..a37233ecdda 100644
--- a/tests/ui/uninit.stderr
+++ b/tests/ui/uninit.stderr
@@ -1,5 +1,5 @@
 error: this call for this type may be undefined behavior
-  --> $DIR/uninit.rs:7:29
+  --> $DIR/uninit.rs:6:29
    |
 LL |     let _: usize = unsafe { MaybeUninit::uninit().assume_init() };
    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -7,7 +7,7 @@ LL |     let _: usize = unsafe { MaybeUninit::uninit().assume_init() };
    = note: `#[deny(clippy::uninit_assumed_init)]` on by default
 
 error: this call for this type may be undefined behavior
-  --> $DIR/uninit.rs:10:31
+  --> $DIR/uninit.rs:9:31
    |
 LL |     let _: [u8; 0] = unsafe { MaybeUninit::uninit().assume_init() };
    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^