Skip to content

Commit 6c75a5b

Browse files
Centri3Catherine
authored and
Catherine
committed
Don't lint if local came from an or pattern
also make sure they have the same type
1 parent 1e4d7de commit 6c75a5b

14 files changed

+421
-317
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5185,7 +5185,7 @@ Released 2018-09-13
51855185
[`redundant_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_else
51865186
[`redundant_feature_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_feature_names
51875187
[`redundant_field_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
5188-
[`redundant_guard`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_guard
5188+
[`redundant_guards`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_guards
51895189
[`redundant_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern
51905190
[`redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
51915191
[`redundant_pub_crate`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pub_crate

clippy_lints/src/declared_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
306306
crate::matches::MATCH_WILDCARD_FOR_SINGLE_VARIANTS_INFO,
307307
crate::matches::MATCH_WILD_ERR_ARM_INFO,
308308
crate::matches::NEEDLESS_MATCH_INFO,
309-
crate::matches::REDUNDANT_GUARD_INFO,
309+
crate::matches::REDUNDANT_GUARDS_INFO,
310310
crate::matches::REDUNDANT_PATTERN_MATCHING_INFO,
311311
crate::matches::REST_PAT_IN_FULLY_BOUND_STRUCTS_INFO,
312312
crate::matches::SIGNIFICANT_DROP_IN_SCRUTINEE_INFO,

clippy_lints/src/matches/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mod match_wild_enum;
1616
mod match_wild_err_arm;
1717
mod needless_match;
1818
mod overlapping_arms;
19-
mod redundant_guard;
19+
mod redundant_guards;
2020
mod redundant_pattern_match;
2121
mod rest_pat_in_fully_bound_struct;
2222
mod significant_drop_in_scrutinee;
@@ -942,7 +942,8 @@ declare_clippy_lint! {
942942
/// Checks for unnecessary guards in match expressions.
943943
///
944944
/// ### Why is this bad?
945-
/// It's more complex and much less readable.
945+
/// It's more complex and much less readable. Making it part of the pattern can improve
946+
/// exhaustiveness checking as well.
946947
///
947948
/// ### Example
948949
/// ```rust,ignore
@@ -961,7 +962,7 @@ declare_clippy_lint! {
961962
/// }
962963
/// ```
963964
#[clippy::version = "1.72.0"]
964-
pub REDUNDANT_GUARD,
965+
pub REDUNDANT_GUARDS,
965966
complexity,
966967
"checks for unnecessary guards in match expressions"
967968
}
@@ -1008,7 +1009,7 @@ impl_lint_pass!(Matches => [
10081009
TRY_ERR,
10091010
MANUAL_MAP,
10101011
MANUAL_FILTER,
1011-
REDUNDANT_GUARD,
1012+
REDUNDANT_GUARDS,
10121013
]);
10131014

10141015
impl<'tcx> LateLintPass<'tcx> for Matches {
@@ -1056,7 +1057,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
10561057
needless_match::check_match(cx, ex, arms, expr);
10571058
match_on_vec_items::check(cx, ex);
10581059
match_str_case_mismatch::check(cx, ex, arms);
1059-
redundant_guard::check(cx, arms);
1060+
redundant_guards::check(cx, arms);
10601061

10611062
if !in_constant(cx, expr.hir_id) {
10621063
manual_unwrap_or::check(cx, expr, ex, arms);

clippy_lints/src/matches/redundant_guard.rs

-249
This file was deleted.

0 commit comments

Comments
 (0)