diff --git a/CHANGELOG.md b/CHANGELOG.md index e3231d9f38e..94cf6748d0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # Change Log All notable changes to this project will be documented in this file. -## 0.0.156 +## Master +* New lint: [`unit_expr`] + +## 0.0.156 - 2017-09-03 * Update to *rustc 1.22.0-nightly (744dd6c1d 2017-09-02)* ## 0.0.155 @@ -602,6 +605,7 @@ All notable changes to this project will be documented in this file. [`type_complexity`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#type_complexity [`unicode_not_nfc`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#unicode_not_nfc [`unit_cmp`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#unit_cmp +[`unit_expr`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#unit_expr [`unnecessary_cast`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#unnecessary_cast [`unnecessary_mut_passed`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#unnecessary_mut_passed [`unnecessary_operation`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#unnecessary_operation diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 5b484aceed8..95d45bed133 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -91,8 +91,8 @@ pub mod functions; pub mod identity_op; pub mod if_let_redundant_pattern_matching; pub mod if_not_else; -pub mod is_unit_expr; pub mod infinite_iter; +pub mod is_unit_expr; pub mod items_after_statements; pub mod large_enum_variant; pub mod len_zero; @@ -423,6 +423,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { identity_op::IDENTITY_OP, if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING, infinite_iter::INFINITE_ITER, + is_unit_expr::UNIT_EXPR, large_enum_variant::LARGE_ENUM_VARIANT, len_zero::LEN_WITHOUT_IS_EMPTY, len_zero::LEN_ZERO, @@ -506,7 +507,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { panic::PANIC_PARAMS, partialeq_ne_impl::PARTIALEQ_NE_IMPL, precedence::PRECEDENCE, - is_unit_expr::UNIT_EXPR, print::PRINT_WITH_NEWLINE, ptr::CMP_NULL, ptr::MUT_FROM_REF, diff --git a/tests/ui/is_unit_expr.stderr b/tests/ui/is_unit_expr.stderr index dafebb1c82a..2d9fcfff74f 100644 --- a/tests/ui/is_unit_expr.stderr +++ b/tests/ui/is_unit_expr.stderr @@ -1,52 +1,55 @@ error: This expression evaluates to the Unit type () - --> $DIR/is_unit_expr.rs:9:13 + --> $DIR/is_unit_expr.rs:8:13 | -9 | let x = { +8 | let x = { | _____________^ -10 | | "foo"; -11 | | "baz"; -12 | | }; +9 | | "foo"; +10 | | "baz"; +11 | | }; | |_____^ | = note: `-D unit-expr` implied by `-D warnings` note: Consider removing the trailing semicolon - --> $DIR/is_unit_expr.rs:11:9 + --> $DIR/is_unit_expr.rs:10:9 | -11 | "baz"; +10 | "baz"; | ^^^^^^ error: This expression evaluates to the Unit type () - --> $DIR/is_unit_expr.rs:23:13 + --> $DIR/is_unit_expr.rs:22:13 | -23 | let z = if true{ +22 | let z = if true { | _____________^ -24 | | "foo"; -25 | | } else{ -26 | | "bar"; -27 | | }; +23 | | "foo"; +24 | | } else { +25 | | "bar"; +26 | | }; | |_____^ | note: Consider removing the trailing semicolon - --> $DIR/is_unit_expr.rs:26:9 + --> $DIR/is_unit_expr.rs:25:9 | -26 | "bar"; +25 | "bar"; | ^^^^^^ error: This expression evaluates to the Unit type () - --> $DIR/is_unit_expr.rs:39:14 + --> $DIR/is_unit_expr.rs:40:14 | -39 | let a3 = match a1 { +40 | let a3 = match a1 { | ______________^ -40 | | Some(x) => {x;}, -41 | | _ => {0;}, -42 | | }; +41 | | Some(x) => { +42 | | x; +43 | | }, +... | +46 | | }, +47 | | }; | |_____^ | note: Consider removing the trailing semicolon - --> $DIR/is_unit_expr.rs:40:21 + --> $DIR/is_unit_expr.rs:42:13 | -40 | Some(x) => {x;}, - | ^^ +42 | x; + | ^^ error: aborting due to 3 previous errors