@@ -51,8 +51,6 @@ use rustc::session::Session;
51
51
use rustc_data_structures:: fx:: FxHashSet ;
52
52
use rustc_lint:: LintId ;
53
53
54
- use std:: path:: Path ;
55
-
56
54
/// Macro used to declare a Clippy lint.
57
55
///
58
56
/// Every lint declaration consists of 4 parts:
@@ -310,7 +308,7 @@ pub mod write;
310
308
pub mod zero_div_zero;
311
309
// end lints modules, do not remove this comment, it’s used in `update_lints`
312
310
313
- pub use crate :: utils:: conf :: Conf ;
311
+ pub use crate :: utils:: config :: Conf ;
314
312
315
313
mod reexport {
316
314
crate use syntax:: ast:: Name ;
@@ -337,42 +335,41 @@ pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, conf: &Co
337
335
338
336
#[ doc( hidden) ]
339
337
pub fn read_conf ( args : & [ syntax:: ast:: NestedMetaItem ] , sess : & Session ) -> Conf {
340
- match utils:: conf:: file_from_args ( args) {
338
+ use std:: path:: Path ;
339
+ match utils:: config:: file_from_args ( args) {
341
340
Ok ( file_name) => {
342
341
// if the user specified a file, it must exist, otherwise default to `clippy.toml` but
343
342
// do not require the file to exist
344
- let file_name = if let Some ( file_name ) = file_name {
345
- Some ( file_name)
346
- } else {
347
- match utils :: conf :: lookup_conf_file ( ) {
348
- Ok ( path ) => path ,
343
+ let file_name = match file_name {
344
+ Some ( file_name) => file_name ,
345
+ None => match utils :: config :: lookup_conf_file ( ) {
346
+ Ok ( Some ( path ) ) => path ,
347
+ Ok ( None ) => return Conf :: default ( ) ,
349
348
Err ( error) => {
350
349
sess. struct_err ( & format ! ( "error finding Clippy's configuration file: {}" , error) )
351
350
. emit ( ) ;
352
- None
351
+ return Conf :: default ( ) ;
353
352
} ,
354
- }
353
+ } ,
355
354
} ;
356
355
357
- let file_name = file_name. map ( |file_name| {
358
- if file_name. is_relative ( ) {
359
- sess. local_crate_source_file
360
- . as_deref ( )
361
- . and_then ( Path :: parent)
362
- . unwrap_or_else ( || Path :: new ( "" ) )
363
- . join ( file_name)
364
- } else {
365
- file_name
366
- }
367
- } ) ;
356
+ let file_name = if file_name. is_relative ( ) {
357
+ sess. local_crate_source_file
358
+ . as_deref ( )
359
+ . and_then ( Path :: parent)
360
+ . unwrap_or_else ( || Path :: new ( "" ) )
361
+ . join ( file_name)
362
+ } else {
363
+ file_name
364
+ } ;
368
365
369
- let ( conf, errors) = utils:: conf :: read ( file_name. as_ref ( ) . map ( AsRef :: as_ref ) ) ;
366
+ let ( conf, errors) = utils:: config :: read ( & file_name) ;
370
367
371
368
// all conf errors are non-fatal, we just use the default conf in case of error
372
369
for error in errors {
373
370
sess. struct_err ( & format ! (
374
371
"error reading Clippy's configuration file `{}`: {}" ,
375
- file_name. as_ref ( ) . and_then ( |p| p . to_str ( ) ) . unwrap_or ( "" ) ,
372
+ file_name. display ( ) ,
376
373
error
377
374
) )
378
375
. emit ( ) ;
0 commit comments