From abf08329bbcc0a3d7c91c3e5c98c458c77a968cc Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 24 Nov 2023 08:49:37 -0800 Subject: [PATCH 1/2] Replace `option.map(cond) == Some(true)` with `option.is_some_and(cond)` --- scripts/rustc-clif.rs | 2 +- scripts/rustdoc-clif.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/rustc-clif.rs b/scripts/rustc-clif.rs index 33d51bdddea..550f2051553 100644 --- a/scripts/rustc-clif.rs +++ b/scripts/rustc-clif.rs @@ -27,7 +27,7 @@ fn main() { args.push(codegen_backend_arg); } if !passed_args.iter().any(|arg| { - arg == "--sysroot" || arg.to_str().map(|s| s.starts_with("--sysroot=")) == Some(true) + arg == "--sysroot" || arg.to_str().is_some_and(|s| s.starts_with("--sysroot=")) }) { args.push(OsString::from("--sysroot")); args.push(OsString::from(sysroot.to_str().unwrap())); diff --git a/scripts/rustdoc-clif.rs b/scripts/rustdoc-clif.rs index 10582cc7bb3..f7d1bdbc4c6 100644 --- a/scripts/rustdoc-clif.rs +++ b/scripts/rustdoc-clif.rs @@ -27,7 +27,7 @@ fn main() { args.push(codegen_backend_arg); } if !passed_args.iter().any(|arg| { - arg == "--sysroot" || arg.to_str().map(|s| s.starts_with("--sysroot=")) == Some(true) + arg == "--sysroot" || arg.to_str().is_some_and(|s| s.starts_with("--sysroot=")) }) { args.push(OsString::from("--sysroot")); args.push(OsString::from(sysroot.to_str().unwrap())); From 0657c1b932d46b37ff5326d945f83cc52c103869 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 Dec 2023 14:08:10 +1100 Subject: [PATCH 2/2] Give `Handler::fatal` and `Session::fatal` the same return type. Currently, `Handler::fatal` returns `FatalError`. But `Session::fatal` returns `!`, because it calls `Handler::fatal` and then calls `raise` on the result. This inconsistency is unfortunate. This commit changes `Handler::fatal` to do the `raise` itself, changing its return type to `!`. This is safe because there are only two calls to `Handler::fatal`, one in `rustc_session` and one in `rustc_codegen_cranelift`, and they both call `raise` on the result. `HandlerInner::fatal` still returns `FatalError`, so I renamed it `fatal_no_raise` to emphasise the return type difference. --- src/concurrency_limiter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/concurrency_limiter.rs b/src/concurrency_limiter.rs index 20f2ee4c76a..978891f2b0d 100644 --- a/src/concurrency_limiter.rs +++ b/src/concurrency_limiter.rs @@ -64,7 +64,7 @@ impl ConcurrencyLimiter { // Make sure to drop the mutex guard first to prevent poisoning the mutex. drop(state); if let Some(err) = err { - handler.fatal(err).raise(); + handler.fatal(err); } else { // The error was already emitted, but compilation continued. Raise a silent // fatal error.