Skip to content

Commit 47139f6

Browse files
committed
Warn on clippy::or_fun_call
1 parent 9da57f3 commit 47139f6

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ unused_qualifications = "warn"
165165
dbg_macro = "warn"
166166
manual_let_else = "warn"
167167
needless_pass_by_ref_mut = "warn"
168+
or_fun_call = "warn"
168169
redundant_clone = "warn"
169170
todo = "warn"
170171
use_self = "warn"

src/cli/rustup_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1900,7 +1900,7 @@ async fn doc(
19001900
}
19011901
(None, name) => {
19021902
topic = name;
1903-
let doc_path = doc_page.path().unwrap_or(Path::new("index.html"));
1903+
let doc_path = doc_page.path().unwrap_or_else(|| Path::new("index.html"));
19041904
(Cow::Borrowed(doc_path), None)
19051905
}
19061906
};

src/cli/self_update.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,10 @@ impl InstallOpts<'_> {
207207

208208
self.default_toolchain = Some(MaybeOfficialToolchainName::try_from(common::question_str(
209209
"Default toolchain? (stable/beta/nightly/none)",
210-
&self
211-
.default_toolchain
212-
.as_ref()
213-
.map(ToString::to_string)
214-
.unwrap_or("stable".into()),
210+
&match &self.default_toolchain {
211+
Some(name) => name.to_string(),
212+
None => "stable".to_owned(),
213+
},
215214
process,
216215
)?)?);
217216

@@ -801,10 +800,10 @@ fn current_install_opts(opts: &InstallOpts<'_>, process: &Process) -> String {
801800
.as_ref()
802801
.map(TargetTuple::new)
803802
.unwrap_or_else(|| TargetTuple::from_host_or_build(process)),
804-
opts.default_toolchain
805-
.as_ref()
806-
.map(ToString::to_string)
807-
.unwrap_or("stable (default)".into()),
803+
match &opts.default_toolchain {
804+
Some(name) => name.to_string(),
805+
None => "stable (default)".to_owned(),
806+
},
808807
opts.profile,
809808
if !opts.no_modify_path { "yes" } else { "no" }
810809
)

src/utils/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,14 +402,14 @@ fn copy_and_delete(name: &'static str, src: &Path, dest: &Path) -> Result<()> {
402402
// This uses std::fs::copy() instead of the faster std::fs::rename() to
403403
// avoid cross-device link errors.
404404
if src.is_dir() {
405-
copy_dir(src, dest).and(remove_dir_all::remove_dir_all(src).with_context(|| {
406-
RustupError::RemovingDirectory {
405+
copy_dir(src, dest).and_then(|()| {
406+
remove_dir_all::remove_dir_all(src).with_context(|| RustupError::RemovingDirectory {
407407
name,
408408
path: PathBuf::from(src),
409-
}
410-
}))
409+
})
410+
})
411411
} else {
412-
copy_file(src, dest).and(remove_file(name, src))
412+
copy_file(src, dest).and_then(|()| remove_file(name, src))
413413
}
414414
}
415415

0 commit comments

Comments
 (0)