Skip to content

Commit 505500f

Browse files
committed
fix(script): Don't sanitize script names from windows reserved names
We discussed this in a recent Cargo team meeting: - Windows is moving away from this - The reserved name is irrespective of whether there is an extension, meaning that windows will limit whether the script can exist in the first place and we don't need further sanitization.
1 parent 8b921a8 commit 505500f

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/cargo/util/toml/embedded.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ pub fn sanitize_name(name: &str) -> String {
6767
name.push(placeholder);
6868
} else if name == "test" {
6969
name.push(placeholder);
70-
} else if restricted_names::is_windows_reserved(&name) {
71-
// Go ahead and be consistent across platforms
72-
name.push(placeholder);
7370
} else {
7471
break;
7572
}

tests/testsuite/script/cargo.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,23 +674,24 @@ args: []
674674
}
675675

676676
#[cargo_test(nightly, reason = "-Zscript is unstable")]
677+
#[cfg(not(windows))]
677678
fn test_name_is_windows_reserved_name() {
678679
let script = ECHO_SCRIPT;
679680
let p = cargo_test_support::project().file("con", script).build();
680681

681682
p.cargo("-Zscript -v ./con")
682683
.masquerade_as_nightly_cargo(&["script"])
683684
.with_stdout_data(str![[r#"
684-
current_exe: [ROOT]/home/.cargo/build/[HASH]/target/debug/con-[EXE]
685+
current_exe: [ROOT]/home/.cargo/build/[HASH]/target/debug/con[EXE]
685686
arg0: [..]
686687
args: []
687688
688689
"#]])
689690
.with_stderr_data(str![[r#"
690691
[WARNING] `package.edition` is unspecified, defaulting to `2024`
691-
[COMPILING] con- v0.0.0 ([ROOT]/foo/con)
692+
[COMPILING] con v0.0.0 ([ROOT]/foo/con)
692693
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
693-
[RUNNING] `[ROOT]/home/.cargo/build/[HASH]/target/debug/con-[EXE]`
694+
[RUNNING] `[ROOT]/home/.cargo/build/[HASH]/target/debug/con[EXE]`
694695
695696
"#]])
696697
.run();

0 commit comments

Comments
 (0)