diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2024-07-12 00:00:03 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2024-07-17 14:05:49 -0400 |
| commit | e34c6dbae5768b5dce90c02465f3492376327c65 (patch) | |
| tree | 116eadb846c5d9274bf08e48bfbcda6f47a0fbd9 /clippy_lints/src/methods | |
| parent | 0ee9f44568b60aaef5d04684cb08f112edd89542 (diff) | |
Refactor for using config values:
* Construct lint passes by taking `Conf` by reference. * Use `HashSet` configs in less places * Move some `check_crate` code into the pass constructor when possible.
Diffstat (limited to 'clippy_lints/src/methods')
| -rw-r--r-- | clippy_lints/src/methods/mod.rs | 24 | ||||
| -rw-r--r-- | clippy_lints/src/methods/path_ends_with_ext.rs | 2 |
2 files changed, 10 insertions, 16 deletions
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index a846552cddf..12a3a36e8f6 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -133,6 +133,7 @@ mod zst_offset; use bind_instead_of_map::BindInsteadOfMap; use clippy_config::msrvs::{self, Msrv}; +use clippy_config::Conf; use clippy_utils::consts::{constant, Constant}; use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; use clippy_utils::macros::FormatArgsStorage; @@ -4131,27 +4132,20 @@ pub struct Methods { msrv: Msrv, allow_expect_in_tests: bool, allow_unwrap_in_tests: bool, - allowed_dotfiles: FxHashSet<String>, + allowed_dotfiles: FxHashSet<&'static str>, format_args: FormatArgsStorage, } impl Methods { - #[must_use] - pub fn new( - avoid_breaking_exported_api: bool, - msrv: Msrv, - allow_expect_in_tests: bool, - allow_unwrap_in_tests: bool, - mut allowed_dotfiles: FxHashSet<String>, - format_args: FormatArgsStorage, - ) -> Self { - allowed_dotfiles.extend(DEFAULT_ALLOWED_DOTFILES.iter().map(ToString::to_string)); + pub fn new(conf: &'static Conf, format_args: FormatArgsStorage) -> Self { + let mut allowed_dotfiles: FxHashSet<_> = conf.allowed_dotfiles.iter().map(|s| &**s).collect(); + allowed_dotfiles.extend(DEFAULT_ALLOWED_DOTFILES); Self { - avoid_breaking_exported_api, - msrv, - allow_expect_in_tests, - allow_unwrap_in_tests, + avoid_breaking_exported_api: conf.avoid_breaking_exported_api, + msrv: conf.msrv.clone(), + allow_expect_in_tests: conf.allow_expect_in_tests, + allow_unwrap_in_tests: conf.allow_unwrap_in_tests, allowed_dotfiles, format_args, } diff --git a/clippy_lints/src/methods/path_ends_with_ext.rs b/clippy_lints/src/methods/path_ends_with_ext.rs index 29f44ec2a4d..cfb823dbf5d 100644 --- a/clippy_lints/src/methods/path_ends_with_ext.rs +++ b/clippy_lints/src/methods/path_ends_with_ext.rs @@ -21,7 +21,7 @@ pub(super) fn check( path: &Expr<'_>, expr: &Expr<'_>, msrv: &Msrv, - allowed_dotfiles: &FxHashSet<String>, + allowed_dotfiles: &FxHashSet<&'static str>, ) { if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(recv).peel_refs(), sym::Path) && !path.span.from_expansion() |
