about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Krones <hello@philkrones.com>2025-07-15 18:51:39 +0000
committerGitHub <noreply@github.com>2025-07-15 18:51:39 +0000
commitae1d3aea41c76d1533a401ca72eb113f9c0f05d7 (patch)
tree62cfd7156c6b27d2b4d10226c05beaf147e33947
parentfc441986b4c5aa863b560886df78b48995925deb (diff)
parentd5b10f0c7e8db174b53cf09d2d2fe4c822447f9d (diff)
downloadrust-ae1d3aea41c76d1533a401ca72eb113f9c0f05d7.tar.gz
rust-ae1d3aea41c76d1533a401ca72eb113f9c0f05d7.zip
Use `$RUSTC` instead of `rustc` to get version if var is available (#15250)
Fixes rust-lang/rust-clippy#15249

For the builtin rustc, it should return "dev" as the release channel.
Clippy tests pass with this patch in both the Clippy standalone
repository and from within the compiler repository.

changelog: none
-rw-r--r--rustc_tools_util/src/lib.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/rustc_tools_util/src/lib.rs b/rustc_tools_util/src/lib.rs
index b45edf23455..194ed84d04c 100644
--- a/rustc_tools_util/src/lib.rs
+++ b/rustc_tools_util/src/lib.rs
@@ -157,7 +157,8 @@ pub fn get_commit_date() -> Option<String> {
 
 #[must_use]
 pub fn get_compiler_version() -> Option<String> {
-    get_output("rustc", &["-V"])
+    let compiler = std::option_env!("RUSTC").unwrap_or("rustc");
+    get_output(compiler, &["-V"])
 }
 
 #[must_use]
@@ -172,6 +173,8 @@ pub fn get_channel(compiler_version: Option<String>) -> String {
             return String::from("beta");
         } else if rustc_output.contains("nightly") {
             return String::from("nightly");
+        } else if rustc_output.contains("dev") {
+            return String::from("dev");
         }
     }