Fix conflicting error message warning (#2182)

This commit is contained in:
Charlie Marsh 2023-01-25 18:26:43 -05:00 committed by GitHub
parent c00b8b6d2d
commit fdccb6ec1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 12 deletions

View File

@ -243,7 +243,7 @@ impl From<&Configuration> for RuleTable {
ignore: config.unfixable.as_deref().unwrap_or_default(),
}]);
for code in validate_enabled(resolve_codes(
for code in resolve_codes(
[RuleCodeSpec {
select: config.select.as_deref().unwrap_or(defaults::PREFIXES),
ignore: config.ignore.as_deref().unwrap_or_default(),
@ -256,7 +256,7 @@ impl From<&Configuration> for RuleTable {
.zip(config.extend_ignore.iter())
.map(|(select, ignore)| RuleCodeSpec { select, ignore }),
),
)) {
) {
let fix = fixable.contains(&code);
rules.enable(code, fix);
}
@ -273,6 +273,13 @@ impl From<&Configuration> for RuleTable {
}
}
// Validate that we didn't enable any incompatible rules.
for (a, b, message) in INCOMPATIBLE_CODES {
if rules.enabled(a) && rules.enabled(b) {
warn_user_once!("{}", message);
}
}
rules
}
}
@ -364,16 +371,6 @@ fn resolve_codes<'a>(specs: impl IntoIterator<Item = RuleCodeSpec<'a>>) -> FxHas
rules
}
/// Warn if the set of enabled codes contains any incompatibilities.
fn validate_enabled(enabled: FxHashSet<Rule>) -> FxHashSet<Rule> {
for (a, b, message) in INCOMPATIBLE_CODES {
if enabled.contains(a) && enabled.contains(b) {
warn_user_once!("{}", message);
}
}
enabled
}
#[cfg(test)]
mod tests {
use rustc_hash::FxHashSet;