Make lint groups work correctly with warningsAsInfo and warningsAsHint

This commit is contained in:
Emil Gardström 2021-11-22 14:14:21 +01:00
parent b69eee6487
commit 3dc898389f
No known key found for this signature in database
GPG key ID: 08AABB4F80C3FAC6
4 changed files with 1042 additions and 94 deletions

View file

@ -282,3 +282,21 @@ pub fn for_each_break_expr(
}
}
}
/// Checks if the given lint is equal or is contained by the other lint which may or may not be a group.
pub fn lint_eq_or_in_group(lint: &str, lint_is: &str) -> bool {
if lint == lint_is {
return true;
}
if let Some(group) = generated_lints::DEFAULT_LINT_GROUPS
.iter()
.chain(generated_lints::CLIPPY_LINT_GROUPS.iter())
.chain(generated_lints::RUSTDOC_LINT_GROUPS.iter())
.find(|&check| check.lint.label == lint_is)
{
group.children.contains(&lint)
} else {
false
}
}