about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/utils/conf.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs
index c9d99617c1e..36a7e67af6f 100644
--- a/clippy_lints/src/utils/conf.rs
+++ b/clippy_lints/src/utils/conf.rs
@@ -322,6 +322,9 @@ pub fn lookup_conf_file() -> io::Result<Option<PathBuf>> {
     let mut current = env::var_os("CLIPPY_CONF_DIR")
         .or_else(|| env::var_os("CARGO_MANIFEST_DIR"))
         .map_or_else(|| PathBuf::from("."), PathBuf::from);
+
+    let mut found_config: Option<PathBuf> = None;
+
     loop {
         for config_file_name in &CONFIG_FILE_NAMES {
             if let Ok(config_file) = current.join(config_file_name).canonicalize() {
@@ -329,11 +332,26 @@ pub fn lookup_conf_file() -> io::Result<Option<PathBuf>> {
                     Err(e) if e.kind() == io::ErrorKind::NotFound => {},
                     Err(e) => return Err(e),
                     Ok(md) if md.is_dir() => {},
-                    Ok(_) => return Ok(Some(config_file)),
+                    Ok(_) => {
+                        // warn if we happen to find two config files
+                        if let Some(ref found_config_) = found_config {
+                            eprintln!(
+                                "Warning: found two config files: {} and {}.\nUsing the first one!",
+                                found_config_.display(),
+                                config_file.display(),
+                            );
+                        } else {
+                            found_config = Some(config_file);
+                        }
+                    },
                 }
             }
         }
 
+        if found_config.is_some() {
+            return Ok(found_config);
+        }
+
         // If the current directory has no parent, we're done searching.
         if !current.pop() {
             return Ok(None);