@@ -173,18 +173,14 @@ pub mod write;
173
173
pub mod zero_div_zero;
174
174
// end lints modules, do not remove this comment, it’s used in `update_lints`
175
175
176
+ use crate :: utils:: conf:: Conf ;
177
+
176
178
mod reexport {
177
179
crate use syntax:: ast:: { Name , NodeId } ;
178
180
}
179
181
180
- pub fn register_pre_expansion_lints ( session : & rustc:: session:: Session , store : & mut rustc:: lint:: LintStore ) {
181
- store. register_pre_expansion_pass ( Some ( session) , box write:: Pass ) ;
182
- store. register_pre_expansion_pass ( Some ( session) , box redundant_field_names:: RedundantFieldNames ) ;
183
- }
184
-
185
- #[ rustfmt:: skip]
186
- pub fn register_plugins ( reg : & mut rustc_plugin:: Registry < ' _ > ) {
187
- let conf = match utils:: conf:: file_from_args ( reg. args ( ) ) {
182
+ pub fn read_conf ( reg : & rustc_plugin:: Registry < ' _ > ) -> Conf {
183
+ match utils:: conf:: file_from_args ( reg. args ( ) ) {
188
184
Ok ( file_name) => {
189
185
// if the user specified a file, it must exist, otherwise default to `clippy.toml` but
190
186
// do not require the file to exist
@@ -226,8 +222,19 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>) {
226
222
. emit ( ) ;
227
223
toml:: from_str ( "" ) . expect ( "we never error on empty config files" )
228
224
}
229
- } ;
225
+ }
226
+ }
230
227
228
+ pub fn register_pre_expansion_lints ( session : & rustc:: session:: Session , store : & mut rustc:: lint:: LintStore , conf : & Conf ) {
229
+ store. register_pre_expansion_pass ( Some ( session) , box write:: Pass ) ;
230
+ store. register_pre_expansion_pass ( Some ( session) , box redundant_field_names:: RedundantFieldNames ) ;
231
+ store. register_pre_expansion_pass ( Some ( session) , box non_expressive_names:: NonExpressiveNames {
232
+ single_char_binding_names_threshold : conf. single_char_binding_names_threshold ,
233
+ } ) ;
234
+ }
235
+
236
+ #[ rustfmt:: skip]
237
+ pub fn register_plugins ( reg : & mut rustc_plugin:: Registry < ' _ > , conf : & Conf ) {
231
238
let mut store = reg. sess . lint_store . borrow_mut ( ) ;
232
239
store. register_removed (
233
240
"should_assert_eq" ,
@@ -329,9 +336,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>) {
329
336
reg. register_late_lint_pass ( box derive:: Derive ) ;
330
337
reg. register_late_lint_pass ( box types:: CharLitAsU8 ) ;
331
338
reg. register_late_lint_pass ( box vec:: Pass ) ;
332
- reg. register_early_lint_pass ( box non_expressive_names:: NonExpressiveNames {
333
- single_char_binding_names_threshold : conf. single_char_binding_names_threshold ,
334
- } ) ;
335
339
reg. register_late_lint_pass ( box drop_forget_ref:: Pass ) ;
336
340
reg. register_late_lint_pass ( box empty_enum:: EmptyEnum ) ;
337
341
reg. register_late_lint_pass ( box types:: AbsurdExtremeComparisons ) ;
@@ -347,9 +351,9 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>) {
347
351
reg. register_late_lint_pass ( box overflow_check_conditional:: OverflowCheckConditional ) ;
348
352
reg. register_late_lint_pass ( box unused_label:: UnusedLabel ) ;
349
353
reg. register_late_lint_pass ( box new_without_default:: NewWithoutDefault ) ;
350
- reg. register_late_lint_pass ( box blacklisted_name:: BlackListedName :: new ( conf. blacklisted_names ) ) ;
354
+ reg. register_late_lint_pass ( box blacklisted_name:: BlackListedName :: new ( conf. blacklisted_names . clone ( ) ) ) ;
351
355
reg. register_late_lint_pass ( box functions:: Functions :: new ( conf. too_many_arguments_threshold ) ) ;
352
- reg. register_early_lint_pass ( box doc:: Doc :: new ( conf. doc_valid_idents ) ) ;
356
+ reg. register_early_lint_pass ( box doc:: Doc :: new ( conf. doc_valid_idents . clone ( ) ) ) ;
353
357
reg. register_late_lint_pass ( box neg_multiply:: NegMultiply ) ;
354
358
reg. register_early_lint_pass ( box unsafe_removed_from_name:: UnsafeNameRemoval ) ;
355
359
reg. register_late_lint_pass ( box mem_forget:: MemForget ) ;
0 commit comments