Skip to content

Commit 09ed3d2

Browse files
borsehuss
authored andcommitted
Auto merge of #9604 - ehuss:is_symlink, r=alexcrichton
Disambiguate is_symlink. `Path::is_symlink` was added in rust-lang/rust#85747 which triggers the `unstable_name_collisions` lint, breaking Cargo's CI. This switches it to a free function to avoid the collision.
1 parent a9eb3ef commit 09ed3d2

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

crates/cargo-test-support/src/paths.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ pub trait CargoPathExt {
125125
fn move_in_time<F>(&self, travel_amount: F)
126126
where
127127
F: Fn(i64, u32) -> (i64, u32);
128-
129-
fn is_symlink(&self) -> bool;
130128
}
131129

132130
impl CargoPathExt for Path {
@@ -199,12 +197,14 @@ impl CargoPathExt for Path {
199197
});
200198
}
201199
}
200+
}
202201

203-
fn is_symlink(&self) -> bool {
204-
fs::symlink_metadata(self)
205-
.map(|m| m.file_type().is_symlink())
206-
.unwrap_or(false)
207-
}
202+
// Replace with std implementation when stabilized, see
203+
// https://github.com/rust-lang/rust/issues/85748
204+
pub fn is_symlink(path: &Path) -> bool {
205+
fs::symlink_metadata(path)
206+
.map(|m| m.file_type().is_symlink())
207+
.unwrap_or(false)
208208
}
209209

210210
fn do_op<F>(path: &Path, desc: &str, mut f: F)

tests/testsuite/build.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4505,6 +4505,7 @@ fn building_a_dependent_crate_witout_bin_should_fail() {
45054505
#[cargo_test]
45064506
#[cfg(any(target_os = "macos", target_os = "ios"))]
45074507
fn uplift_dsym_of_bin_on_mac() {
4508+
use cargo_test_support::paths::is_symlink;
45084509
let p = project()
45094510
.file("src/main.rs", "fn main() { panic!(); }")
45104511
.file("src/bin/b.rs", "fn main() { panic!(); }")
@@ -4517,7 +4518,7 @@ fn uplift_dsym_of_bin_on_mac() {
45174518
.run();
45184519
assert!(p.target_debug_dir().join("foo.dSYM").is_dir());
45194520
assert!(p.target_debug_dir().join("b.dSYM").is_dir());
4520-
assert!(p.target_debug_dir().join("b.dSYM").is_symlink());
4521+
assert!(is_symlink(&p.target_debug_dir().join("b.dSYM")));
45214522
assert!(p.target_debug_dir().join("examples/c.dSYM").is_dir());
45224523
assert!(!p.target_debug_dir().join("c.dSYM").exists());
45234524
assert!(!p.target_debug_dir().join("d.dSYM").exists());
@@ -4526,6 +4527,7 @@ fn uplift_dsym_of_bin_on_mac() {
45264527
#[cargo_test]
45274528
#[cfg(any(target_os = "macos", target_os = "ios"))]
45284529
fn uplift_dsym_of_bin_on_mac_when_broken_link_exists() {
4530+
use cargo_test_support::paths::is_symlink;
45294531
let p = project()
45304532
.file("src/main.rs", "fn main() { panic!(); }")
45314533
.build();
@@ -4544,7 +4546,7 @@ fn uplift_dsym_of_bin_on_mac_when_broken_link_exists() {
45444546
.join("foo-baaaaaadbaaaaaad.dSYM"),
45454547
&dsym,
45464548
);
4547-
assert!(dsym.is_symlink());
4549+
assert!(is_symlink(&dsym));
45484550
assert!(!dsym.exists());
45494551

45504552
p.cargo("build").enable_mac_dsym().run();

tests/testsuite/clean.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Tests for the `cargo clean` command.
22
3-
use cargo_test_support::paths::CargoPathExt;
3+
use cargo_test_support::paths::is_symlink;
44
use cargo_test_support::registry::Package;
55
use cargo_test_support::{basic_bin_manifest, basic_manifest, git, main_file, project, rustc_host};
66
use std::env;
@@ -438,7 +438,7 @@ fn assert_all_clean(build_dir: &Path) {
438438
{
439439
continue;
440440
}
441-
if path.is_symlink() || path.is_file() {
441+
if is_symlink(path) || path.is_file() {
442442
panic!("{:?} was not cleaned", path);
443443
}
444444
}

0 commit comments

Comments
 (0)