Minimize visibilities.

This makes it much clearer which things are used outside the crate.
This commit is contained in:
Nicholas Nethercote
2024-09-05 15:16:55 +10:00
parent 04a318787b
commit bdacdfe95f
24 changed files with 188 additions and 179 deletions

View File

@@ -8,7 +8,7 @@ use std::{fmt, io, mem};
use rustc_target::spec::LldFlavor;
#[derive(Clone)]
pub struct Command {
pub(crate) struct Command {
program: Program,
args: Vec<OsString>,
env: Vec<(OsString, OsString)>,
@@ -23,15 +23,15 @@ enum Program {
}
impl Command {
pub fn new<P: AsRef<OsStr>>(program: P) -> Command {
pub(crate) fn new<P: AsRef<OsStr>>(program: P) -> Command {
Command::_new(Program::Normal(program.as_ref().to_owned()))
}
pub fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
pub(crate) fn bat_script<P: AsRef<OsStr>>(program: P) -> Command {
Command::_new(Program::CmdBatScript(program.as_ref().to_owned()))
}
pub fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
pub(crate) fn lld<P: AsRef<OsStr>>(program: P, flavor: LldFlavor) -> Command {
Command::_new(Program::Lld(program.as_ref().to_owned(), flavor))
}
@@ -39,12 +39,12 @@ impl Command {
Command { program, args: Vec::new(), env: Vec::new(), env_remove: Vec::new() }
}
pub fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
pub(crate) fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
self._arg(arg.as_ref());
self
}
pub fn args<I>(&mut self, args: I) -> &mut Command
pub(crate) fn args<I>(&mut self, args: I) -> &mut Command
where
I: IntoIterator<Item: AsRef<OsStr>>,
{
@@ -58,7 +58,7 @@ impl Command {
self.args.push(arg.to_owned());
}
pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
pub(crate) fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
where
K: AsRef<OsStr>,
V: AsRef<OsStr>,
@@ -71,7 +71,7 @@ impl Command {
self.env.push((key.to_owned(), value.to_owned()));
}
pub fn env_remove<K>(&mut self, key: K) -> &mut Command
pub(crate) fn env_remove<K>(&mut self, key: K) -> &mut Command
where
K: AsRef<OsStr>,
{
@@ -83,11 +83,11 @@ impl Command {
self.env_remove.push(key.to_owned());
}
pub fn output(&mut self) -> io::Result<Output> {
pub(crate) fn output(&mut self) -> io::Result<Output> {
self.command().output()
}
pub fn command(&self) -> process::Command {
pub(crate) fn command(&self) -> process::Command {
let mut ret = match self.program {
Program::Normal(ref p) => process::Command::new(p),
Program::CmdBatScript(ref p) => {
@@ -111,17 +111,17 @@ impl Command {
// extensions
pub fn get_args(&self) -> &[OsString] {
pub(crate) fn get_args(&self) -> &[OsString] {
&self.args
}
pub fn take_args(&mut self) -> Vec<OsString> {
pub(crate) fn take_args(&mut self) -> Vec<OsString> {
mem::take(&mut self.args)
}
/// Returns a `true` if we're pretty sure that this'll blow OS spawn limits,
/// or `false` if we should attempt to spawn and see what the OS says.
pub fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
pub(crate) fn very_likely_to_exceed_some_spawn_limit(&self) -> bool {
// We mostly only care about Windows in this method, on Unix the limits
// can be gargantuan anyway so we're pretty unlikely to hit them
if cfg!(unix) {