Inline process_rlink into try_process_rlink

This commit is contained in:
bjorn3 2021-03-28 19:00:49 +02:00
parent 2fa7175293
commit 2acdc87700

View File

@ -599,7 +599,8 @@ fn show_content_with_pager(content: &str) {
}
impl RustcDefaultCalls {
fn process_rlink(sess: &Session, compiler: &interface::Compiler) -> Result<(), ErrorReported> {
pub fn try_process_rlink(sess: &Session, compiler: &interface::Compiler) -> Compilation {
if sess.opts.debugging_opts.link_only {
if let Input::File(file) = compiler.input() {
// FIXME: #![crate_type] and #![crate_name] support not implemented yet
let attrs = vec![];
@ -608,19 +609,15 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) -> Result<(), E
let rlink_data = fs::read_to_string(file).unwrap_or_else(|err| {
sess.fatal(&format!("failed to read rlink file: {}", err));
});
let codegen_results: CodegenResults = json::decode(&rlink_data).unwrap_or_else(|err| {
let codegen_results: CodegenResults =
json::decode(&rlink_data).unwrap_or_else(|err| {
sess.fatal(&format!("failed to decode rlink: {}", err));
});
compiler.codegen_backend().link(&sess, codegen_results, &outputs)
let result = compiler.codegen_backend().link(&sess, codegen_results, &outputs);
abort_on_err(result, sess);
} else {
sess.fatal("rlink must be a file")
}
}
pub fn try_process_rlink(sess: &Session, compiler: &interface::Compiler) -> Compilation {
if sess.opts.debugging_opts.link_only {
let result = RustcDefaultCalls::process_rlink(sess, compiler);
abort_on_err(result, sess);
Compilation::Stop
} else {
Compilation::Continue