diff options
| author | bors <bors@rust-lang.org> | 2025-02-02 23:15:58 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-02-02 23:15:58 +0000 |
| commit | 613bdd49978298648ed05ace086bd1ecad54b44a (patch) | |
| tree | 3725056656c352d9ce7ae60a63882868a3d6d104 /compiler/rustc_driver_impl/src | |
| parent | 4a43094662727040d8522163f295b19d1aed0e49 (diff) | |
| parent | a8055f944fb99a2d53b444b317d85ff9acbb5562 (diff) | |
| download | rust-613bdd49978298648ed05ace086bd1ecad54b44a.tar.gz rust-613bdd49978298648ed05ace086bd1ecad54b44a.zip | |
Auto merge of #136454 - matthiaskrgr:rollup-ewejzmp, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #136145 (Test validity of pattern types) - #136339 (CompileTest: Add Directives to Ignore `arm-unknown-*` Targets) - #136403 (Fix malformed error annotations in a UI test) - #136414 (Shorten error message for callable with wrong return type) - #136425 (Move `rustc_middle::infer::unify_key`) - #136426 (Explain why we retroactively change a static initializer to have a different type) - #136445 (Couple of cleanups to DiagCtxt and EarlyDiagCtxt) - #136452 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_driver_impl/src')
| -rw-r--r-- | compiler/rustc_driver_impl/src/args.rs | 19 | ||||
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 10 |
2 files changed, 13 insertions, 16 deletions
diff --git a/compiler/rustc_driver_impl/src/args.rs b/compiler/rustc_driver_impl/src/args.rs index 2fc767b3750..b0970144c42 100644 --- a/compiler/rustc_driver_impl/src/args.rs +++ b/compiler/rustc_driver_impl/src/args.rs @@ -1,7 +1,6 @@ use std::{env, error, fmt, fs, io}; use rustc_session::EarlyDiagCtxt; -use rustc_span::ErrorGuaranteed; /// Expands argfiles in command line arguments. #[derive(Default)] @@ -118,22 +117,22 @@ pub fn arg_expand_all(early_dcx: &EarlyDiagCtxt, at_args: &[String]) -> Vec<Stri /// /// This function is identical to [`env::args()`] except that it emits an error when it encounters /// non-Unicode arguments instead of panicking. -pub fn raw_args(early_dcx: &EarlyDiagCtxt) -> Result<Vec<String>, ErrorGuaranteed> { - let mut res = Ok(Vec::new()); +pub fn raw_args(early_dcx: &EarlyDiagCtxt) -> Vec<String> { + let mut args = Vec::new(); + let mut guar = Ok(()); for (i, arg) in env::args_os().enumerate() { match arg.into_string() { - Ok(arg) => { - if let Ok(args) = &mut res { - args.push(arg); - } - } + Ok(arg) => args.push(arg), Err(arg) => { - res = + guar = Err(early_dcx.early_err(format!("argument {i} is not valid Unicode: {arg:?}"))) } } } - res + if let Err(guar) = guar { + guar.raise_fatal(); + } + args } #[derive(Debug)] diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index d4899261487..6ea14d15c14 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -1212,9 +1212,9 @@ pub fn catch_fatal_errors<F: FnOnce() -> R, R>(f: F) -> Result<R, FatalError> { /// Variant of `catch_fatal_errors` for the `interface::Result` return type /// that also computes the exit code. -pub fn catch_with_exit_code(f: impl FnOnce() -> interface::Result<()>) -> i32 { +pub fn catch_with_exit_code(f: impl FnOnce()) -> i32 { match catch_fatal_errors(f) { - Ok(Ok(())) => EXIT_SUCCESS, + Ok(()) => EXIT_SUCCESS, _ => EXIT_FAILURE, } } @@ -1499,10 +1499,8 @@ pub fn main() -> ! { install_ice_hook(DEFAULT_BUG_REPORT_URL, |_| ()); install_ctrlc_handler(); - let exit_code = catch_with_exit_code(|| { - run_compiler(&args::raw_args(&early_dcx)?, &mut callbacks); - Ok(()) - }); + let exit_code = + catch_with_exit_code(|| run_compiler(&args::raw_args(&early_dcx), &mut callbacks)); if let Some(format) = callbacks.time_passes { let end_rss = get_resident_set_size(); |
