Skip to content

File tree

7 files changed

+31
-69
lines changed

7 files changed

+31
-69
lines changed
 

‎rustfmt.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ ignore = [
1616
"tests",
1717

1818
# do not format submodules
19+
# FIXME: sync submodule list with tidy/bootstrap/etc
20+
# tidy/src/walk.rs:filter_dirs
1921
"library/backtrace",
2022
"library/portable-simd",
2123
"library/stdarch",
@@ -31,10 +33,8 @@ ignore = [
3133
"src/tools/cargo",
3234
"src/tools/clippy",
3335
"src/tools/miri",
34-
"src/tools/rls",
3536
"src/tools/rust-analyzer",
3637
"src/tools/rustfmt",
37-
"src/tools/rust-installer",
3838

3939
# these are ignored by a standard cargo fmt run
4040
"compiler/rustc_codegen_cranelift/y.rs", # running rustfmt breaks this file

‎src/tools/rust-installer/src/combiner.rs

+6-19
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,16 @@ impl Combiner {
7171

7272
// Merge each installer into the work directory of the new installer.
7373
let components = create_new_file(package_dir.join("components"))?;
74-
for input_tarball in self
75-
.input_tarballs
76-
.split(',')
77-
.map(str::trim)
78-
.filter(|s| !s.is_empty())
74+
for input_tarball in self.input_tarballs.split(',').map(str::trim).filter(|s| !s.is_empty())
7975
{
8076
// Extract the input tarballs
8177
let compression =
8278
CompressionFormat::detect_from_path(input_tarball).ok_or_else(|| {
8379
anyhow::anyhow!("couldn't figure out the format of {}", input_tarball)
8480
})?;
85-
Archive::new(compression.decode(input_tarball)?)
86-
.unpack(&self.work_dir)
87-
.with_context(|| {
88-
format!(
89-
"unable to extract '{}' into '{}'",
90-
&input_tarball, self.work_dir
91-
)
92-
})?;
81+
Archive::new(compression.decode(input_tarball)?).unpack(&self.work_dir).with_context(
82+
|| format!("unable to extract '{}' into '{}'", &input_tarball, self.work_dir),
83+
)?;
9384

9485
let pkg_name =
9586
input_tarball.trim_end_matches(&format!(".tar.{}", compression.extension()));
@@ -126,12 +117,8 @@ impl Combiner {
126117

127118
// Write the installer version.
128119
let version = package_dir.join("rust-installer-version");
129-
writeln!(
130-
create_new_file(version)?,
131-
"{}",
132-
crate::RUST_INSTALLER_VERSION
133-
)
134-
.context("failed to write new installer version")?;
120+
writeln!(create_new_file(version)?, "{}", crate::RUST_INSTALLER_VERSION)
121+
.context("failed to write new installer version")?;
135122

136123
// Copy the overlay.
137124
if !self.non_installed_overlay.is_empty() {

‎src/tools/rust-installer/src/generator.rs

+6-24
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,8 @@ impl Generator {
8686

8787
// Write the installer version (only used by combine-installers.sh)
8888
let version = package_dir.join("rust-installer-version");
89-
writeln!(
90-
create_new_file(version)?,
91-
"{}",
92-
crate::RUST_INSTALLER_VERSION
93-
)
94-
.context("failed to write new installer version")?;
89+
writeln!(create_new_file(version)?, "{}", crate::RUST_INSTALLER_VERSION)
90+
.context("failed to write new installer version")?;
9591

9692
// Copy the overlay
9793
if !self.non_installed_overlay.is_empty() {
@@ -128,33 +124,19 @@ impl Generator {
128124
/// Copies the `src` directory recursively to `dst`, writing `manifest.in` too.
129125
fn copy_and_manifest(src: &Path, dst: &Path, bulk_dirs: &str) -> Result<()> {
130126
let mut manifest = create_new_file(dst.join("manifest.in"))?;
131-
let bulk_dirs: Vec<_> = bulk_dirs
132-
.split(',')
133-
.filter(|s| !s.is_empty())
134-
.map(Path::new)
135-
.collect();
127+
let bulk_dirs: Vec<_> = bulk_dirs.split(',').filter(|s| !s.is_empty()).map(Path::new).collect();
136128

137129
let mut paths = BTreeSet::new();
138130
copy_with_callback(src, dst, |path, file_type| {
139131
// We need paths to be compatible with both Unix and Windows.
140-
if path
141-
.components()
142-
.filter_map(|c| c.as_os_str().to_str())
143-
.any(|s| s.contains('\\'))
144-
{
145-
bail!(
146-
"rust-installer doesn't support '\\' in path components: {:?}",
147-
path
148-
);
132+
if path.components().filter_map(|c| c.as_os_str().to_str()).any(|s| s.contains('\\')) {
133+
bail!("rust-installer doesn't support '\\' in path components: {:?}", path);
149134
}
150135

151136
// Normalize to Unix-style path separators.
152137
let normalized_string;
153138
let mut string = path.to_str().ok_or_else(|| {
154-
format_err!(
155-
"rust-installer doesn't support non-Unicode paths: {:?}",
156-
path
157-
)
139+
format_err!("rust-installer doesn't support non-Unicode paths: {:?}", path)
158140
})?;
159141
if string.contains('\\') {
160142
normalized_string = string.replace('\\', "/");

‎src/tools/rust-installer/src/main.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ fn main() -> Result<()> {
1919
let command_line = CommandLine::parse();
2020
match command_line.command {
2121
Subcommand::Combine(combiner) => combiner.run().context("failed to combine installers")?,
22-
Subcommand::Generate(generator) => generator.run().context("failed to generate installer")?,
23-
Subcommand::Script(scripter) => scripter.run().context("failed to generate installation script")?,
22+
Subcommand::Generate(generator) => {
23+
generator.run().context("failed to generate installer")?
24+
}
25+
Subcommand::Script(scripter) => {
26+
scripter.run().context("failed to generate installation script")?
27+
}
2428
Subcommand::Tarball(tarballer) => tarballer.run().context("failed to generate tarballs")?,
2529
}
2630
Ok(())

‎src/tools/rust-installer/src/scripter.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ impl Scripter {
4444
.replace("%%TEMPLATE_PRODUCT_NAME%%", &sh_quote(&product_name))
4545
.replace("%%TEMPLATE_REL_MANIFEST_DIR%%", &self.rel_manifest_dir)
4646
.replace("%%TEMPLATE_SUCCESS_MESSAGE%%", &sh_quote(&success_message))
47-
.replace(
48-
"%%TEMPLATE_LEGACY_MANIFEST_DIRS%%",
49-
&sh_quote(&self.legacy_manifest_dirs),
50-
)
47+
.replace("%%TEMPLATE_LEGACY_MANIFEST_DIRS%%", &sh_quote(&self.legacy_manifest_dirs))
5148
.replace(
5249
"%%TEMPLATE_RUST_INSTALLER_VERSION%%",
5350
&sh_quote(&crate::RUST_INSTALLER_VERSION),

‎src/tools/rust-installer/src/tarballer.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ impl Tarballer {
5858
let buf = BufWriter::with_capacity(1024 * 1024, encoder);
5959
let mut builder = Builder::new(buf);
6060

61-
let pool = rayon::ThreadPoolBuilder::new()
62-
.num_threads(2)
63-
.build()
64-
.unwrap();
61+
let pool = rayon::ThreadPoolBuilder::new().num_threads(2).build().unwrap();
6562
pool.install(move || {
6663
for path in dirs {
6764
let src = Path::new(&self.work_dir).join(&path);
@@ -122,11 +119,7 @@ where
122119
let name = name.as_ref();
123120

124121
if !name.is_relative() && !name.starts_with(root) {
125-
bail!(
126-
"input '{}' is not in work dir '{}'",
127-
name.display(),
128-
root.display()
129-
);
122+
bail!("input '{}' is not in work dir '{}'", name.display(), root.display());
130123
}
131124

132125
let mut dirs = vec![];

‎src/tools/rust-installer/src/util.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ use std::os::windows::fs::symlink_file;
1515

1616
/// Converts a `&Path` to a UTF-8 `&str`.
1717
pub fn path_to_str(path: &Path) -> Result<&str> {
18-
path.to_str()
19-
.ok_or_else(|| format_err!("path is not valid UTF-8 '{}'", path.display()))
18+
path.to_str().ok_or_else(|| format_err!("path is not valid UTF-8 '{}'", path.display()))
2019
}
2120

2221
/// 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> {
2726
Ok(0)
2827
} else {
2928
let amt = fs::copy(&from, &to).with_context(|| {
30-
format!(
31-
"failed to copy '{}' to '{}'",
32-
from.as_ref().display(),
33-
to.as_ref().display()
34-
)
29+
format!("failed to copy '{}' to '{}'", from.as_ref().display(), to.as_ref().display())
3530
})?;
3631
Ok(amt)
3732
}
@@ -123,8 +118,12 @@ where
123118
}
124119

125120
macro_rules! actor_field_default {
126-
() => { Default::default() };
127-
(= $expr:expr) => { $expr.into() }
121+
() => {
122+
Default::default()
123+
};
124+
(= $expr:expr) => {
125+
$expr.into()
126+
};
128127
}
129128

130129
/// Creates an "actor" with default values, setters for all fields, and Clap parser support.

0 commit comments

Comments
 (0)
Please sign in to comment.