Skip to content

Commit 0f7cbf4

Browse files
committed
Move unintentional_unit_return from nursery to correctness
Also rewrites the description to be clearer
1 parent e9ebc00 commit 0f7cbf4

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

clippy_lints/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
14261426
LintId::of(&types::UNNECESSARY_CAST),
14271427
LintId::of(&types::VEC_BOX),
14281428
LintId::of(&unicode::ZERO_WIDTH_SPACE),
1429+
LintId::of(&unintentional_unit_return::UNINTENTIONAL_UNIT_RETURN),
14291430
LintId::of(&unnamed_address::FN_ADDRESS_COMPARISONS),
14301431
LintId::of(&unnamed_address::VTABLE_ADDRESS_COMPARISONS),
14311432
LintId::of(&unnecessary_sort_by::UNNECESSARY_SORT_BY),
@@ -1681,6 +1682,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
16811682
LintId::of(&types::CAST_REF_TO_MUT),
16821683
LintId::of(&types::UNIT_CMP),
16831684
LintId::of(&unicode::ZERO_WIDTH_SPACE),
1685+
LintId::of(&unintentional_unit_return::UNINTENTIONAL_UNIT_RETURN),
16841686
LintId::of(&unnamed_address::FN_ADDRESS_COMPARISONS),
16851687
LintId::of(&unnamed_address::VTABLE_ADDRESS_COMPARISONS),
16861688
LintId::of(&unused_io_amount::UNUSED_IO_AMOUNT),
@@ -1730,7 +1732,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
17301732
LintId::of(&path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE),
17311733
LintId::of(&redundant_pub_crate::REDUNDANT_PUB_CRATE),
17321734
LintId::of(&transmute::USELESS_TRANSMUTE),
1733-
LintId::of(&unintentional_unit_return::UNINTENTIONAL_UNIT_RETURN),
17341735
LintId::of(&use_self::USE_SELF),
17351736
]);
17361737
}

clippy_lints/src/unintentional_unit_return.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ use rustc_span::{BytePos, Span};
1010

1111
declare_clippy_lint! {
1212
/// **What it does:** Checks for functions that expect closures of type
13-
/// Fn(...) -> Ord where the implemented closure has a semi-colon
14-
/// at the end of the last statement.
13+
/// Fn(...) -> Ord where the implemented closure returns the unit type.
14+
/// The lint also suggests to remove the semi-colon at the end of the statement if present.
1515
///
16-
/// **Why is this bad?** Likely the semi-colon is unintentional which
17-
/// returns () instead of the result of last statement. Since () implements Ord
18-
/// it doesn't cause a compilation error
16+
/// **Why is this bad?** Likely, returning the unit type is unintentional, and
17+
/// could simply be caused by an extra semi-colon. Since () implements Ord
18+
/// it doesn't cause a compilation error.
19+
/// This is the same reasoning behind the unit_cmp lint.
1920
///
2021
/// **Known problems:** If returning unit is intentional, then there is no
2122
/// way of specifying this without triggering needless_return lint
@@ -27,8 +28,8 @@ declare_clippy_lint! {
2728
/// twins.sort_by_key(|x| { x.1; });
2829
/// ```
2930
pub UNINTENTIONAL_UNIT_RETURN,
30-
nursery,
31-
"fn arguments of type Fn(...) -> Once having last statements with a semi-colon, suggesting to remove the semi-colon if it is unintentional."
31+
correctness,
32+
"fn arguments of type Fn(...) -> Ord returning the unit type ()."
3233
}
3334

3435
declare_lint_pass!(UnintentionalUnitReturn => [UNINTENTIONAL_UNIT_RETURN]);

src/lintlist/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,8 +2252,8 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
22522252
},
22532253
Lint {
22542254
name: "unintentional_unit_return",
2255-
group: "nursery",
2256-
desc: "fn arguments of type Fn(...) -> Once having last statements with a semi-colon, suggesting to remove the semi-colon if it is unintentional.",
2255+
group: "correctness",
2256+
desc: "fn arguments of type Fn(...) -> Ord returning the unit type ().",
22572257
deprecation: None,
22582258
module: "unintentional_unit_return",
22592259
},

0 commit comments

Comments
 (0)