Skip to content

Commit

Permalink
Categorize the unwrap lints correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
fanzier committed Jun 12, 2018
1 parent 0c6730d commit 8682858
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions clippy_lints/src/lib.rs
Expand Up @@ -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,
]);
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/unwrap.rs
Expand Up @@ -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),
Expand All @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/checked_unwrap.rs
@@ -1,4 +1,4 @@
#![deny(unnecessary_unwrap)]
#![deny(panicking_unwrap, unnecessary_unwrap)]
#![allow(if_same_then_else)]

fn main() {
Expand Down
12 changes: 9 additions & 3 deletions tests/ui/checked_unwrap.stderr
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8682858

Please sign in to comment.