Skip to content

Commit c6745a3

Browse files
committed
Auto merge of #10290 - maxwase:is_symlink_stabilized, r=Eh2406
Use `is_symlink()` method I've came across this comment ```rust // Replace with std implementation when stabilized, see // rust-lang/rust#85748 ``` and fixed this due to the method stabilization in 1.58
2 parents e77c071 + 2623af0 commit c6745a3

File tree

4 files changed

+3
-15
lines changed

4 files changed

+3
-15
lines changed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,6 @@ impl CargoPathExt for Path {
198198
}
199199
}
200200

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)
207-
}
208-
209201
fn do_op<F>(path: &Path, desc: &str, mut f: F)
210202
where
211203
F: FnMut(&Path) -> io::Result<()>,

crates/cargo-util/src/paths.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ pub fn remove_dir_all<P: AsRef<Path>>(p: P) -> Result<()> {
420420
fn _remove_dir_all(p: &Path) -> Result<()> {
421421
if p.symlink_metadata()
422422
.with_context(|| format!("could not get metadata for `{}` to remove", p.display()))?
423-
.file_type()
424423
.is_symlink()
425424
{
426425
return remove_file(p);

tests/testsuite/build.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4805,7 +4805,6 @@ fn building_a_dependent_crate_witout_bin_should_fail() {
48054805
#[cargo_test]
48064806
#[cfg(any(target_os = "macos", target_os = "ios"))]
48074807
fn uplift_dsym_of_bin_on_mac() {
4808-
use cargo_test_support::paths::is_symlink;
48094808
let p = project()
48104809
.file("src/main.rs", "fn main() { panic!(); }")
48114810
.file("src/bin/b.rs", "fn main() { panic!(); }")
@@ -4818,7 +4817,7 @@ fn uplift_dsym_of_bin_on_mac() {
48184817
.run();
48194818
assert!(p.target_debug_dir().join("foo.dSYM").is_dir());
48204819
assert!(p.target_debug_dir().join("b.dSYM").is_dir());
4821-
assert!(is_symlink(&p.target_debug_dir().join("b.dSYM")));
4820+
assert!(p.target_debug_dir().join("b.dSYM").is_symlink());
48224821
assert!(p.target_debug_dir().join("examples/c.dSYM").is_dir());
48234822
assert!(!p.target_debug_dir().join("c.dSYM").exists());
48244823
assert!(!p.target_debug_dir().join("d.dSYM").exists());
@@ -4827,7 +4826,6 @@ fn uplift_dsym_of_bin_on_mac() {
48274826
#[cargo_test]
48284827
#[cfg(any(target_os = "macos", target_os = "ios"))]
48294828
fn uplift_dsym_of_bin_on_mac_when_broken_link_exists() {
4830-
use cargo_test_support::paths::is_symlink;
48314829
let p = project()
48324830
.file("src/main.rs", "fn main() { panic!(); }")
48334831
.build();
@@ -4846,7 +4844,7 @@ fn uplift_dsym_of_bin_on_mac_when_broken_link_exists() {
48464844
.join("foo-baaaaaadbaaaaaad.dSYM"),
48474845
&dsym,
48484846
);
4849-
assert!(is_symlink(&dsym));
4847+
assert!(dsym.is_symlink());
48504848
assert!(!dsym.exists());
48514849

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

tests/testsuite/clean.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Tests for the `cargo clean` command.
22
3-
use cargo_test_support::paths::is_symlink;
43
use cargo_test_support::registry::Package;
54
use cargo_test_support::{
65
basic_bin_manifest, basic_manifest, git, main_file, project, project_in, rustc_host,
@@ -476,7 +475,7 @@ fn assert_all_clean(build_dir: &Path) {
476475
{
477476
continue;
478477
}
479-
if is_symlink(path) || path.is_file() {
478+
if path.is_symlink() || path.is_file() {
480479
panic!("{:?} was not cleaned", path);
481480
}
482481
}

0 commit comments

Comments
 (0)