Skip to content

Commit 1b400b4

Browse files
committed
chore: disable some unix-only helper functions on Windows
1 parent 7cbc3c9 commit 1b400b4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/cli/rustup_mode.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::fmt;
22
use std::io::Write;
33
use std::path::{Path, PathBuf};
4-
use std::process;
54
use std::str::FromStr;
65

76
use anyhow::{anyhow, Error, Result};
@@ -24,7 +23,6 @@ use crate::{
2423
currentprocess::{
2524
argsource::ArgSource,
2625
filesource::{StderrSource, StdoutSource},
27-
varsource::VarSource,
2826
},
2927
dist::{
3028
dist::{PartialToolchainDesc, Profile, TargetTriple},
@@ -212,6 +210,7 @@ pub fn main() -> Result<utils::ExitCode> {
212210
("run", m) => run(cfg, m)?,
213211
("which", m) => which(cfg, m)?,
214212
("doc", m) => doc(cfg, m)?,
213+
#[cfg(not(windows))]
215214
("man", m) => man(cfg, m)?,
216215
("self", c) => match c.subcommand() {
217216
Some(s) => match s {
@@ -1615,7 +1614,10 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
16151614
}
16161615
}
16171616

1617+
#[cfg(not(windows))]
16181618
fn man(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
1619+
use crate::currentprocess::varsource::VarSource;
1620+
16191621
let command = m.get_one::<String>("command").unwrap();
16201622

16211623
let toolchain = explicit_desc_or_dir_toolchain(cfg, m)?;
@@ -1629,7 +1631,7 @@ fn man(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
16291631
if let Some(path) = process().var_os("MANPATH") {
16301632
manpaths.push(path);
16311633
}
1632-
process::Command::new("man")
1634+
std::process::Command::new("man")
16331635
.env("MANPATH", manpaths)
16341636
.arg(command)
16351637
.status()

src/dist/dist.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use std::collections::HashSet;
22
use std::env;
33
use std::fmt;
4-
use std::fs;
5-
use std::io::{self, Read, Write};
4+
use std::io::Write;
65
use std::ops::Deref;
76
use std::path::Path;
87
use std::str::FromStr;
@@ -238,10 +237,13 @@ impl Deref for TargetTriple {
238237
}
239238
}
240239

240+
#[cfg(not(windows))]
241241
fn is_32bit_userspace() -> bool {
242242
// Check if /bin/sh is a 32-bit binary. If it doesn't exist, fall back to
243243
// checking if _we_ are a 32-bit binary.
244244
// rustup-init.sh also relies on checking /bin/sh for bitness.
245+
use std::fs;
246+
use std::io::{self, Read};
245247

246248
// inner function is to simplify error handling.
247249
fn inner() -> io::Result<bool> {

0 commit comments

Comments
 (0)