Remove HashSets from Conf

This commit is contained in:
Alex Macleod 2024-08-12 16:25:14 +00:00
parent 182cd5f278
commit a22ce2d005
8 changed files with 25 additions and 27 deletions

View file

@ -205,7 +205,7 @@ declare_clippy_lint! {
}
pub struct Cargo {
allowed_duplicate_crates: &'static FxHashSet<String>,
allowed_duplicate_crates: FxHashSet<String>,
ignore_publish: bool,
}
@ -221,7 +221,7 @@ impl_lint_pass!(Cargo => [
impl Cargo {
pub fn new(conf: &'static Conf) -> Self {
Self {
allowed_duplicate_crates: &conf.allowed_duplicate_crates,
allowed_duplicate_crates: conf.allowed_duplicate_crates.iter().cloned().collect(),
ignore_publish: conf.cargo_ignore_publish,
}
}
@ -263,7 +263,7 @@ impl LateLintPass<'_> for Cargo {
{
match MetadataCommand::new().exec() {
Ok(metadata) => {
multiple_crate_versions::check(cx, &metadata, self.allowed_duplicate_crates);
multiple_crate_versions::check(cx, &metadata, &self.allowed_duplicate_crates);
},
Err(e) => {
for lint in WITH_DEPS_LINTS {

View file

@ -423,14 +423,14 @@ declare_clippy_lint! {
}
pub struct Documentation {
valid_idents: &'static FxHashSet<String>,
valid_idents: FxHashSet<String>,
check_private_items: bool,
}
impl Documentation {
pub fn new(conf: &'static Conf) -> Self {
Self {
valid_idents: &conf.doc_valid_idents,
valid_idents: conf.doc_valid_idents.iter().cloned().collect(),
check_private_items: conf.check_private_items,
}
}
@ -452,7 +452,7 @@ impl_lint_pass!(Documentation => [
impl<'tcx> LateLintPass<'tcx> for Documentation {
fn check_attributes(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
let Some(headers) = check_attrs(cx, self.valid_idents, attrs) else {
let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else {
return;
};

View file

@ -41,14 +41,14 @@ declare_clippy_lint! {
impl_lint_pass!(MinIdentChars => [MIN_IDENT_CHARS]);
pub struct MinIdentChars {
allowed_idents_below_min_chars: &'static FxHashSet<String>,
allowed_idents_below_min_chars: FxHashSet<String>,
min_ident_chars_threshold: u64,
}
impl MinIdentChars {
pub fn new(conf: &'static Conf) -> Self {
Self {
allowed_idents_below_min_chars: &conf.allowed_idents_below_min_chars,
allowed_idents_below_min_chars: conf.allowed_idents_below_min_chars.iter().cloned().collect(),
min_ident_chars_threshold: conf.min_ident_chars_threshold,
}
}

View file

@ -35,7 +35,7 @@ impl ArithmeticSideEffects {
("f64", FxHashSet::from_iter(["f64"])),
("std::string::String", FxHashSet::from_iter(["str"])),
]);
for [lhs, rhs] in &conf.arithmetic_side_effects_allowed_binary {
for (lhs, rhs) in &conf.arithmetic_side_effects_allowed_binary {
allowed_binary.entry(lhs).or_default().insert(rhs);
}
for s in &conf.arithmetic_side_effects_allowed {

View file

@ -100,14 +100,14 @@ declare_clippy_lint! {
pub struct WildcardImports {
warn_on_all: bool,
allowed_segments: &'static FxHashSet<String>,
allowed_segments: FxHashSet<String>,
}
impl WildcardImports {
pub fn new(conf: &'static Conf) -> Self {
Self {
warn_on_all: conf.warn_on_all_wildcard_imports,
allowed_segments: &conf.allowed_wildcard_imports,
allowed_segments: conf.allowed_wildcard_imports.iter().cloned().collect(),
}
}
}
@ -181,7 +181,7 @@ impl WildcardImports {
fn check_exceptions(&self, cx: &LateContext<'_>, item: &Item<'_>, segments: &[PathSegment<'_>]) -> bool {
item.span.from_expansion()
|| is_prelude_import(segments)
|| is_allowed_via_config(segments, self.allowed_segments)
|| is_allowed_via_config(segments, &self.allowed_segments)
|| (is_super_only_import(segments) && is_in_test(cx.tcx, item.hir_id()))
}
}