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