Skip to content

Commit 8063672

Browse files
committed
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.
2 parents 1fc6406 + c0dca04 commit 8063672

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
@@ -124,8 +124,6 @@ pub trait CargoPathExt {
124124
fn move_in_time<F>(&self, travel_amount: F)
125125
where
126126
F: Fn(i64, u32) -> (i64, u32);
127-
128-
fn is_symlink(&self) -> bool;
129127
}
130128

131129
impl CargoPathExt for Path {
@@ -198,12 +196,14 @@ impl CargoPathExt for Path {
198196
});
199197
}
200198
}
199+
}
201200

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

209209
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
@@ -4519,6 +4519,7 @@ fn building_a_dependent_crate_witout_bin_should_fail() {
45194519
#[cargo_test]
45204520
#[cfg(any(target_os = "macos", target_os = "ios"))]
45214521
fn uplift_dsym_of_bin_on_mac() {
4522+
use cargo_test_support::paths::is_symlink;
45224523
let p = project()
45234524
.file("src/main.rs", "fn main() { panic!(); }")
45244525
.file("src/bin/b.rs", "fn main() { panic!(); }")
@@ -4531,7 +4532,7 @@ fn uplift_dsym_of_bin_on_mac() {
45314532
.run();
45324533
assert!(p.target_debug_dir().join("foo.dSYM").is_dir());
45334534
assert!(p.target_debug_dir().join("b.dSYM").is_dir());
4534-
assert!(p.target_debug_dir().join("b.dSYM").is_symlink());
4535+
assert!(is_symlink(&p.target_debug_dir().join("b.dSYM")));
45354536
assert!(p.target_debug_dir().join("examples/c.dSYM").is_dir());
45364537
assert!(!p.target_debug_dir().join("c.dSYM").exists());
45374538
assert!(!p.target_debug_dir().join("d.dSYM").exists());
@@ -4540,6 +4541,7 @@ fn uplift_dsym_of_bin_on_mac() {
45404541
#[cargo_test]
45414542
#[cfg(any(target_os = "macos", target_os = "ios"))]
45424543
fn uplift_dsym_of_bin_on_mac_when_broken_link_exists() {
4544+
use cargo_test_support::paths::is_symlink;
45434545
let p = project()
45444546
.file("src/main.rs", "fn main() { panic!(); }")
45454547
.build();
@@ -4558,7 +4560,7 @@ fn uplift_dsym_of_bin_on_mac_when_broken_link_exists() {
45584560
.join("foo-baaaaaadbaaaaaad.dSYM"),
45594561
&dsym,
45604562
);
4561-
assert!(dsym.is_symlink());
4563+
assert!(is_symlink(&dsym));
45624564
assert!(!dsym.exists());
45634565

45644566
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)