Avoid a couple of unnecessary EarlyDiagCtxt uses
This commit is contained in:
parent
e3ffbbd226
commit
8d1f5b30ef
@ -367,18 +367,17 @@ fn run_compiler(
|
|||||||
return early_exit();
|
return early_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
let early_dcx = EarlyDiagCtxt::new(sess.opts.error_format);
|
if print_crate_info(codegen_backend, sess, has_input) == Compilation::Stop {
|
||||||
|
|
||||||
if print_crate_info(&early_dcx, codegen_backend, sess, has_input) == Compilation::Stop {
|
|
||||||
return early_exit();
|
return early_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if !has_input {
|
if !has_input {
|
||||||
early_dcx.early_fatal("no input filename given"); // this is fatal
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
|
sess.dcx().fatal("no input filename given"); // this is fatal
|
||||||
}
|
}
|
||||||
|
|
||||||
if !sess.opts.unstable_opts.ls.is_empty() {
|
if !sess.opts.unstable_opts.ls.is_empty() {
|
||||||
list_metadata(&early_dcx, sess, &*codegen_backend.metadata_loader());
|
list_metadata(sess, &*codegen_backend.metadata_loader());
|
||||||
return early_exit();
|
return early_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -674,7 +673,7 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_metadata(early_dcx: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dyn MetadataLoader) {
|
fn list_metadata(sess: &Session, metadata_loader: &dyn MetadataLoader) {
|
||||||
match sess.io.input {
|
match sess.io.input {
|
||||||
Input::File(ref ifile) => {
|
Input::File(ref ifile) => {
|
||||||
let path = &(*ifile);
|
let path = &(*ifile);
|
||||||
@ -691,13 +690,13 @@ fn list_metadata(early_dcx: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dy
|
|||||||
safe_println!("{}", String::from_utf8(v).unwrap());
|
safe_println!("{}", String::from_utf8(v).unwrap());
|
||||||
}
|
}
|
||||||
Input::Str { .. } => {
|
Input::Str { .. } => {
|
||||||
early_dcx.early_fatal("cannot list metadata for stdin");
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
|
sess.dcx().fatal("cannot list metadata for stdin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_crate_info(
|
fn print_crate_info(
|
||||||
early_dcx: &EarlyDiagCtxt,
|
|
||||||
codegen_backend: &dyn CodegenBackend,
|
codegen_backend: &dyn CodegenBackend,
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
parse_attrs: bool,
|
parse_attrs: bool,
|
||||||
@ -881,8 +880,8 @@ fn print_crate_info(
|
|||||||
.expect("unknown Apple target OS");
|
.expect("unknown Apple target OS");
|
||||||
println_info!("deployment_target={}", format!("{major}.{minor}"))
|
println_info!("deployment_target={}", format!("{major}.{minor}"))
|
||||||
} else {
|
} else {
|
||||||
early_dcx
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
.early_fatal("only Apple targets currently support deployment version info")
|
sess.dcx().fatal("only Apple targets currently support deployment version info")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,3 +4,5 @@ warning: failed to connect to jobserver from environment variable `MAKEFLAGS="--
|
|||||||
|
|
||||||
error: no input filename given
|
error: no input filename given
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use run_make_support::rustc;
|
use run_make_support::rustc;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
rustc()
|
rustc().print("crate-name").run_fail().assert_exit_code(1).assert_stderr_equals(
|
||||||
.print("crate-name")
|
"error: no input filename given
|
||||||
.run_fail()
|
|
||||||
.assert_exit_code(1)
|
error: aborting due to 1 previous error",
|
||||||
.assert_stderr_equals("error: no input filename given");
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
error: only Apple targets currently support deployment version info
|
error: only Apple targets currently support deployment version info
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user