Skip to content

Commit

Permalink
fix(dist/prefix): normalize path separators in REL_MANIFEST_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Feb 10, 2025
1 parent 82bed1f commit 6908f50
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
9 changes: 8 additions & 1 deletion src/dist/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ use std::path::{Path, PathBuf};

use crate::utils;

const REL_MANIFEST_DIR: &str = "lib/rustlib";
/// The relative path to the manifest directory in a Rust installation,
/// with path components separated by [`std::path::MAIN_SEPARATOR`].
const REL_MANIFEST_DIR: &str = match std::path::MAIN_SEPARATOR {
'/' => "lib/rustlib",
'\\' => r"lib\rustlib",
_ => panic!("unknown `std::path::MAIN_SEPARATOR`"),
};

static V1_COMMON_COMPONENT_LIST: &[&str] = &["cargo", "rustc", "rust-docs"];

#[derive(Clone, Debug)]
Expand Down
21 changes: 10 additions & 11 deletions tests/suite/cli_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::fs;
use std::io::Write;
use std::path::PathBuf;

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

#[cfg(not(target_os = "windows"))]
let path = format!(
"toolchains/nightly-{}/lib/rustlib/multirust-channel-manifest.toml",
this_host_triple(),
);

#[cfg(target_os = "windows")]
let path = format!(
r"toolchains\nightly-{}\lib/rustlib\multirust-channel-manifest.toml",
this_host_triple(),
);
let path = [
"toolchains",
for_host!("nightly-{}"),
"lib",
"rustlib",
"multirust-channel-manifest.toml",
]
.into_iter()
.collect::<PathBuf>();

assert!(cx.config.rustupdir.has(&path));
let path = cx.config.rustupdir.join(&path);
Expand Down

0 comments on commit 6908f50

Please sign in to comment.