Skip to content

Commit 613b566

Browse files
committed
chore: Non-controversial clippy cleanups
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
1 parent ecd6cb3 commit 613b566

File tree

8 files changed

+35
-40
lines changed

8 files changed

+35
-40
lines changed

src/cli/rustup_mode.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ pub fn main() -> Result<utils::ExitCode> {
9797
return Ok(utils::ExitCode(0));
9898
}
9999

100-
Err(e) => match &e {
101-
clap::Error { kind, message, .. } => {
100+
Err(e) => {
101+
{
102+
let clap::Error { kind, message, .. } = &e;
102103
if [
103104
InvalidSubcommand,
104105
UnknownArgument,
@@ -109,9 +110,9 @@ pub fn main() -> Result<utils::ExitCode> {
109110
writeln!(process().stdout().lock(), "{}", message)?;
110111
return Ok(utils::ExitCode(1));
111112
}
112-
Err(e)
113113
}
114-
},
114+
Err(e)
115+
}
115116
}?;
116117
let verbose = matches.is_present("verbose");
117118
let quiet = matches.is_present("quiet");
@@ -898,7 +899,7 @@ fn check_updates(cfg: &Cfg) -> Result<utils::ExitCode> {
898899
let available_version = get_available_rustup_version()?;
899900

900901
let _ = t.attr(term2::Attr::Bold);
901-
write!(t, "{} - ", "rustup")?;
902+
write!(t, "rustup - ")?;
902903

903904
if current_version != available_version {
904905
let _ = t.fg(term2::color::YELLOW);
@@ -935,21 +936,18 @@ fn update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
935936

936937
if toolchain_has_triple {
937938
let host_arch = TargetTriple::from_host_or_build();
938-
match ToolchainDesc::from_str(name) {
939-
Ok(toolchain_desc) => {
940-
let target_triple = toolchain_desc.target;
941-
if host_arch.ne(&target_triple) {
942-
warn!(
943-
"toolchain '{}' may not be able to run on this system.",
944-
name
945-
);
946-
warn!(
947-
"If you meant to build software to target that platform, perhaps try `rustup target add {}` instead?",
948-
target_triple.to_string()
949-
);
950-
}
939+
if let Ok(toolchain_desc) = ToolchainDesc::from_str(name) {
940+
let target_triple = toolchain_desc.target;
941+
if host_arch.ne(&target_triple) {
942+
warn!(
943+
"toolchain '{}' may not be able to run on this system.",
944+
name
945+
);
946+
warn!(
947+
"If you meant to build software to target that platform, perhaps try `rustup target add {}` instead?",
948+
target_triple.to_string()
949+
);
951950
}
952-
_ => (),
953951
}
954952
}
955953

src/dist/component/package.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn unpack_without_first_dir<'a, R: Read>(
323323
// TODO capture metrics
324324
budget.reclaim(&item);
325325
filter_result(&mut item).chain_err(|| ErrorKind::ExtractingPackage)?;
326-
trigger_children(&mut *io_executor, &mut directories, &mut budget, item)?;
326+
trigger_children(&*io_executor, &mut directories, &mut budget, item)?;
327327
}
328328

329329
let mut entry = entry.chain_err(|| ErrorKind::ExtractingPackage)?;
@@ -461,7 +461,7 @@ fn unpack_without_first_dir<'a, R: Read>(
461461
// TODO capture metrics
462462
budget.reclaim(&item);
463463
filter_result(&mut item).chain_err(|| ErrorKind::ExtractingPackage)?;
464-
trigger_children(&mut *io_executor, &mut directories, &mut budget, item)?;
464+
trigger_children(&*io_executor, &mut directories, &mut budget, item)?;
465465
}
466466
}
467467

@@ -472,7 +472,7 @@ fn unpack_without_first_dir<'a, R: Read>(
472472
// TODO capture metrics
473473
budget.reclaim(&item);
474474
filter_result(&mut item).chain_err(|| ErrorKind::ExtractingPackage)?;
475-
triggered += trigger_children(&mut *io_executor, &mut directories, &mut budget, item)?;
475+
triggered += trigger_children(&*io_executor, &mut directories, &mut budget, item)?;
476476
}
477477
if triggered == 0 {
478478
// None of the IO submitted before the prior join triggered any new

src/dist/dist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl FromStr for ParsedToolchainDesc {
107107

108108
let d = TOOLCHAIN_CHANNEL_RE.captures(desc).map(|c| {
109109
fn fn_map(s: &str) -> Option<String> {
110-
if s == "" {
110+
if s.is_empty() {
111111
None
112112
} else {
113113
Some(s.to_owned())
@@ -858,7 +858,7 @@ pub fn dl_v2_manifest<'a>(
858858
}
859859
}
860860

861-
fn dl_v1_manifest<'a>(download: DownloadCfg<'a>, toolchain: &ToolchainDesc) -> Result<Vec<String>> {
861+
fn dl_v1_manifest(download: DownloadCfg<'_>, toolchain: &ToolchainDesc) -> Result<Vec<String>> {
862862
let root_url = toolchain.package_dir(download.dist_root);
863863

864864
if !["nightly", "beta", "stable"].contains(&&*toolchain.channel) {

src/dist/notifications.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'a> Display for Notification<'a> {
186186
if component.target.as_ref() != Some(&toolchain.target) {
187187
component.name(manifest)
188188
} else {
189-
component.short_name(manifest).to_owned()
189+
component.short_name(manifest)
190190
}
191191
})
192192
.collect::<Vec<_>>()

src/dist/triple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl PartialTargetTriple {
7777
}
7878
RE.captures(&name).map(|c| {
7979
fn fn_map(s: &str) -> Option<String> {
80-
if s == "" {
80+
if s.is_empty() {
8181
None
8282
} else {
8383
Some(s.to_owned())

src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,9 @@ fn component_unavailable_msg(cs: &[Component], manifest: &Manifest, toolchain: &
423423
let mut buf = vec![];
424424

425425
if cs.len() == 1 {
426-
let _ = write!(
426+
let _ = writeln!(
427427
buf,
428-
"component {} is unavailable for download for channel '{}'\n",
428+
"component {} is unavailable for download for channel '{}'",
429429
&cs[0].description(manifest),
430430
toolchain,
431431
);

src/utils/units.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ mod tests {
8383

8484
// Test Bytes
8585
assert_eq!(
86-
format!("{}", Size::new(1 as usize, Unit::B, UnitMode::Norm)),
86+
format!("{}", Size::new(1, Unit::B, UnitMode::Norm)),
8787
" 1 B"
8888
);
8989
assert_eq!(
90-
format!("{}", Size::new(1024 as usize, Unit::B, UnitMode::Norm)),
90+
format!("{}", Size::new(1024, Unit::B, UnitMode::Norm)),
9191
" 1.0 KiB"
9292
);
9393
assert_eq!(
@@ -101,11 +101,11 @@ mod tests {
101101

102102
// Test Bytes at given rate
103103
assert_eq!(
104-
format!("{}", Size::new(1 as usize, Unit::B, UnitMode::Rate)),
104+
format!("{}", Size::new(1, Unit::B, UnitMode::Rate)),
105105
" 1 B/s"
106106
);
107107
assert_eq!(
108-
format!("{}", Size::new(1024 as usize, Unit::B, UnitMode::Rate)),
108+
format!("{}", Size::new(1024, Unit::B, UnitMode::Rate)),
109109
" 1.0 KiB/s"
110110
);
111111
assert_eq!(
@@ -119,11 +119,11 @@ mod tests {
119119

120120
//Test I/O Operations
121121
assert_eq!(
122-
format!("{}", Size::new(1 as usize, Unit::IO, UnitMode::Norm)),
122+
format!("{}", Size::new(1, Unit::IO, UnitMode::Norm)),
123123
" 1 IO-ops"
124124
);
125125
assert_eq!(
126-
format!("{}", Size::new(1000 as usize, Unit::IO, UnitMode::Norm)),
126+
format!("{}", Size::new(1000, Unit::IO, UnitMode::Norm)),
127127
" 1.0 kilo-IO-ops"
128128
);
129129
assert_eq!(
@@ -137,11 +137,11 @@ mod tests {
137137

138138
//Test I/O Operations at given rate
139139
assert_eq!(
140-
format!("{}", Size::new(1 as usize, Unit::IO, UnitMode::Rate)),
140+
format!("{}", Size::new(1, Unit::IO, UnitMode::Rate)),
141141
" 1 IOPS"
142142
);
143143
assert_eq!(
144-
format!("{}", Size::new(1000 as usize, Unit::IO, UnitMode::Rate)),
144+
format!("{}", Size::new(1000, Unit::IO, UnitMode::Rate)),
145145
" 1.0 kilo-IOPS"
146146
);
147147
assert_eq!(

tests/cli-paths.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ export PATH="$HOME/apple/bin"
5353
let mut rcs = files.iter();
5454
let env = rcs.next().unwrap();
5555
let envfile = fs::read_to_string(&env).unwrap();
56-
let (_, envfile_export) = envfile.split_at(match envfile.find("export PATH") {
57-
Some(idx) => idx,
58-
None => 0,
59-
});
56+
let (_, envfile_export) = envfile.split_at(envfile.find("export PATH").unwrap_or(0));
6057
assert_eq!(&envfile_export[..DEFAULT_EXPORT.len()], DEFAULT_EXPORT);
6158

6259
for rc in rcs {

0 commit comments

Comments
 (0)