Categorize the unwrap lints correctly.

This commit is contained in:
Fabian Zaiser 2018-06-08 20:38:39 +02:00
parent 0c6730d851
commit 8682858e2c
4 changed files with 13 additions and 6 deletions

View File

@ -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,
]);
}

View File

@ -161,7 +161,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
} 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 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
impl<'a> LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(UNNECESSARY_UNWRAP)
lint_array!(PANICKING_UNWRAP, UNNECESSARY_UNWRAP)
}
}

View File

@ -1,4 +1,4 @@
#![deny(unnecessary_unwrap)]
#![deny(panicking_unwrap, unnecessary_unwrap)]
#![allow(if_same_then_else)]
fn main() {

View File

@ -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