@@ -51,8 +51,6 @@ use rustc::session::Session;
5151use rustc_data_structures:: fx:: FxHashSet ;
5252use rustc_lint:: LintId ;
5353
54- use std:: path:: Path ;
55-
5654/// Macro used to declare a Clippy lint.
5755///
5856/// Every lint declaration consists of 4 parts:
@@ -310,7 +308,7 @@ pub mod write;
310308pub mod zero_div_zero;
311309// end lints modules, do not remove this comment, it’s used in `update_lints`
312310
313- pub use crate :: utils:: conf :: Conf ;
311+ pub use crate :: utils:: config :: Conf ;
314312
315313mod reexport {
316314 crate use syntax:: ast:: Name ;
@@ -337,42 +335,41 @@ pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, conf: &Co
337335
338336#[ doc( hidden) ]
339337pub 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) {
341340 Ok ( file_name) => {
342341 // if the user specified a file, it must exist, otherwise default to `clippy.toml` but
343342 // 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 ( ) ,
349348 Err ( error) => {
350349 sess. struct_err ( & format ! ( "error finding Clippy's configuration file: {}" , error) )
351350 . emit ( ) ;
352- None
351+ return Conf :: default ( ) ;
353352 } ,
354- }
353+ } ,
355354 } ;
356355
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+ } ;
368365
369- let ( conf, errors) = utils:: conf :: read ( file_name. as_ref ( ) . map ( AsRef :: as_ref ) ) ;
366+ let ( conf, errors) = utils:: config :: read ( & file_name) ;
370367
371368 // all conf errors are non-fatal, we just use the default conf in case of error
372369 for error in errors {
373370 sess. struct_err ( & format ! (
374371 "error reading Clippy's configuration file `{}`: {}" ,
375- file_name. as_ref ( ) . and_then ( |p| p . to_str ( ) ) . unwrap_or ( "" ) ,
372+ file_name. display ( ) ,
376373 error
377374 ) )
378375 . emit ( ) ;
0 commit comments