From b961660ce9b4f538ebd504acd6fa6a586a179b30 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 25 Apr 2024 15:29:51 +0000 Subject: [PATCH] Make RUSTC_FORCE_RUSTC_VERSION overwrite the rendered version output, too --- compiler/rustc_driver_impl/src/lib.rs | 9 +++++++++ tests/ui/feature-gates/version_check.rs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index b3cba4dbfc20e..f5b73a58b64c9 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -878,6 +878,15 @@ pub fn version_at_macro_invocation( ) { let verbose = matches.opt_present("verbose"); + let mut version = version; + let mut release = release; + let tmp; + if let Ok(force_version) = std::env::var("RUSTC_FORCE_RUSTC_VERSION") { + tmp = force_version; + version = &tmp; + release = &tmp; + } + safe_println!("{binary} {version}"); if verbose { diff --git a/tests/ui/feature-gates/version_check.rs b/tests/ui/feature-gates/version_check.rs index fd0d0ab8c003a..42f8656a0a039 100644 --- a/tests/ui/feature-gates/version_check.rs +++ b/tests/ui/feature-gates/version_check.rs @@ -10,5 +10,5 @@ fn main() { .unwrap() .stdout; let version = std::str::from_utf8(&version).unwrap().strip_prefix("rustc ").unwrap().trim_end(); - assert_ne!(version, signalled_version); + assert_eq!(version, signalled_version); }