Skip to content

Commit 88066c8

Browse files
authored
Rollup merge of #143767 - hkBst:cleanup-x, r=jieyouxu
Bump `src/tools/x` to Edition 2024 and some cleanups - Some clippy fixes - Bump `src/tools/x` to Edition 2024
2 parents 0fb53e7 + dcf965d commit 88066c8

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/tools/x/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
name = "x"
33
version = "0.1.1"
44
description = "Run x.py slightly more conveniently"
5-
edition = "2021"
5+
edition = "2024"
66
publish = false

src/tools/x/src/main.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ const PYTHON2: &str = "python2";
1919
const PYTHON3: &str = "python3";
2020

2121
fn python() -> &'static str {
22-
let val = match env::var_os("PATH") {
23-
Some(val) => val,
24-
None => return PYTHON,
22+
let Some(path) = env::var_os("PATH") else {
23+
return PYTHON;
2524
};
2625

2726
let mut python2 = false;
2827
let mut python3 = false;
2928

30-
for dir in env::split_paths(&val) {
29+
for dir in env::split_paths(&path) {
3130
// `python` should always take precedence over python2 / python3 if it exists
3231
if dir.join(PYTHON).with_extension(EXE_EXTENSION).exists() {
3332
return PYTHON;
@@ -89,7 +88,7 @@ fn exec_or_status(command: &mut Command) -> io::Result<ExitStatus> {
8988
fn handle_result(result: io::Result<ExitStatus>, cmd: Command) {
9089
match result {
9190
Err(error) => {
92-
eprintln!("Failed to invoke `{:?}`: {}", cmd, error);
91+
eprintln!("Failed to invoke `{cmd:?}`: {error}");
9392
}
9493
Ok(status) => {
9594
process::exit(status.code().unwrap_or(1));
@@ -98,22 +97,19 @@ fn handle_result(result: io::Result<ExitStatus>, cmd: Command) {
9897
}
9998

10099
fn main() {
101-
match env::args().skip(1).next().as_deref() {
102-
Some("--wrapper-version") => {
103-
let version = env!("CARGO_PKG_VERSION");
104-
println!("{}", version);
105-
return;
106-
}
107-
_ => {}
100+
if env::args().nth(1).is_some_and(|s| s == "--wrapper-version") {
101+
let version = env!("CARGO_PKG_VERSION");
102+
println!("{version}");
103+
return;
108104
}
105+
109106
let current = match env::current_dir() {
110107
Ok(dir) => dir,
111108
Err(err) => {
112109
eprintln!("Failed to get current directory: {err}");
113110
process::exit(1);
114111
}
115112
};
116-
117113
for dir in current.ancestors() {
118114
let candidate = dir.join("x.py");
119115
if candidate.exists() {

0 commit comments

Comments
 (0)