Skip to content

Commit

Permalink
Don't lint if local came from an or pattern
Browse files Browse the repository at this point in the history
also make sure they have the same type
  • Loading branch information
Centri3 authored and Catherine committed Jul 18, 2023
1 parent 1e4d7de commit 6c75a5b
Show file tree
Hide file tree
Showing 14 changed files with 421 additions and 317 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5185,7 +5185,7 @@ Released 2018-09-13
[`redundant_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_else
[`redundant_feature_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_feature_names
[`redundant_field_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
[`redundant_guard`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_guard
[`redundant_guards`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_guards
[`redundant_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern
[`redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
[`redundant_pub_crate`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pub_crate
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::matches::MATCH_WILDCARD_FOR_SINGLE_VARIANTS_INFO,
crate::matches::MATCH_WILD_ERR_ARM_INFO,
crate::matches::NEEDLESS_MATCH_INFO,
crate::matches::REDUNDANT_GUARD_INFO,
crate::matches::REDUNDANT_GUARDS_INFO,
crate::matches::REDUNDANT_PATTERN_MATCHING_INFO,
crate::matches::REST_PAT_IN_FULLY_BOUND_STRUCTS_INFO,
crate::matches::SIGNIFICANT_DROP_IN_SCRUTINEE_INFO,
Expand Down
11 changes: 6 additions & 5 deletions clippy_lints/src/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod match_wild_enum;
mod match_wild_err_arm;
mod needless_match;
mod overlapping_arms;
mod redundant_guard;
mod redundant_guards;
mod redundant_pattern_match;
mod rest_pat_in_fully_bound_struct;
mod significant_drop_in_scrutinee;
Expand Down Expand Up @@ -942,7 +942,8 @@ declare_clippy_lint! {
/// Checks for unnecessary guards in match expressions.
///
/// ### Why is this bad?
/// It's more complex and much less readable.
/// It's more complex and much less readable. Making it part of the pattern can improve
/// exhaustiveness checking as well.
///
/// ### Example
/// ```rust,ignore
Expand All @@ -961,7 +962,7 @@ declare_clippy_lint! {
/// }
/// ```
#[clippy::version = "1.72.0"]
pub REDUNDANT_GUARD,
pub REDUNDANT_GUARDS,
complexity,
"checks for unnecessary guards in match expressions"
}
Expand Down Expand Up @@ -1008,7 +1009,7 @@ impl_lint_pass!(Matches => [
TRY_ERR,
MANUAL_MAP,
MANUAL_FILTER,
REDUNDANT_GUARD,
REDUNDANT_GUARDS,
]);

impl<'tcx> LateLintPass<'tcx> for Matches {
Expand Down Expand Up @@ -1056,7 +1057,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
needless_match::check_match(cx, ex, arms, expr);
match_on_vec_items::check(cx, ex);
match_str_case_mismatch::check(cx, ex, arms);
redundant_guard::check(cx, arms);
redundant_guards::check(cx, arms);

if !in_constant(cx, expr.hir_id) {
manual_unwrap_or::check(cx, expr, ex, arms);
Expand Down
249 changes: 0 additions & 249 deletions clippy_lints/src/matches/redundant_guard.rs

This file was deleted.

Loading

0 comments on commit 6c75a5b

Please sign in to comment.