about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-07-11 19:45:25 +0200
committerGitHub <noreply@github.com>2025-07-11 19:45:25 +0200
commit8c5f3e415a160efc9b29fd88a862761a43f8f20b (patch)
tree67ed14804c338c4236376a2526f2044138d02a6d /src
parent93caee661a674f2ab95f7fc7ac6202680fc2b2fc (diff)
parentdcf965d65271c76b3cb73e53b91147905f811f34 (diff)
downloadrust-8c5f3e415a160efc9b29fd88a862761a43f8f20b.tar.gz
rust-8c5f3e415a160efc9b29fd88a862761a43f8f20b.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/tools/x/Cargo.toml2
-rw-r--r--src/tools/x/src/main.rs22
2 files changed, 10 insertions, 14 deletions
diff --git a/src/tools/x/Cargo.toml b/src/tools/x/Cargo.toml
index 84a42ca36ef..c59f5ff52a0 100644
--- a/src/tools/x/Cargo.toml
+++ b/src/tools/x/Cargo.toml
@@ -2,5 +2,5 @@
 name = "x"
 version = "0.1.1"
 description = "Run x.py slightly more conveniently"
-edition = "2021"
+edition = "2024"
 publish = false
diff --git a/src/tools/x/src/main.rs b/src/tools/x/src/main.rs
index b288cfcd5be..93167141d34 100644
--- a/src/tools/x/src/main.rs
+++ b/src/tools/x/src/main.rs
@@ -19,15 +19,14 @@ const PYTHON2: &str = "python2";
 const PYTHON3: &str = "python3";
 
 fn python() -> &'static str {
-    let val = match env::var_os("PATH") {
-        Some(val) => val,
-        None => return PYTHON,
+    let Some(path) = env::var_os("PATH") else {
+        return PYTHON;
     };
 
     let mut python2 = false;
     let mut python3 = false;
 
-    for dir in env::split_paths(&val) {
+    for dir in env::split_paths(&path) {
         // `python` should always take precedence over python2 / python3 if it exists
         if dir.join(PYTHON).with_extension(EXE_EXTENSION).exists() {
             return PYTHON;
@@ -89,7 +88,7 @@ fn exec_or_status(command: &mut Command) -> io::Result<ExitStatus> {
 fn handle_result(result: io::Result<ExitStatus>, cmd: Command) {
     match result {
         Err(error) => {
-            eprintln!("Failed to invoke `{:?}`: {}", cmd, error);
+            eprintln!("Failed to invoke `{cmd:?}`: {error}");
         }
         Ok(status) => {
             process::exit(status.code().unwrap_or(1));
@@ -98,14 +97,12 @@ fn handle_result(result: io::Result<ExitStatus>, cmd: Command) {
 }
 
 fn main() {
-    match env::args().skip(1).next().as_deref() {
-        Some("--wrapper-version") => {
-            let version = env!("CARGO_PKG_VERSION");
-            println!("{}", version);
-            return;
-        }
-        _ => {}
+    if env::args().nth(1).is_some_and(|s| s == "--wrapper-version") {
+        let version = env!("CARGO_PKG_VERSION");
+        println!("{version}");
+        return;
     }
+
     let current = match env::current_dir() {
         Ok(dir) => dir,
         Err(err) => {
@@ -113,7 +110,6 @@ fn main() {
             process::exit(1);
         }
     };
-
     for dir in current.ancestors() {
         let candidate = dir.join("x.py");
         if candidate.exists() {