Skip to content

Commit ccd49b6

Browse files
committed
Reformat
1 parent 7b30220 commit ccd49b6

File tree

20 files changed

+145
-257
lines changed

20 files changed

+145
-257
lines changed

src/rustup-cli/rustup_mode.rs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,7 @@ fn default_(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
539539

540540
if let Some(status) = status {
541541
println!("");
542-
common::show_channel_update(
543-
cfg,
544-
toolchain.name(),
545-
Ok(status)
546-
)?;
542+
common::show_channel_update(cfg, toolchain.name(), Ok(status))?;
547543
}
548544

549545
Ok(())
@@ -565,11 +561,7 @@ fn update(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
565561

566562
if let Some(status) = status {
567563
println!("");
568-
common::show_channel_update(
569-
cfg,
570-
toolchain.name(),
571-
Ok(status)
572-
)?;
564+
common::show_channel_update(cfg, toolchain.name(), Ok(status))?;
573565
}
574566
}
575567
} else {
@@ -593,15 +585,15 @@ fn run(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
593585
cmd,
594586
args[0],
595587
&args[1..],
596-
&cfg
588+
&cfg,
597589
)?)
598590
}
599591

600592
fn which(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
601593
let binary = m.value_of("command").expect("");
602594

603-
let binary_path =
604-
cfg.which_binary(&utils::current_dir()?, binary)?.expect("binary not found");
595+
let binary_path = cfg.which_binary(&utils::current_dir()?, binary)?
596+
.expect("binary not found");
605597

606598
utils::assert_is_file(&binary_path)?;
607599

@@ -871,11 +863,7 @@ fn override_add(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
871863

872864
if let Some(status) = status {
873865
println!("");
874-
common::show_channel_update(
875-
cfg,
876-
toolchain.name(),
877-
Ok(status)
878-
)?;
866+
common::show_channel_update(cfg, toolchain.name(), Ok(status))?;
879867
}
880868

881869
Ok(())
@@ -908,10 +896,9 @@ fn override_remove(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
908896
};
909897

910898
for path in paths {
911-
if cfg.settings_file.with_mut(|s| Ok(s.remove_override(
912-
&Path::new(&path),
913-
cfg.notify_handler.as_ref()
914-
)))? {
899+
if cfg.settings_file
900+
.with_mut(|s| Ok(s.remove_override(&Path::new(&path), cfg.notify_handler.as_ref())))?
901+
{
915902
info!("override toolchain for '{}' removed", path);
916903
} else {
917904
info!("no override toolchain for '{}'", path);
@@ -935,10 +922,7 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
935922
"index.html"
936923
};
937924

938-
Ok(cfg.open_docs_for_dir(
939-
&utils::current_dir()?,
940-
doc_url
941-
)?)
925+
Ok(cfg.open_docs_for_dir(&utils::current_dir()?, doc_url)?)
942926
}
943927

944928
fn man(cfg: &Cfg, m: &ArgMatches) -> Result<()> {

src/rustup-cli/self_update.rs

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,7 @@ pub fn install(no_prompt: bool, verbose: bool, mut opts: InstallOpts) -> Result<
271271
// FIXME: Someday we can stop setting up the symlink, and when
272272
// we do that we can stop creating ~/.rustup as well.
273273
utils::create_rustup_home()?;
274-
maybe_install_rust(
275-
&opts.default_toolchain,
276-
&opts.default_host_triple,
277-
verbose
278-
)?;
274+
maybe_install_rust(&opts.default_toolchain, &opts.default_host_triple, verbose)?;
279275

280276
if cfg!(unix) {
281277
let ref env_file = utils::cargo_home()?.join("env");
@@ -624,20 +620,16 @@ fn customize_install(mut opts: InstallOpts) -> Result<InstallOpts> {
624620

625621
println!("");
626622

627-
opts.default_host_triple = common::question_str(
628-
"Default host triple?",
629-
&opts.default_host_triple
630-
)?;
623+
opts.default_host_triple =
624+
common::question_str("Default host triple?", &opts.default_host_triple)?;
631625

632626
opts.default_toolchain = common::question_str(
633627
"Default toolchain? (stable/beta/nightly/none)",
634-
&opts.default_toolchain
628+
&opts.default_toolchain,
635629
)?;
636630

637-
opts.no_modify_path = !common::question_bool(
638-
"Modify PATH variable? (y/n)",
639-
!opts.no_modify_path
640-
)?;
631+
opts.no_modify_path =
632+
!common::question_bool("Modify PATH variable? (y/n)", !opts.no_modify_path)?;
641633

642634
Ok(opts)
643635
}
@@ -823,10 +815,7 @@ pub fn uninstall(no_prompt: bool) -> Result<()> {
823815

824816
if !no_prompt {
825817
println!("");
826-
let ref msg = format!(
827-
pre_uninstall_msg!(),
828-
cargo_home = canonical_cargo_home()?
829-
);
818+
let ref msg = format!(pre_uninstall_msg!(), cargo_home = canonical_cargo_home()?);
830819
term2::stdout().md(msg);
831820
if !common::confirm("\nContinue? (y/N)", false)? {
832821
info!("aborting uninstallation");
@@ -1247,8 +1236,7 @@ fn do_add_to_path(methods: &[PathUpdateMethod]) -> Result<()> {
12471236
}
12481237

12491238
let root = RegKey::predef(HKEY_CURRENT_USER);
1250-
let environment = root
1251-
.open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE)
1239+
let environment = root.open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE)
12521240
.chain_err(|| ErrorKind::PermissionDenied)?;
12531241

12541242
let reg_value = RegValue {
@@ -1286,8 +1274,7 @@ fn get_windows_path_var() -> Result<Option<String>> {
12861274
use std::io;
12871275

12881276
let root = RegKey::predef(HKEY_CURRENT_USER);
1289-
let environment = root
1290-
.open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE)
1277+
let environment = root.open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE)
12911278
.chain_err(|| ErrorKind::PermissionDenied)?;
12921279

12931280
let reg_value = environment.get_raw_value("PATH");
@@ -1368,8 +1355,7 @@ fn do_remove_from_path(methods: &[PathUpdateMethod]) -> Result<()> {
13681355
new_path.push_str(&old_path[idx + len..]);
13691356

13701357
let root = RegKey::predef(HKEY_CURRENT_USER);
1371-
let environment = root
1372-
.open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE)
1358+
let environment = root.open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE)
13731359
.chain_err(|| ErrorKind::PermissionDenied)?;
13741360

13751361
if new_path.is_empty() {
@@ -1534,12 +1520,7 @@ pub fn prepare_update() -> Result<Option<PathBuf>> {
15341520
let release_file_url = format!("{}/release-stable.toml", update_root);
15351521
let release_file_url = utils::parse_url(&release_file_url)?;
15361522
let release_file = tempdir.path().join("release-stable.toml");
1537-
utils::download_file(
1538-
&release_file_url,
1539-
&release_file,
1540-
None,
1541-
&|_| ()
1542-
)?;
1523+
utils::download_file(&release_file_url, &release_file, None, &|_| ())?;
15431524
let release_toml_str = utils::read_file("rustup release", &release_file)?;
15441525
let release_toml: toml::Value = toml::from_str(&release_toml_str)
15451526
.map_err(|_| Error::from("unable to parse rustup release file"))?;
@@ -1579,12 +1560,7 @@ pub fn prepare_update() -> Result<Option<PathBuf>> {
15791560

15801561
// Download new version
15811562
info!("downloading self-update");
1582-
utils::download_file(
1583-
&download_url,
1584-
&setup_path,
1585-
None,
1586-
&|_| ()
1587-
)?;
1563+
utils::download_file(&download_url, &setup_path, None, &|_| ())?;
15881564

15891565
// Mark as executable
15901566
utils::make_executable(setup_path)?;

src/rustup-dist/src/component/components.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ impl Components {
4141
fn read_version(&self) -> Result<Option<String>> {
4242
let p = self.prefix.manifest_file(VERSION_FILE);
4343
if utils::is_file(&p) {
44-
Ok(Some(
45-
utils::read_file(VERSION_FILE, &p)?.trim().to_string(),
46-
))
44+
Ok(Some(utils::read_file(VERSION_FILE, &p)?.trim().to_string()))
4745
} else {
4846
Ok(None)
4947
}
@@ -53,7 +51,7 @@ impl Components {
5351
utils::write_file(
5452
VERSION_FILE,
5553
&self.prefix.manifest_file(VERSION_FILE),
56-
INSTALLER_VERSION
54+
INSTALLER_VERSION,
5755
)?;
5856

5957
Ok(())
@@ -121,12 +119,7 @@ impl<'a> ComponentBuilder<'a> {
121119
for part in self.parts {
122120
// FIXME: This writes relative paths to the component manifest,
123121
// but rust-installer writes absolute paths.
124-
utils::write_line(
125-
"component",
126-
&mut file,
127-
&abs_path,
128-
&part.encode()
129-
)?;
122+
utils::write_line("component", &mut file, &abs_path, &part.encode())?;
130123
}
131124

132125
// Add component to components file
@@ -179,10 +172,8 @@ impl Component {
179172
pub fn parts(&self) -> Result<Vec<ComponentPart>> {
180173
let mut result = Vec::new();
181174
for line in utils::read_file("component", &self.manifest_file())?.lines() {
182-
result
183-
.push(ComponentPart::decode(line).ok_or_else(|| {
184-
ErrorKind::CorruptComponent(self.name.clone())
185-
})?);
175+
result.push(ComponentPart::decode(line)
176+
.ok_or_else(|| ErrorKind::CorruptComponent(self.name.clone()))?);
186177
}
187178
Ok(result)
188179
}
@@ -191,7 +182,9 @@ impl Component {
191182
let path = self.components.rel_components_file();
192183
let abs_path = self.components.prefix.abs_path(&path);
193184
let temp = tx.temp().new_file()?;
194-
utils::filter_file("components", &abs_path, &temp, |l| (l != self.name))?;
185+
utils::filter_file("components", &abs_path, &temp, |l| {
186+
(l != self.name)
187+
})?;
195188
tx.modify_file(path)?;
196189
utils::rename_file("components", &temp, &abs_path)?;
197190

src/rustup-dist/src/component/package.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ impl DirectoryPackage {
4545
pub fn new(path: PathBuf) -> Result<Self> {
4646
validate_installer_version(&path)?;
4747

48-
let content = utils::read_file(
49-
"package components",
50-
&path.join("components")
51-
)?;
48+
let content = utils::read_file("package components", &path.join("components"))?;
5249
let components = content.lines().map(|l| l.to_owned()).collect();
5350
Ok(DirectoryPackage {
5451
path: path,
@@ -58,10 +55,7 @@ impl DirectoryPackage {
5855
}
5956

6057
fn validate_installer_version(path: &Path) -> Result<()> {
61-
let file = utils::read_file(
62-
"installer version",
63-
&path.join(VERSION_FILE)
64-
)?;
58+
let file = utils::read_file("installer version", &path.join(VERSION_FILE))?;
6559
let v = file.trim();
6660
if v == INSTALLER_VERSION {
6761
Ok(())
@@ -95,10 +89,7 @@ impl Package for DirectoryPackage {
9589

9690
let root = self.path.join(actual_name);
9791

98-
let manifest = utils::read_file(
99-
"package manifest",
100-
&root.join("manifest.in")
101-
)?;
92+
let manifest = utils::read_file("package manifest", &root.join("manifest.in"))?;
10293
let mut builder = target.add(name, tx);
10394

10495
for l in manifest.lines() {
@@ -114,10 +105,7 @@ impl Package for DirectoryPackage {
114105
_ => return Err(ErrorKind::CorruptComponent(name.to_owned()).into()),
115106
}
116107

117-
set_file_perms(
118-
&target.prefix().path().join(path),
119-
&src_path
120-
)?;
108+
set_file_perms(&target.prefix().path().join(path), &src_path)?;
121109
}
122110

123111
let tx = builder.finish()?;
@@ -169,8 +157,7 @@ fn set_file_perms(dest_path: &Path, src_path: &Path) -> Result<()> {
169157
.chain_err(|| ErrorKind::ComponentFilePermissionsFailed)?;
170158
}
171159
} else {
172-
let meta = fs::metadata(dest_path)
173-
.chain_err(|| ErrorKind::ComponentFilePermissionsFailed)?;
160+
let meta = fs::metadata(dest_path).chain_err(|| ErrorKind::ComponentFilePermissionsFailed)?;
174161
let mut perm = meta.permissions();
175162
perm.set_mode(if is_bin || needs_x(&meta) {
176163
0o755
@@ -209,7 +196,9 @@ impl<'a> TarPackage<'a> {
209196
}
210197

211198
fn unpack_without_first_dir<R: Read>(archive: &mut tar::Archive<R>, path: &Path) -> Result<()> {
212-
let entries = archive.entries().chain_err(|| ErrorKind::ExtractingPackage)?;
199+
let entries = archive
200+
.entries()
201+
.chain_err(|| ErrorKind::ExtractingPackage)?;
213202
for entry in entries {
214203
let mut entry = entry.chain_err(|| ErrorKind::ExtractingPackage)?;
215204
let relpath = {

0 commit comments

Comments
 (0)