Skip to content

Commit 6b1aa7d

Browse files
committed
fix(dist/prefix): normalize path separators in REL_MANIFEST_DIR
1 parent 09f1aab commit 6b1aa7d

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/dist/prefix.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ use std::path::{Path, PathBuf};
22

33
use crate::utils;
44

5-
const REL_MANIFEST_DIR: &str = "lib/rustlib";
5+
/// The relative path to the manifest directory in a Rust installation,
6+
/// with path components separated by [`std::path::MAIN_SEPARATOR`].
7+
const REL_MANIFEST_DIR: &str = match std::path::MAIN_SEPARATOR {
8+
'/' => "lib/rustlib",
9+
'\\' => r"lib\rustlib",
10+
_ => panic!("unknown `std::path::MAIN_SEPARATOR`"),
11+
};
12+
613
static V1_COMMON_COMPONENT_LIST: &[&str] = &["cargo", "rustc", "rust-docs"];
714

815
#[derive(Clone, Debug)]

tests/suite/cli_v2.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
use std::fs;
55
use std::io::Write;
6+
use std::path::PathBuf;
67

78
use rustup::dist::TargetTriple;
89
use rustup::for_host;
@@ -392,17 +393,15 @@ async fn bad_manifest() {
392393
// install some toolchain
393394
cx.config.expect_ok(&["rustup", "update", "nightly"]).await;
394395

395-
#[cfg(not(target_os = "windows"))]
396-
let path = format!(
397-
"toolchains/nightly-{}/lib/rustlib/multirust-channel-manifest.toml",
398-
this_host_triple(),
399-
);
400-
401-
#[cfg(target_os = "windows")]
402-
let path = format!(
403-
r"toolchains\nightly-{}\lib/rustlib\multirust-channel-manifest.toml",
404-
this_host_triple(),
405-
);
396+
let path = [
397+
"toolchains",
398+
for_host!("nightly-{}"),
399+
"lib",
400+
"rustlib",
401+
"multirust-channel-manifest.toml",
402+
]
403+
.into_iter()
404+
.collect::<PathBuf>();
406405

407406
assert!(cx.config.rustupdir.has(&path));
408407
let path = cx.config.rustupdir.join(&path);

0 commit comments

Comments
 (0)