From 9af0935988ee514bedb1dee7d8d9f979602dd1e4 Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Mon, 27 Jan 2025 01:21:09 +0000 Subject: [PATCH] Account for rust-lang/rust#135880 --- driver/src/lib.rs | 29 ++++++++++++++++++++------ expensive/tests/boundary_toolchains.rs | 3 +++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/driver/src/lib.rs b/driver/src/lib.rs index cbfdc33b9..ff4acddee 100644 --- a/driver/src/lib.rs +++ b/driver/src/lib.rs @@ -350,8 +350,7 @@ pub fn run>(args: &[T]) -> Result<()> { // of the log messages. log::debug!("{:?}", rustc_args); - #[allow(clippy::unit_arg)] - map_run_compiler_err(rustc_driver::RunCompiler::new(&rustc_args, &mut callbacks).run()) + run_compiler(&rustc_args, &mut callbacks) } fn sysroot() -> Result { @@ -422,13 +421,31 @@ fn rustc_args, U: AsRef, V: AsRef>( } #[rustversion::before(2024-12-09)] -fn map_run_compiler_err(result: Result<(), rustc_span::ErrorGuaranteed>) -> Result<()> { - result.map_err(|_| std::process::exit(1)) +fn run_compiler( + at_args: &[String], + callbacks: &mut (dyn rustc_driver::Callbacks + Send), +) -> Result<()> { + rustc_driver::RunCompiler::new(at_args, callbacks) + .run() + .map_err(|_| std::process::exit(1)) } -#[rustversion::since(2024-12-09)] +#[rustversion::all(since(2024-12-09), before(2025-01-24))] #[allow(clippy::unnecessary_wraps)] -const fn map_run_compiler_err((): ()) -> Result<()> { +fn run_compiler( + at_args: &[String], + callbacks: &mut (dyn rustc_driver::Callbacks + Send), +) -> Result<()> { + rustc_driver::RunCompiler::new(at_args, callbacks).run(); + Ok(()) +} + +#[rustversion::since(2025-01-24)] +fn run_compiler( + at_args: &[String], + callbacks: &mut (dyn rustc_driver::Callbacks + Send), +) -> Result<()> { + rustc_driver::run_compiler(at_args, callbacks); Ok(()) } diff --git a/expensive/tests/boundary_toolchains.rs b/expensive/tests/boundary_toolchains.rs index 781ce97fa..54f9b2aef 100644 --- a/expensive/tests/boundary_toolchains.rs +++ b/expensive/tests/boundary_toolchains.rs @@ -18,6 +18,9 @@ use tempfile::tempdir; // smoelius: Put recent boundaries first, since they're more likely to cause problems. // smoelius: The relevant PRs and merge commits appear before each boundary. const BOUNDARIES: &[(&str, &str)] = &[ + // https://github.com/rust-lang/rust/pull/135880 + // https://github.com/rust-lang/rust/commit/7d31ae7f351b4aa0fcb47d1d22e04c275bef0653 + ("2025-01-24", "2025-01-25"), // https://github.com/rust-lang/rust/pull/133567 // https://github.com/rust-lang/rust/commit/d2881e4eb5e0fe1591bfd8e4cab1d5abc3e3a46c ("2024-12-09", "2024-12-10"),