File tree Expand file tree Collapse file tree 9 files changed +46
-1
lines changed
tests/ui-cargo/multiple_config_files Expand file tree Collapse file tree 9 files changed +46
-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>> {
322
322
let mut current = env:: var_os ( "CLIPPY_CONF_DIR" )
323
323
. or_else ( || env:: var_os ( "CARGO_MANIFEST_DIR" ) )
324
324
. map_or_else ( || PathBuf :: from ( "." ) , PathBuf :: from) ;
325
+
326
+ let mut found_config: Option < PathBuf > = None ;
327
+
325
328
loop {
326
329
for config_file_name in & CONFIG_FILE_NAMES {
327
330
if let Ok ( config_file) = current. join ( config_file_name) . canonicalize ( ) {
328
331
match fs:: metadata ( & config_file) {
329
332
Err ( e) if e. kind ( ) == io:: ErrorKind :: NotFound => { } ,
330
333
Err ( e) => return Err ( e) ,
331
334
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 #8323
337
+ if let Some ( ref found_config_) = found_config {
338
+ eprintln ! (
339
+ "Using config file `{}`\n Warning: `{}` will be ignored." ,
340
+ found_config_. canonicalize( ) . unwrap( ) . display( ) ,
341
+ config_file. canonicalize( ) . unwrap( ) . display( ) ,
342
+ ) ;
343
+ } else {
344
+ found_config = Some ( config_file) ;
345
+ }
346
+ } ,
333
347
}
334
348
}
335
349
}
336
350
351
+ if found_config. is_some ( ) {
352
+ return Ok ( found_config) ;
353
+ }
354
+
337
355
// If the current directory has no parent, we're done searching.
338
356
if !current. pop ( ) {
339
357
return Ok ( None ) ;
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " no_warn"
3
+ version = " 0.1.0"
4
+ edition = " 2021"
5
+
6
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
+
8
+ [dependencies ]
Original file line number Diff line number Diff line change
1
+ avoid-breaking-exported-api = false
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ println ! ( "Hello, world!" ) ;
3
+ }
Original file line number Diff line number Diff line change
1
+ avoid-breaking-exported-api = false
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " warn"
3
+ version = " 0.1.0"
4
+ edition = " 2021"
5
+
6
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
+
8
+ [dependencies ]
Original file line number Diff line number Diff line change
1
+ avoid-breaking-exported-api = false
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ println ! ( "Hello, world!" ) ;
3
+ }
Original file line number Diff line number Diff line change
1
+ Using config file `$SRC_DIR/tests/ui-cargo/multiple_config_files/warn/.clippy.toml`
2
+ Warning: `$SRC_DIR/tests/ui-cargo/multiple_config_files/warn/clippy.toml` will be ignored.
You can’t perform that action at this time.
0 commit comments