This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -322,18 +322,36 @@ pub fn lookup_conf_file() -> io::Result<Option<PathBuf>> {
322322 let mut current = env:: var_os ( "CLIPPY_CONF_DIR" )
323323 . or_else ( || env:: var_os ( "CARGO_MANIFEST_DIR" ) )
324324 . map_or_else ( || PathBuf :: from ( "." ) , PathBuf :: from) ;
325+
326+ let mut found_config: Option < PathBuf > = None ;
327+
325328 loop {
326329 for config_file_name in & CONFIG_FILE_NAMES {
327330 if let Ok ( config_file) = current. join ( config_file_name) . canonicalize ( ) {
328331 match fs:: metadata ( & config_file) {
329332 Err ( e) if e. kind ( ) == io:: ErrorKind :: NotFound => { } ,
330333 Err ( e) => return Err ( e) ,
331334 Ok ( md) if md. is_dir ( ) => { } ,
332- Ok ( _) => return Ok ( Some ( config_file) ) ,
335+ Ok ( _) => {
336+ // warn if we happen to find two config files
337+ if let Some ( ref found_config_) = found_config {
338+ eprintln ! (
339+ "Warning: found two config files: {} and {}.\n Using the first one!" ,
340+ found_config_. display( ) ,
341+ config_file. display( ) ,
342+ ) ;
343+ } else {
344+ found_config = Some ( config_file) ;
345+ }
346+ } ,
333347 }
334348 }
335349 }
336350
351+ if found_config. is_some ( ) {
352+ return Ok ( found_config) ;
353+ }
354+
337355 // If the current directory has no parent, we're done searching.
338356 if !current. pop ( ) {
339357 return Ok ( None ) ;
You can’t perform that action at this time.
0 commit comments