rust-installer and rls no longer submodule, so fix rustfmt.toml

This commit is contained in:
klensy 2023-06-23 10:34:06 +03:00
parent cd68ead9ec
commit f3d9248c22
7 changed files with 31 additions and 69 deletions

View File

@ -16,6 +16,8 @@ ignore = [
"tests", "tests",
# do not format submodules # do not format submodules
# FIXME: sync submodule list with tidy/bootstrap/etc
# tidy/src/walk.rs:filter_dirs
"library/backtrace", "library/backtrace",
"library/portable-simd", "library/portable-simd",
"library/stdarch", "library/stdarch",
@ -31,10 +33,8 @@ ignore = [
"src/tools/cargo", "src/tools/cargo",
"src/tools/clippy", "src/tools/clippy",
"src/tools/miri", "src/tools/miri",
"src/tools/rls",
"src/tools/rust-analyzer", "src/tools/rust-analyzer",
"src/tools/rustfmt", "src/tools/rustfmt",
"src/tools/rust-installer",
# these are ignored by a standard cargo fmt run # these are ignored by a standard cargo fmt run
"compiler/rustc_codegen_cranelift/y.rs", # running rustfmt breaks this file "compiler/rustc_codegen_cranelift/y.rs", # running rustfmt breaks this file

View File

@ -71,25 +71,16 @@ impl Combiner {
// Merge each installer into the work directory of the new installer. // Merge each installer into the work directory of the new installer.
let components = create_new_file(package_dir.join("components"))?; let components = create_new_file(package_dir.join("components"))?;
for input_tarball in self for input_tarball in self.input_tarballs.split(',').map(str::trim).filter(|s| !s.is_empty())
.input_tarballs
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
{ {
// Extract the input tarballs // Extract the input tarballs
let compression = let compression =
CompressionFormat::detect_from_path(input_tarball).ok_or_else(|| { CompressionFormat::detect_from_path(input_tarball).ok_or_else(|| {
anyhow::anyhow!("couldn't figure out the format of {}", input_tarball) anyhow::anyhow!("couldn't figure out the format of {}", input_tarball)
})?; })?;
Archive::new(compression.decode(input_tarball)?) Archive::new(compression.decode(input_tarball)?).unpack(&self.work_dir).with_context(
.unpack(&self.work_dir) || format!("unable to extract '{}' into '{}'", &input_tarball, self.work_dir),
.with_context(|| { )?;
format!(
"unable to extract '{}' into '{}'",
&input_tarball, self.work_dir
)
})?;
let pkg_name = let pkg_name =
input_tarball.trim_end_matches(&format!(".tar.{}", compression.extension())); input_tarball.trim_end_matches(&format!(".tar.{}", compression.extension()));
@ -126,12 +117,8 @@ impl Combiner {
// Write the installer version. // Write the installer version.
let version = package_dir.join("rust-installer-version"); let version = package_dir.join("rust-installer-version");
writeln!( writeln!(create_new_file(version)?, "{}", crate::RUST_INSTALLER_VERSION)
create_new_file(version)?, .context("failed to write new installer version")?;
"{}",
crate::RUST_INSTALLER_VERSION
)
.context("failed to write new installer version")?;
// Copy the overlay. // Copy the overlay.
if !self.non_installed_overlay.is_empty() { if !self.non_installed_overlay.is_empty() {

View File

@ -86,12 +86,8 @@ impl Generator {
// Write the installer version (only used by combine-installers.sh) // Write the installer version (only used by combine-installers.sh)
let version = package_dir.join("rust-installer-version"); let version = package_dir.join("rust-installer-version");
writeln!( writeln!(create_new_file(version)?, "{}", crate::RUST_INSTALLER_VERSION)
create_new_file(version)?, .context("failed to write new installer version")?;
"{}",
crate::RUST_INSTALLER_VERSION
)
.context("failed to write new installer version")?;
// Copy the overlay // Copy the overlay
if !self.non_installed_overlay.is_empty() { if !self.non_installed_overlay.is_empty() {
@ -128,33 +124,19 @@ impl Generator {
/// Copies the `src` directory recursively to `dst`, writing `manifest.in` too. /// Copies the `src` directory recursively to `dst`, writing `manifest.in` too.
fn copy_and_manifest(src: &Path, dst: &Path, bulk_dirs: &str) -> Result<()> { fn copy_and_manifest(src: &Path, dst: &Path, bulk_dirs: &str) -> Result<()> {
let mut manifest = create_new_file(dst.join("manifest.in"))?; let mut manifest = create_new_file(dst.join("manifest.in"))?;
let bulk_dirs: Vec<_> = bulk_dirs let bulk_dirs: Vec<_> = bulk_dirs.split(',').filter(|s| !s.is_empty()).map(Path::new).collect();
.split(',')
.filter(|s| !s.is_empty())
.map(Path::new)
.collect();
let mut paths = BTreeSet::new(); let mut paths = BTreeSet::new();
copy_with_callback(src, dst, |path, file_type| { copy_with_callback(src, dst, |path, file_type| {
// We need paths to be compatible with both Unix and Windows. // We need paths to be compatible with both Unix and Windows.
if path if path.components().filter_map(|c| c.as_os_str().to_str()).any(|s| s.contains('\\')) {
.components() bail!("rust-installer doesn't support '\\' in path components: {:?}", path);
.filter_map(|c| c.as_os_str().to_str())
.any(|s| s.contains('\\'))
{
bail!(
"rust-installer doesn't support '\\' in path components: {:?}",
path
);
} }
// Normalize to Unix-style path separators. // Normalize to Unix-style path separators.
let normalized_string; let normalized_string;
let mut string = path.to_str().ok_or_else(|| { let mut string = path.to_str().ok_or_else(|| {
format_err!( format_err!("rust-installer doesn't support non-Unicode paths: {:?}", path)
"rust-installer doesn't support non-Unicode paths: {:?}",
path
)
})?; })?;
if string.contains('\\') { if string.contains('\\') {
normalized_string = string.replace('\\', "/"); normalized_string = string.replace('\\', "/");

View File

@ -19,8 +19,12 @@ fn main() -> Result<()> {
let command_line = CommandLine::parse(); let command_line = CommandLine::parse();
match command_line.command { match command_line.command {
Subcommand::Combine(combiner) => combiner.run().context("failed to combine installers")?, Subcommand::Combine(combiner) => combiner.run().context("failed to combine installers")?,
Subcommand::Generate(generator) => generator.run().context("failed to generate installer")?, Subcommand::Generate(generator) => {
Subcommand::Script(scripter) => scripter.run().context("failed to generate installation script")?, generator.run().context("failed to generate installer")?
}
Subcommand::Script(scripter) => {
scripter.run().context("failed to generate installation script")?
}
Subcommand::Tarball(tarballer) => tarballer.run().context("failed to generate tarballs")?, Subcommand::Tarball(tarballer) => tarballer.run().context("failed to generate tarballs")?,
} }
Ok(()) Ok(())

View File

@ -44,10 +44,7 @@ impl Scripter {
.replace("%%TEMPLATE_PRODUCT_NAME%%", &sh_quote(&product_name)) .replace("%%TEMPLATE_PRODUCT_NAME%%", &sh_quote(&product_name))
.replace("%%TEMPLATE_REL_MANIFEST_DIR%%", &self.rel_manifest_dir) .replace("%%TEMPLATE_REL_MANIFEST_DIR%%", &self.rel_manifest_dir)
.replace("%%TEMPLATE_SUCCESS_MESSAGE%%", &sh_quote(&success_message)) .replace("%%TEMPLATE_SUCCESS_MESSAGE%%", &sh_quote(&success_message))
.replace( .replace("%%TEMPLATE_LEGACY_MANIFEST_DIRS%%", &sh_quote(&self.legacy_manifest_dirs))
"%%TEMPLATE_LEGACY_MANIFEST_DIRS%%",
&sh_quote(&self.legacy_manifest_dirs),
)
.replace( .replace(
"%%TEMPLATE_RUST_INSTALLER_VERSION%%", "%%TEMPLATE_RUST_INSTALLER_VERSION%%",
&sh_quote(&crate::RUST_INSTALLER_VERSION), &sh_quote(&crate::RUST_INSTALLER_VERSION),

View File

@ -58,10 +58,7 @@ impl Tarballer {
let buf = BufWriter::with_capacity(1024 * 1024, encoder); let buf = BufWriter::with_capacity(1024 * 1024, encoder);
let mut builder = Builder::new(buf); let mut builder = Builder::new(buf);
let pool = rayon::ThreadPoolBuilder::new() let pool = rayon::ThreadPoolBuilder::new().num_threads(2).build().unwrap();
.num_threads(2)
.build()
.unwrap();
pool.install(move || { pool.install(move || {
for path in dirs { for path in dirs {
let src = Path::new(&self.work_dir).join(&path); let src = Path::new(&self.work_dir).join(&path);
@ -122,11 +119,7 @@ where
let name = name.as_ref(); let name = name.as_ref();
if !name.is_relative() && !name.starts_with(root) { if !name.is_relative() && !name.starts_with(root) {
bail!( bail!("input '{}' is not in work dir '{}'", name.display(), root.display());
"input '{}' is not in work dir '{}'",
name.display(),
root.display()
);
} }
let mut dirs = vec![]; let mut dirs = vec![];

View File

@ -15,8 +15,7 @@ use std::os::windows::fs::symlink_file;
/// Converts a `&Path` to a UTF-8 `&str`. /// Converts a `&Path` to a UTF-8 `&str`.
pub fn path_to_str(path: &Path) -> Result<&str> { pub fn path_to_str(path: &Path) -> Result<&str> {
path.to_str() path.to_str().ok_or_else(|| format_err!("path is not valid UTF-8 '{}'", path.display()))
.ok_or_else(|| format_err!("path is not valid UTF-8 '{}'", path.display()))
} }
/// Wraps `fs::copy` with a nicer error message. /// Wraps `fs::copy` with a nicer error message.
@ -27,11 +26,7 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64> {
Ok(0) Ok(0)
} else { } else {
let amt = fs::copy(&from, &to).with_context(|| { let amt = fs::copy(&from, &to).with_context(|| {
format!( format!("failed to copy '{}' to '{}'", from.as_ref().display(), to.as_ref().display())
"failed to copy '{}' to '{}'",
from.as_ref().display(),
to.as_ref().display()
)
})?; })?;
Ok(amt) Ok(amt)
} }
@ -123,8 +118,12 @@ where
} }
macro_rules! actor_field_default { macro_rules! actor_field_default {
() => { Default::default() }; () => {
(= $expr:expr) => { $expr.into() } Default::default()
};
(= $expr:expr) => {
$expr.into()
};
} }
/// Creates an "actor" with default values, setters for all fields, and Clap parser support. /// Creates an "actor" with default values, setters for all fields, and Clap parser support.