From 6161e56ea4bf3ddae8b53779fc935f70f10bc19a Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 23 Mar 2023 18:01:37 +0100 Subject: [PATCH] Fix RuleSet.remove (#3685) --- crates/ruff/src/registry/rule_set.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/ruff/src/registry/rule_set.rs b/crates/ruff/src/registry/rule_set.rs index 65e799314fe7a..8c358fa469837 100644 --- a/crates/ruff/src/registry/rule_set.rs +++ b/crates/ruff/src/registry/rule_set.rs @@ -111,7 +111,7 @@ impl RuleSet { let mut i = 0; while i < self.0.len() { - self.0[i] ^= other.0[i]; + self.0[i] &= !other.0[i]; i += 1; } @@ -362,4 +362,15 @@ mod tests { let expected_rules: Vec<_> = Rule::iter().collect(); assert_eq!(all_rules, expected_rules); } + + #[test] + fn remove_not_existing_rule_from_set() { + let mut set = RuleSet::default(); + + set.remove(Rule::AmbiguousFunctionName); + + assert!(!set.contains(Rule::AmbiguousFunctionName)); + assert!(set.is_empty()); + assert_eq!(set.into_iter().collect::>(), vec![]); + } }