Skip to content

Commit 6e6ee87

Browse files
committed
Auto merge of #4307 - flip1995:unnecessary_unwrap, r=oli-obk
Move {unnecessary,panicking}_unwrap out of nursery Resolves #2437 changelog: Move `{unnnecessary,panicking}_unwrap` out of nursery
2 parents c8e5352 + feca48d commit 6e6ee87

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

clippy_lints/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
894894
unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
895895
unused_io_amount::UNUSED_IO_AMOUNT,
896896
unused_label::UNUSED_LABEL,
897+
unwrap::PANICKING_UNWRAP,
898+
unwrap::UNNECESSARY_UNWRAP,
897899
vec::USELESS_VEC,
898900
write::PRINTLN_EMPTY_STRING,
899901
write::PRINT_LITERAL,
@@ -1060,6 +1062,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
10601062
types::UNNECESSARY_CAST,
10611063
types::VEC_BOX,
10621064
unused_label::UNUSED_LABEL,
1065+
unwrap::UNNECESSARY_UNWRAP,
10631066
zero_div_zero::ZERO_DIVIDED_BY_ZERO,
10641067
]);
10651068

@@ -1121,6 +1124,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
11211124
types::UNIT_CMP,
11221125
unicode::ZERO_WIDTH_SPACE,
11231126
unused_io_amount::UNUSED_IO_AMOUNT,
1127+
unwrap::PANICKING_UNWRAP,
11241128
]);
11251129

11261130
reg.register_lint_group("clippy::perf", Some("clippy_perf"), vec![
@@ -1157,8 +1161,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
11571161
needless_borrow::NEEDLESS_BORROW,
11581162
path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE,
11591163
redundant_clone::REDUNDANT_CLONE,
1160-
unwrap::PANICKING_UNWRAP,
1161-
unwrap::UNNECESSARY_UNWRAP,
11621164
]);
11631165
}
11641166

clippy_lints/src/unwrap.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ declare_clippy_lint! {
1414
///
1515
/// **Why is this bad?** Using `if let` or `match` is more idiomatic.
1616
///
17-
/// **Known problems:** Limitations of the borrow checker might make unwrap() necessary sometimes?
17+
/// **Known problems:** None
1818
///
1919
/// **Example:**
2020
/// ```rust
21+
/// # let option = Some(0);
22+
/// # fn do_something_with(_x: usize) {}
2123
/// if option.is_some() {
2224
/// do_something_with(option.unwrap())
2325
/// }
@@ -26,12 +28,14 @@ declare_clippy_lint! {
2628
/// Could be written:
2729
///
2830
/// ```rust
31+
/// # let option = Some(0);
32+
/// # fn do_something_with(_x: usize) {}
2933
/// if let Some(value) = option {
3034
/// do_something_with(value)
3135
/// }
3236
/// ```
3337
pub UNNECESSARY_UNWRAP,
34-
nursery,
38+
complexity,
3539
"checks for calls of unwrap[_err]() that cannot fail"
3640
}
3741

@@ -45,14 +49,16 @@ declare_clippy_lint! {
4549
///
4650
/// **Example:**
4751
/// ```rust
52+
/// # let option = Some(0);
53+
/// # fn do_something_with(_x: usize) {}
4854
/// if option.is_none() {
4955
/// do_something_with(option.unwrap())
5056
/// }
5157
/// ```
5258
///
5359
/// This code will always panic. The if condition should probably be inverted.
5460
pub PANICKING_UNWRAP,
55-
nursery,
61+
correctness,
5662
"checks for calls of unwrap[_err]() that will always fail"
5763
}
5864

src/lintlist/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ pub const ALL_LINTS: [Lint; 309] = [
13811381
},
13821382
Lint {
13831383
name: "panicking_unwrap",
1384-
group: "nursery",
1384+
group: "correctness",
13851385
desc: "checks for calls of unwrap[_err]() that will always fail",
13861386
deprecation: None,
13871387
module: "unwrap",
@@ -1927,7 +1927,7 @@ pub const ALL_LINTS: [Lint; 309] = [
19271927
},
19281928
Lint {
19291929
name: "unnecessary_unwrap",
1930-
group: "nursery",
1930+
group: "complexity",
19311931
desc: "checks for calls of unwrap[_err]() that cannot fail",
19321932
deprecation: None,
19331933
module: "unwrap",

0 commit comments

Comments
 (0)