File tree 3 files changed +10
-21
lines changed
3 files changed +10
-21
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,7 @@ rand.workspace = true
184
184
regex.workspace = true
185
185
rusqlite.workspace = true
186
186
rustfix.workspace = true
187
+ same-file.workspace = true
187
188
semver.workspace = true
188
189
serde = { workspace = true , features = [" derive" ] }
189
190
serde-untagged.workspace = true
Original file line number Diff line number Diff line change @@ -1537,36 +1537,32 @@ impl GlobalContext {
1537
1537
let possible = dir. join ( filename_without_extension) ;
1538
1538
let possible_with_extension = dir. join ( format ! ( "{}.toml" , filename_without_extension) ) ;
1539
1539
1540
- if possible . exists ( ) {
1540
+ if let Ok ( possible_handle ) = same_file :: Handle :: from_path ( & possible ) {
1541
1541
if warn {
1542
+ if let Ok ( possible_with_extension_handle) =
1543
+ same_file:: Handle :: from_path ( & possible_with_extension)
1544
+ {
1542
1545
// We don't want to print a warning if the version
1543
1546
// without the extension is just a symlink to the version
1544
1547
// WITH an extension, which people may want to do to
1545
1548
// support multiple Cargo versions at once and not
1546
1549
// get a warning.
1547
- let skip_warning = if let Ok ( target_path) = fs:: read_link ( & possible) {
1548
- target_path == possible_with_extension
1549
- } else {
1550
- false
1551
- } ;
1552
-
1553
- if !skip_warning {
1554
- if possible_with_extension. exists ( ) {
1550
+ if possible_handle != possible_with_extension_handle {
1555
1551
self . shell ( ) . warn ( format ! (
1556
1552
"both `{}` and `{}` exist. Using `{}`" ,
1557
1553
possible. display( ) ,
1558
1554
possible_with_extension. display( ) ,
1559
1555
possible. display( )
1560
1556
) ) ?;
1561
- } else {
1557
+ }
1558
+ } else {
1562
1559
self . shell ( ) . warn ( format ! (
1563
1560
"`{}` is deprecated in favor of `{filename_without_extension}.toml`" ,
1564
1561
possible. display( ) ,
1565
1562
) ) ?;
1566
1563
self . shell ( ) . note (
1567
1564
format ! ( "if you need to support cargo 1.38 or earlier, you can symlink `{filename_without_extension}` to `{filename_without_extension}.toml`" ) ,
1568
1565
) ?;
1569
- }
1570
1566
}
1571
1567
}
1572
1568
Original file line number Diff line number Diff line change @@ -348,12 +348,8 @@ f1 = 1
348
348
assert_eq ! ( gctx. get:: <Option <i32 >>( "foo.f1" ) . unwrap( ) , Some ( 1 ) ) ;
349
349
350
350
// It should NOT have warned for the symlink.
351
- // But, currently it does!
352
351
let output = read_output ( gctx) ;
353
- let expected = "\
354
- [WARNING] both `[..]/.cargo/config` and `[..]/.cargo/config.toml` exist. Using `[..]/.cargo/config`
355
- " ;
356
- assert_match ( expected, & output) ;
352
+ assert_match ( "" , & output) ;
357
353
}
358
354
359
355
#[ cargo_test]
@@ -378,12 +374,8 @@ f1 = 1
378
374
assert_eq ! ( gctx. get:: <Option <i32 >>( "foo.f1" ) . unwrap( ) , Some ( 1 ) ) ;
379
375
380
376
// It should NOT have warned for this situation.
381
- // But, currently it does!
382
377
let output = read_output ( gctx) ;
383
- let expected = "\
384
- [WARNING] both `[..]/.cargo/config` and `[..]/.cargo/config.toml` exist. Using `[..]/.cargo/config`
385
- " ;
386
- assert_match ( expected, & output) ;
378
+ assert_match ( "" , & output) ;
387
379
}
388
380
389
381
#[ cargo_test]
You can’t perform that action at this time.
0 commit comments