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 @@ -1542,36 +1542,32 @@ impl GlobalContext {
1542
1542
//
1543
1543
// Instead, if we got an error, we should bail, but perhaps
1544
1544
// that might be too much risk of being a breaking change.
1545
- if possible . exists ( ) {
1545
+ if let Ok ( possible_handle ) = same_file :: Handle :: from_path ( & possible ) {
1546
1546
if warn {
1547
+ if let Ok ( possible_with_extension_handle) =
1548
+ same_file:: Handle :: from_path ( & possible_with_extension)
1549
+ {
1547
1550
// We don't want to print a warning if the version
1548
1551
// without the extension is just a symlink to the version
1549
1552
// WITH an extension, which people may want to do to
1550
1553
// support multiple Cargo versions at once and not
1551
1554
// get a warning.
1552
- let skip_warning = if let Ok ( target_path) = fs:: read_link ( & possible) {
1553
- target_path == possible_with_extension
1554
- } else {
1555
- false
1556
- } ;
1557
-
1558
- if !skip_warning {
1559
- if possible_with_extension. exists ( ) {
1555
+ if possible_handle != possible_with_extension_handle {
1560
1556
self . shell ( ) . warn ( format ! (
1561
1557
"both `{}` and `{}` exist. Using `{}`" ,
1562
1558
possible. display( ) ,
1563
1559
possible_with_extension. display( ) ,
1564
1560
possible. display( )
1565
1561
) ) ?;
1566
- } else {
1562
+ }
1563
+ } else {
1567
1564
self . shell ( ) . warn ( format ! (
1568
1565
"`{}` is deprecated in favor of `{filename_without_extension}.toml`" ,
1569
1566
possible. display( ) ,
1570
1567
) ) ?;
1571
1568
self . shell ( ) . note (
1572
1569
format ! ( "if you need to support cargo 1.38 or earlier, you can symlink `{filename_without_extension}` to `{filename_without_extension}.toml`" ) ,
1573
1570
) ?;
1574
- }
1575
1571
}
1576
1572
}
1577
1573
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,13 +374,9 @@ 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
378
assert_match ( "" , & output) ;
384
- let expected = "\
385
- [WARNING] both `[..]/.cargo/config` and `[..]/.cargo/config.toml` exist. Using `[..]/.cargo/config`
386
- " ;
387
- assert_match ( expected, & output) ;
379
+ assert_match ( "" , & output) ;
388
380
}
389
381
390
382
#[ cargo_test]
You can’t perform that action at this time.
0 commit comments