Skip to content

Commit 3a1b8e6

Browse files
committed
Rename EarlyDiagCtxt methods to match DiagCtxt.
- `early_error_no_abort` -> `early_err` - `early_error` -> `early_fatal` - `early_struct_error` -> `early_struct_fatal`
1 parent 1f08bfa commit 3a1b8e6

File tree

11 files changed

+92
-93
lines changed

11 files changed

+92
-93
lines changed

compiler/rustc_codegen_cranelift/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub(crate) fn compile_fn(
179179
let early_dcx = rustc_session::EarlyDiagCtxt::new(
180180
rustc_session::config::ErrorOutputType::default(),
181181
);
182-
early_dcx.early_error(format!(
182+
early_dcx.early_fatal(format!(
183183
"backend implementation limit exceeded while compiling {name}",
184184
name = codegened_func.symbol_name
185185
));

compiler/rustc_driver_impl/src/args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn arg_expand_all(early_dcx: &EarlyDiagCtxt, at_args: &[String]) -> Vec<Stri
2828
for arg in at_args {
2929
match arg_expand(arg.clone()) {
3030
Ok(arg) => args.extend(arg),
31-
Err(err) => early_dcx.early_error(format!("Failed to load argument file: {err}")),
31+
Err(err) => early_dcx.early_fatal(format!("Failed to load argument file: {err}")),
3232
}
3333
}
3434
args

compiler/rustc_driver_impl/src/lib.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ fn run_compiler(
345345
Ok(None) => match matches.free.len() {
346346
0 => false, // no input: we will exit early
347347
1 => panic!("make_input should have provided valid inputs"),
348-
_ => default_early_dcx.early_error(format!(
348+
_ => default_early_dcx.early_fatal(format!(
349349
"multiple input filenames provided (first two filenames are `{}` and `{}`)",
350350
matches.free[0], matches.free[1],
351351
)),
@@ -376,7 +376,7 @@ fn run_compiler(
376376
}
377377

378378
if !has_input {
379-
early_dcx.early_error("no input filename given"); // this is fatal
379+
early_dcx.early_fatal("no input filename given"); // this is fatal
380380
}
381381

382382
if !sess.opts.unstable_opts.ls.is_empty() {
@@ -505,9 +505,8 @@ fn make_input(
505505
if io::stdin().read_to_string(&mut src).is_err() {
506506
// Immediately stop compilation if there was an issue reading
507507
// the input (for example if the input stream is not UTF-8).
508-
let reported = early_dcx.early_error_no_abort(
509-
"couldn't read from stdin, as it did not contain valid UTF-8",
510-
);
508+
let reported = early_dcx
509+
.early_err("couldn't read from stdin, as it did not contain valid UTF-8");
511510
return Err(reported);
512511
}
513512
if let Ok(path) = env::var("UNSTABLE_RUSTDOC_TEST_PATH") {
@@ -567,7 +566,7 @@ fn handle_explain(early_dcx: &EarlyDiagCtxt, registry: Registry, code: &str, col
567566
}
568567
}
569568
Err(InvalidErrorCode) => {
570-
early_dcx.early_error(format!("{code} is not a valid error code"));
569+
early_dcx.early_fatal(format!("{code} is not a valid error code"));
571570
}
572571
}
573572
}
@@ -685,7 +684,7 @@ fn list_metadata(early_dcx: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dy
685684
safe_println!("{}", String::from_utf8(v).unwrap());
686685
}
687686
Input::Str { .. } => {
688-
early_dcx.early_error("cannot list metadata for stdin");
687+
early_dcx.early_fatal("cannot list metadata for stdin");
689688
}
690689
}
691690
}
@@ -839,7 +838,7 @@ fn print_crate_info(
839838
println_info!("deployment_target={}", format!("{major}.{minor}"))
840839
} else {
841840
early_dcx
842-
.early_error("only Apple targets currently support deployment version info")
841+
.early_fatal("only Apple targets currently support deployment version info")
843842
}
844843
}
845844
}
@@ -1182,7 +1181,7 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
11821181
.map(|(flag, _)| format!("{e}. Did you mean `-{flag} {opt}`?")),
11831182
_ => None,
11841183
};
1185-
early_dcx.early_error(msg.unwrap_or_else(|| e.to_string()));
1184+
early_dcx.early_fatal(msg.unwrap_or_else(|| e.to_string()));
11861185
});
11871186

11881187
// For all options we just parsed, we check a few aspects:
@@ -1333,7 +1332,7 @@ pub fn install_ice_hook(
13331332
{
13341333
// the error code is already going to be reported when the panic unwinds up the stack
13351334
let early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
1336-
let _ = early_dcx.early_error_no_abort(msg.clone());
1335+
let _ = early_dcx.early_err(msg.clone());
13371336
return;
13381337
}
13391338
};
@@ -1481,7 +1480,7 @@ pub fn init_rustc_env_logger(early_dcx: &EarlyDiagCtxt) {
14811480
/// the values directly rather than having to set an environment variable.
14821481
pub fn init_logger(early_dcx: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) {
14831482
if let Err(error) = rustc_log::init_logger(cfg) {
1484-
early_dcx.early_error(error.to_string());
1483+
early_dcx.early_fatal(error.to_string());
14851484
}
14861485
}
14871486

@@ -1500,7 +1499,7 @@ pub fn main() -> ! {
15001499
.enumerate()
15011500
.map(|(i, arg)| {
15021501
arg.into_string().unwrap_or_else(|arg| {
1503-
early_dcx.early_error(format!("argument {i} is not valid Unicode: {arg:?}"))
1502+
early_dcx.early_fatal(format!("argument {i} is not valid Unicode: {arg:?}"))
15041503
})
15051504
})
15061505
.collect::<Vec<_>>();

compiler/rustc_interface/src/interface.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
347347
) {
348348
Ok(bundle) => bundle,
349349
Err(e) => {
350-
early_dcx.early_error(format!("failed to load fluent bundle: {e}"));
350+
early_dcx.early_fatal(format!("failed to load fluent bundle: {e}"));
351351
}
352352
};
353353

compiler/rustc_interface/src/util.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
164164
fn load_backend_from_dylib(early_dcx: &EarlyDiagCtxt, path: &Path) -> MakeBackendFn {
165165
let lib = unsafe { Library::new(path) }.unwrap_or_else(|err| {
166166
let err = format!("couldn't load codegen backend {path:?}: {err}");
167-
early_dcx.early_error(err);
167+
early_dcx.early_fatal(err);
168168
});
169169

170170
let backend_sym = unsafe { lib.get::<MakeBackendFn>(b"__rustc_codegen_backend") }
171171
.unwrap_or_else(|e| {
172172
let err = format!("couldn't load codegen backend: {e}");
173-
early_dcx.early_error(err);
173+
early_dcx.early_fatal(err);
174174
});
175175

176176
// Intentionally leak the dynamic library. We can't ever unload it
@@ -271,7 +271,7 @@ fn get_codegen_sysroot(
271271
"failed to find a `codegen-backends` folder \
272272
in the sysroot candidates:\n* {candidates}"
273273
);
274-
early_dcx.early_error(err);
274+
early_dcx.early_fatal(err);
275275
});
276276
info!("probing {} for a codegen backend", sysroot.display());
277277

@@ -282,7 +282,7 @@ fn get_codegen_sysroot(
282282
sysroot.display(),
283283
e
284284
);
285-
early_dcx.early_error(err);
285+
early_dcx.early_fatal(err);
286286
});
287287

288288
let mut file: Option<PathBuf> = None;
@@ -310,7 +310,7 @@ fn get_codegen_sysroot(
310310
prev.display(),
311311
path.display()
312312
);
313-
early_dcx.early_error(err);
313+
early_dcx.early_fatal(err);
314314
}
315315
file = Some(path.clone());
316316
}
@@ -319,7 +319,7 @@ fn get_codegen_sysroot(
319319
Some(ref s) => load_backend_from_dylib(early_dcx, s),
320320
None => {
321321
let err = format!("unsupported builtin codegen backend `{backend_name}`");
322-
early_dcx.early_error(err);
322+
early_dcx.early_fatal(err);
323323
}
324324
}
325325
}

0 commit comments

Comments
 (0)