Skip to content

Commit

Permalink
Move unintentional_unit_return from nursery to correctness
Browse files Browse the repository at this point in the history
Also rewrites the description to be clearer
  • Loading branch information
Uriopass committed Jul 13, 2020
1 parent e9ebc00 commit 0f7cbf4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&types::UNNECESSARY_CAST),
LintId::of(&types::VEC_BOX),
LintId::of(&unicode::ZERO_WIDTH_SPACE),
LintId::of(&unintentional_unit_return::UNINTENTIONAL_UNIT_RETURN),
LintId::of(&unnamed_address::FN_ADDRESS_COMPARISONS),
LintId::of(&unnamed_address::VTABLE_ADDRESS_COMPARISONS),
LintId::of(&unnecessary_sort_by::UNNECESSARY_SORT_BY),
Expand Down Expand Up @@ -1681,6 +1682,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&types::CAST_REF_TO_MUT),
LintId::of(&types::UNIT_CMP),
LintId::of(&unicode::ZERO_WIDTH_SPACE),
LintId::of(&unintentional_unit_return::UNINTENTIONAL_UNIT_RETURN),
LintId::of(&unnamed_address::FN_ADDRESS_COMPARISONS),
LintId::of(&unnamed_address::VTABLE_ADDRESS_COMPARISONS),
LintId::of(&unused_io_amount::UNUSED_IO_AMOUNT),
Expand Down Expand Up @@ -1730,7 +1732,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE),
LintId::of(&redundant_pub_crate::REDUNDANT_PUB_CRATE),
LintId::of(&transmute::USELESS_TRANSMUTE),
LintId::of(&unintentional_unit_return::UNINTENTIONAL_UNIT_RETURN),
LintId::of(&use_self::USE_SELF),
]);
}
Expand Down
15 changes: 8 additions & 7 deletions clippy_lints/src/unintentional_unit_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ use rustc_span::{BytePos, Span};

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

declare_lint_pass!(UnintentionalUnitReturn => [UNINTENTIONAL_UNIT_RETURN]);
Expand Down
4 changes: 2 additions & 2 deletions src/lintlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2252,8 +2252,8 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
},
Lint {
name: "unintentional_unit_return",
group: "nursery",
desc: "fn arguments of type Fn(...) -> Once having last statements with a semi-colon, suggesting to remove the semi-colon if it is unintentional.",
group: "correctness",
desc: "fn arguments of type Fn(...) -> Ord returning the unit type ().",
deprecation: None,
module: "unintentional_unit_return",
},
Expand Down

0 comments on commit 0f7cbf4

Please sign in to comment.