Skip to content

Commit 9ed1843

Browse files
committed
dogfood clippy::or_fun_call
1 parent 19c1c70 commit 9ed1843

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

clippy_dev/src/lint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn run<'a>(path: &str, edition: &str, args: impl Iterator<Item = &'a String>
1313

1414
if is_file {
1515
exit_if_err(
16-
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
16+
Command::new(env::var("CARGO").unwrap_or_else(|_| "cargo".into()))
1717
.args(["run", "--bin", "clippy-driver", "--"])
1818
.args(["-L", "./target/debug"])
1919
.args(["-Z", "no-codegen"])
@@ -26,7 +26,7 @@ pub fn run<'a>(path: &str, edition: &str, args: impl Iterator<Item = &'a String>
2626
);
2727
} else {
2828
exit_if_err(
29-
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
29+
Command::new(env::var("CARGO").unwrap_or_else(|_| "cargo".into()))
3030
.arg("build")
3131
.status(),
3232
);

clippy_dev/src/serve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn run(port: u16, lint: Option<String>) -> ! {
2828
.map(mtime);
2929

3030
if times.iter().any(|&time| index_time < time) {
31-
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
31+
Command::new(env::var("CARGO").unwrap_or_else(|_| "cargo".into()))
3232
.arg("collect-metadata")
3333
.spawn()
3434
.unwrap()

clippy_lints/src/attrs/utils.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ pub(super) fn is_relevant_trait(cx: &LateContext<'_>, item: &TraitItem<'_>) -> b
4646
}
4747

4848
fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, block: &Block<'_>) -> bool {
49-
block.stmts.first().map_or(
50-
block
51-
.expr
52-
.as_ref()
53-
.is_some_and(|e| is_relevant_expr(cx, typeck_results, e)),
49+
block.stmts.first().map_or_else(
50+
|| {
51+
block
52+
.expr
53+
.as_ref()
54+
.is_some_and(|e| is_relevant_expr(cx, typeck_results, e))
55+
},
5456
|stmt| match &stmt.kind {
5557
StmtKind::Let(_) => true,
5658
StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, typeck_results, expr),

lintcheck/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use rayon::prelude::*;
4545

4646
#[must_use]
4747
pub fn target_dir() -> String {
48-
env::var("CARGO_TARGET_DIR").unwrap_or("target".to_owned())
48+
env::var("CARGO_TARGET_DIR").unwrap_or_else(|_| "target".to_owned())
4949
}
5050

5151
fn lintcheck_sources() -> String {

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl ClippyCmd {
107107
}
108108

109109
fn into_std_cmd(self) -> Command {
110-
let mut cmd = Command::new(env::var("CARGO").unwrap_or("cargo".into()));
110+
let mut cmd = Command::new(env::var("CARGO").unwrap_or_else(|_| "cargo".into()));
111111
let clippy_args: String = self
112112
.clippy_args
113113
.iter()

0 commit comments

Comments
 (0)