Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ede9923

Browse files
committedFeb 16, 2024
Make CodegenBackend::join_codegen infallible.
Because they all are, in practice.
1 parent cbddf31 commit ede9923

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed
 

‎compiler/rustc_codegen_cranelift/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ impl CodegenBackend for CraneliftCodegenBackend {
233233
ongoing_codegen: Box<dyn Any>,
234234
sess: &Session,
235235
_outputs: &OutputFilenames,
236-
) -> Result<(CodegenResults, FxIndexMap<WorkProductId, WorkProduct>), ErrorGuaranteed> {
237-
Ok(ongoing_codegen
236+
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
237+
ongoing_codegen
238238
.downcast::<driver::aot::OngoingCodegen>()
239239
.unwrap()
240-
.join(sess, self.config.borrow().as_ref().unwrap()))
240+
.join(sess, self.config.borrow().as_ref().unwrap())
241241
}
242242

243243
fn link(

‎compiler/rustc_codegen_gcc/src/lib.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,11 @@ impl CodegenBackend for GccCodegenBackend {
217217
Box::new(res)
218218
}
219219

220-
fn join_codegen(&self, ongoing_codegen: Box<dyn Any>, sess: &Session, _outputs: &OutputFilenames) -> Result<(CodegenResults, FxIndexMap<WorkProductId, WorkProduct>), ErrorGuaranteed> {
221-
let (codegen_results, work_products) = ongoing_codegen
220+
fn join_codegen(&self, ongoing_codegen: Box<dyn Any>, sess: &Session, _outputs: &OutputFilenames) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
221+
ongoing_codegen
222222
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<GccCodegenBackend>>()
223223
.expect("Expected GccCodegenBackend's OngoingCodegen, found Box<Any>")
224-
.join(sess);
225-
226-
Ok((codegen_results, work_products))
224+
.join(sess)
227225
}
228226

229227
fn link(&self, sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames) -> Result<(), ErrorGuaranteed> {

‎compiler/rustc_codegen_llvm/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl CodegenBackend for LlvmCodegenBackend {
369369
ongoing_codegen: Box<dyn Any>,
370370
sess: &Session,
371371
outputs: &OutputFilenames,
372-
) -> Result<(CodegenResults, FxIndexMap<WorkProductId, WorkProduct>), ErrorGuaranteed> {
372+
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
373373
let (codegen_results, work_products) = ongoing_codegen
374374
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<LlvmCodegenBackend>>()
375375
.expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>")
@@ -382,7 +382,7 @@ impl CodegenBackend for LlvmCodegenBackend {
382382
});
383383
}
384384

385-
Ok((codegen_results, work_products))
385+
(codegen_results, work_products)
386386
}
387387

388388
fn link(

‎compiler/rustc_codegen_ssa/src/traits/backend.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub trait CodegenBackend {
102102
ongoing_codegen: Box<dyn Any>,
103103
sess: &Session,
104104
outputs: &OutputFilenames,
105-
) -> Result<(CodegenResults, FxIndexMap<WorkProductId, WorkProduct>), ErrorGuaranteed>;
105+
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>);
106106

107107
/// This is called on the returned `CodegenResults` from `join_codegen`
108108
fn link(

‎compiler/rustc_interface/src/queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub struct Linker {
259259
impl Linker {
260260
pub fn link(self, sess: &Session, codegen_backend: &dyn CodegenBackend) -> Result<()> {
261261
let (codegen_results, work_products) =
262-
codegen_backend.join_codegen(self.ongoing_codegen, sess, &self.output_filenames)?;
262+
codegen_backend.join_codegen(self.ongoing_codegen, sess, &self.output_filenames);
263263

264264
sess.compile_status()?;
265265

‎tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ impl CodegenBackend for TheBackend {
4949
ongoing_codegen: Box<dyn Any>,
5050
_sess: &Session,
5151
_outputs: &OutputFilenames,
52-
) -> Result<(CodegenResults, FxIndexMap<WorkProductId, WorkProduct>), ErrorGuaranteed> {
52+
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
5353
let codegen_results = ongoing_codegen
5454
.downcast::<CodegenResults>()
5555
.expect("in join_codegen: ongoing_codegen is not a CodegenResults");
56-
Ok((*codegen_results, FxIndexMap::default()))
56+
(*codegen_results, FxIndexMap::default())
5757
}
5858

5959
fn link(

0 commit comments

Comments
 (0)
Failed to load comments.