Skip to content

Commit 8682858

Browse files
committed
Categorize the unwrap lints correctly.
1 parent 0c6730d commit 8682858

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

clippy_lints/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
926926
mutex_atomic::MUTEX_INTEGER,
927927
needless_borrow::NEEDLESS_BORROW,
928928
ranges::RANGE_PLUS_ONE,
929+
unwrap::PANICKING_UNWRAP,
929930
unwrap::UNNECESSARY_UNWRAP,
930931
]);
931932
}

clippy_lints/src/unwrap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> {
161161
} else {
162162
span_lint_and_then(
163163
self.cx,
164-
UNNECESSARY_UNWRAP,
164+
PANICKING_UNWRAP,
165165
expr.span,
166166
&format!("This call to `{}()` will always panic.",
167167
method_name.name),
@@ -181,7 +181,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> {
181181

182182
impl<'a> LintPass for Pass {
183183
fn get_lints(&self) -> LintArray {
184-
lint_array!(UNNECESSARY_UNWRAP)
184+
lint_array!(PANICKING_UNWRAP, UNNECESSARY_UNWRAP)
185185
}
186186
}
187187

tests/ui/checked_unwrap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unnecessary_unwrap)]
1+
#![deny(panicking_unwrap, unnecessary_unwrap)]
22
#![allow(if_same_then_else)]
33

44
fn main() {

tests/ui/checked_unwrap.stderr

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ error: You checked before that `unwrap()` cannot fail. Instead of checking and u
77
| ^^^^^^^^^^
88
|
99
note: lint level defined here
10-
--> $DIR/checked_unwrap.rs:1:9
10+
--> $DIR/checked_unwrap.rs:1:27
1111
|
12-
1 | #![deny(unnecessary_unwrap)]
13-
| ^^^^^^^^^^^^^^^^^^
12+
1 | #![deny(panicking_unwrap, unnecessary_unwrap)]
13+
| ^^^^^^^^^^^^^^^^^^
1414

1515
error: This call to `unwrap()` will always panic.
1616
--> $DIR/checked_unwrap.rs:9:9
@@ -20,6 +20,12 @@ error: This call to `unwrap()` will always panic.
2020
...
2121
9 | x.unwrap(); // will panic
2222
| ^^^^^^^^^^
23+
|
24+
note: lint level defined here
25+
--> $DIR/checked_unwrap.rs:1:9
26+
|
27+
1 | #![deny(panicking_unwrap, unnecessary_unwrap)]
28+
| ^^^^^^^^^^^^^^^^
2329

2430
error: This call to `unwrap()` will always panic.
2531
--> $DIR/checked_unwrap.rs:12:9

0 commit comments

Comments
 (0)