Skip to content

Commit e6c0a3c

Browse files
committed
Fix all current clippy lints
1 parent d3bb61a commit e6c0a3c

File tree

16 files changed

+54
-57
lines changed

16 files changed

+54
-57
lines changed

src/cli/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ fn show_channel_updates(
183183
) -> Result<()> {
184184
let data = toolchains.into_iter().map(|(name, result)| {
185185
let toolchain = cfg.get_toolchain(&name, false).unwrap();
186-
let mut version: String = toolchain.rustc_version().into();
186+
let mut version: String = toolchain.rustc_version();
187187

188188
let banner;
189189
let color;
@@ -486,12 +486,12 @@ pub fn list_toolchains(cfg: &Cfg, verbose: bool) -> Result<utils::ExitCode> {
486486
String::new()
487487
};
488488
for toolchain in toolchains {
489-
let if_default = if def_toolchain_name == &*toolchain {
489+
let if_default = if def_toolchain_name == *toolchain {
490490
" (default)"
491491
} else {
492492
""
493493
};
494-
let if_override = if ovr_toolchain_name == &*toolchain {
494+
let if_override = if ovr_toolchain_name == *toolchain {
495495
" (override)"
496496
} else {
497497
""

src/cli/self_update.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ info: default host triple is {0}
11491149
vars,
11501150
..Default::default()
11511151
});
1152-
currentprocess::with(tp.clone(), || -> anyhow::Result<()> {
1152+
currentprocess::with(tp, || -> anyhow::Result<()> {
11531153
super::install_bins().unwrap();
11541154
Ok(())
11551155
})

src/cli/self_update/windows.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn get_windows_path_var() -> Result<Option<String>> {
214214
} else {
215215
warn!("the registry key HKEY_CURRENT_USER\\Environment\\PATH does not contain valid Unicode. \
216216
Not modifying the PATH variable");
217-
return Ok(None);
217+
Ok(None)
218218
}
219219
}
220220
Err(ref e) if e.kind() == io::ErrorKind::NotFound => Ok(Some(String::new())),
@@ -230,7 +230,7 @@ fn _add_to_path(old_path: &str, path_str: String) -> Option<String> {
230230
} else if old_path.contains(&path_str) {
231231
None
232232
} else {
233-
let mut new_path = path_str.clone();
233+
let mut new_path = path_str;
234234
new_path.push_str(";");
235235
new_path.push_str(&old_path);
236236
Some(new_path)
@@ -471,8 +471,11 @@ mod tests {
471471
.unwrap();
472472
environment.delete_value("PATH").unwrap();
473473

474-
assert_eq!((), super::_apply_new_path(Some("foo".into())).unwrap());
475-
474+
{
475+
// Can't compare the Results as Eq isn't derived; thanks error-chain.
476+
#![allow(clippy::unit_cmp)]
477+
assert_eq!((), super::_apply_new_path(Some("foo".into())).unwrap());
478+
}
476479
let root = RegKey::predef(HKEY_CURRENT_USER);
477480
let environment = root
478481
.open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE)
@@ -506,8 +509,11 @@ mod tests {
506509
)
507510
.unwrap();
508511

509-
assert_eq!((), super::_apply_new_path(Some("".into())).unwrap());
510-
512+
{
513+
// Can't compare the Results as Eq isn't derived; thanks error-chain.
514+
#![allow(clippy::unit_cmp)]
515+
assert_eq!((), super::_apply_new_path(Some("".into())).unwrap());
516+
}
511517
let reg_value = environment.get_raw_value("PATH");
512518
match reg_value {
513519
Ok(_) => panic!("key not deleted"),

src/cli/setup_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub fn main() -> Result<utils::ExitCode> {
101101
writeln!(process().stdout().lock(), "{}", e.message)?;
102102
return Ok(utils::ExitCode(0));
103103
}
104-
Err(e) => Err(e)?,
104+
Err(e) => return Err(e.into()),
105105
};
106106
let no_prompt = matches.is_present("no-prompt");
107107
let verbose = matches.is_present("verbose");

src/cli/term2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,26 @@ mod termhack {
7676
/// opened.
7777
#[allow(unused)]
7878
pub fn stdout(terminfo: Option<TermInfo>) -> Option<Box<StdoutTerminal>> {
79-
make_terminal(terminfo, || io::stdout())
79+
make_terminal(terminfo, io::stdout)
8080
}
8181

8282
/// Return a Terminal wrapping stderr, or None if a terminal couldn't be
8383
/// opened.
8484
#[allow(unused)]
8585
pub fn stderr(terminfo: Option<TermInfo>) -> Option<Box<StderrTerminal>> {
86-
make_terminal(terminfo, || io::stderr())
86+
make_terminal(terminfo, io::stderr)
8787
}
8888

8989
/// Return a Terminal wrapping stdout.
9090
#[allow(unused)]
9191
pub fn stdout_with_fallback(terminfo: Option<TermInfo>) -> Box<StdoutTerminal> {
92-
make_terminal_with_fallback(terminfo, || io::stdout())
92+
make_terminal_with_fallback(terminfo, io::stdout)
9393
}
9494

9595
/// Return a Terminal wrapping stderr.
9696
#[allow(unused)]
9797
pub fn stderr_with_fallback(terminfo: Option<TermInfo>) -> Box<StderrTerminal> {
98-
make_terminal_with_fallback(terminfo, || io::stderr())
98+
make_terminal_with_fallback(terminfo, io::stderr)
9999
}
100100
}
101101

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ impl Cfg {
585585
let contents = contents.as_ref();
586586

587587
match contents.lines().count() {
588-
0 => return Err(ErrorKind::EmptyOverrideFile.into()),
588+
0 => Err(ErrorKind::EmptyOverrideFile.into()),
589589
1 => {
590590
let channel = contents.trim();
591591

src/currentprocess.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ where
147147
});
148148

149149
PROCESS.with(|p| {
150-
if let Some(_) = *p.borrow() {
151-
panic!("current process already set {}");
150+
if let Some(old_p) = &*p.borrow() {
151+
panic!("current process already set {:?}", old_p);
152152
}
153153
*p.borrow_mut() = Some(process);
154154
let result = f();

src/dist/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ impl TargetedPackage {
440440
if !extensions.is_empty() {
441441
result.insert("extensions".to_owned(), toml::Value::Array(extensions));
442442
}
443-
if let Some(bins) = self.bins.clone() {
443+
if let Some(bins) = self.bins {
444444
result.insert("hash".to_owned(), toml::Value::String(bins.hash));
445445
result.insert("url".to_owned(), toml::Value::String(bins.url));
446446
if let (Some(xz_hash), Some(xz_url)) = (bins.xz_hash, bins.xz_url) {

src/dist/notifications.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<'a> Display for Notification<'a> {
182182
.iter()
183183
.map(|component| {
184184
if component.target.as_ref() != Some(&toolchain.target) {
185-
component.name_in_manifest().to_owned()
185+
component.name_in_manifest()
186186
} else {
187187
component.short_name_in_manifest().to_owned()
188188
}

src/test.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ pub fn this_host_triple() -> String {
8686
// building with i686 toolchain, but on an x86_64 host, so run the
8787
// actual detection logic and trust it.
8888
let tp = Box::new(currentprocess::TestProcess::default());
89-
return currentprocess::with(tp.clone(), || {
90-
TargetTriple::from_host().unwrap().to_string()
91-
});
89+
return currentprocess::with(tp, || TargetTriple::from_host().unwrap().to_string());
9290
}
9391
let arch = if cfg!(target_arch = "x86") {
9492
"i686"

0 commit comments

Comments
 (0)