diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2023-05-18 10:52:35 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-18 10:52:35 +0530 |
| commit | 08efb9d652c840715d15954592426e2befe13b36 (patch) | |
| tree | aa97bae80b39c4e36910dd711e499002f5ab59cd /compiler/rustc_interface/src | |
| parent | cdfaf69498e339b02a90193cc842eed462c8e589 (diff) | |
| parent | 01e33a3600789b0e96511c4ac95fc114b507c79e (diff) | |
| download | rust-08efb9d652c840715d15954592426e2befe13b36.tar.gz rust-08efb9d652c840715d15954592426e2befe13b36.zip | |
Rollup merge of #111633 - nnethercote:avoid-ref-format, r=WaffleLapkin
Avoid `&format("...")` calls in error message code.
Some error message cleanups. Best reviewed one commit at a time.
r? `@davidtwco`
Diffstat (limited to 'compiler/rustc_interface/src')
| -rw-r--r-- | compiler/rustc_interface/src/interface.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/util.rs | 14 |
2 files changed, 9 insertions, 12 deletions
diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index c9e857141c9..681819703c2 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -80,7 +80,7 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String ($reason: expr) => { early_error( ErrorOutputType::default(), - &format!(concat!("invalid `--cfg` argument: `{}` (", $reason, ")"), s), + format!(concat!("invalid `--cfg` argument: `{}` (", $reason, ")"), s), ); }; } @@ -139,10 +139,7 @@ pub fn parse_check_cfg(specs: Vec<String>) -> CheckCfg { ($reason: expr) => { early_error( ErrorOutputType::default(), - &format!( - concat!("invalid `--check-cfg` argument: `{}` (", $reason, ")"), - s - ), + format!(concat!("invalid `--check-cfg` argument: `{}` (", $reason, ")"), s), ) }; } diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 8d37b1053d8..910cafff769 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -88,7 +88,7 @@ pub fn create_session( ) { Ok(bundle) => bundle, Err(e) => { - early_error(sopts.error_format, &format!("failed to load fluent bundle: {e}")); + early_error(sopts.error_format, format!("failed to load fluent bundle: {e}")); } }; @@ -220,13 +220,13 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>( fn load_backend_from_dylib(path: &Path) -> MakeBackendFn { let lib = unsafe { Library::new(path) }.unwrap_or_else(|err| { let err = format!("couldn't load codegen backend {path:?}: {err}"); - early_error(ErrorOutputType::default(), &err); + early_error(ErrorOutputType::default(), err); }); let backend_sym = unsafe { lib.get::<MakeBackendFn>(b"__rustc_codegen_backend") } .unwrap_or_else(|e| { let err = format!("couldn't load codegen backend: {e}"); - early_error(ErrorOutputType::default(), &err); + early_error(ErrorOutputType::default(), err); }); // Intentionally leak the dynamic library. We can't ever unload it @@ -320,7 +320,7 @@ fn get_codegen_sysroot(maybe_sysroot: &Option<PathBuf>, backend_name: &str) -> M "failed to find a `codegen-backends` folder \ in the sysroot candidates:\n* {candidates}" ); - early_error(ErrorOutputType::default(), &err); + early_error(ErrorOutputType::default(), err); }); info!("probing {} for a codegen backend", sysroot.display()); @@ -331,7 +331,7 @@ fn get_codegen_sysroot(maybe_sysroot: &Option<PathBuf>, backend_name: &str) -> M sysroot.display(), e ); - early_error(ErrorOutputType::default(), &err); + early_error(ErrorOutputType::default(), err); }); let mut file: Option<PathBuf> = None; @@ -359,7 +359,7 @@ fn get_codegen_sysroot(maybe_sysroot: &Option<PathBuf>, backend_name: &str) -> M prev.display(), path.display() ); - early_error(ErrorOutputType::default(), &err); + early_error(ErrorOutputType::default(), err); } file = Some(path.clone()); } @@ -368,7 +368,7 @@ fn get_codegen_sysroot(maybe_sysroot: &Option<PathBuf>, backend_name: &str) -> M Some(ref s) => load_backend_from_dylib(s), None => { let err = format!("unsupported builtin codegen backend `{backend_name}`"); - early_error(ErrorOutputType::default(), &err); + early_error(ErrorOutputType::default(), err); } } } |
