From 8682858e2cdddc483b7652f87e1eb45686b70e61 Mon Sep 17 00:00:00 2001 From: Fabian Zaiser Date: Fri, 8 Jun 2018 20:38:39 +0200 Subject: [PATCH] Categorize the unwrap lints correctly. --- clippy_lints/src/lib.rs | 1 + clippy_lints/src/unwrap.rs | 4 ++-- tests/ui/checked_unwrap.rs | 2 +- tests/ui/checked_unwrap.stderr | 12 +++++++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index e49cc0cec28..f00146ea5b8 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -926,6 +926,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { mutex_atomic::MUTEX_INTEGER, needless_borrow::NEEDLESS_BORROW, ranges::RANGE_PLUS_ONE, + unwrap::PANICKING_UNWRAP, unwrap::UNNECESSARY_UNWRAP, ]); } diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 3694c48a39f..877dc67681c 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -161,7 +161,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> { } else { span_lint_and_then( self.cx, - UNNECESSARY_UNWRAP, + PANICKING_UNWRAP, expr.span, &format!("This call to `{}()` will always panic.", method_name.name), @@ -181,7 +181,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> { impl<'a> LintPass for Pass { fn get_lints(&self) -> LintArray { - lint_array!(UNNECESSARY_UNWRAP) + lint_array!(PANICKING_UNWRAP, UNNECESSARY_UNWRAP) } } diff --git a/tests/ui/checked_unwrap.rs b/tests/ui/checked_unwrap.rs index 893e2db0433..c3d4b8de08b 100644 --- a/tests/ui/checked_unwrap.rs +++ b/tests/ui/checked_unwrap.rs @@ -1,4 +1,4 @@ -#![deny(unnecessary_unwrap)] +#![deny(panicking_unwrap, unnecessary_unwrap)] #![allow(if_same_then_else)] fn main() { diff --git a/tests/ui/checked_unwrap.stderr b/tests/ui/checked_unwrap.stderr index 28e0df8920a..1b46ceb5fa8 100644 --- a/tests/ui/checked_unwrap.stderr +++ b/tests/ui/checked_unwrap.stderr @@ -7,10 +7,10 @@ error: You checked before that `unwrap()` cannot fail. Instead of checking and u | ^^^^^^^^^^ | note: lint level defined here - --> $DIR/checked_unwrap.rs:1:9 + --> $DIR/checked_unwrap.rs:1:27 | -1 | #![deny(unnecessary_unwrap)] - | ^^^^^^^^^^^^^^^^^^ +1 | #![deny(panicking_unwrap, unnecessary_unwrap)] + | ^^^^^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:9:9 @@ -20,6 +20,12 @@ error: This call to `unwrap()` will always panic. ... 9 | x.unwrap(); // will panic | ^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/checked_unwrap.rs:1:9 + | +1 | #![deny(panicking_unwrap, unnecessary_unwrap)] + | ^^^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:12:9