Skip to content

Commit d8c9dd4

Browse files
committed
Move has_errors_or_delayed_bugs check into start_codegen
1 parent e2aadc2 commit d8c9dd4

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

compiler/rustc_interface/src/passes.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,14 @@ fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
10081008
pub(crate) fn start_codegen<'tcx>(
10091009
codegen_backend: &dyn CodegenBackend,
10101010
tcx: TyCtxt<'tcx>,
1011-
) -> Box<dyn Any> {
1011+
) -> Result<Box<dyn Any>> {
1012+
// Don't do code generation if there were any errors. Likewise if
1013+
// there were any delayed bugs, because codegen will likely cause
1014+
// more ICEs, obscuring the original problem.
1015+
if let Some(guar) = tcx.sess.dcx().has_errors_or_delayed_bugs() {
1016+
return Err(guar);
1017+
}
1018+
10121019
// Hook for UI tests.
10131020
check_for_rustc_errors_attr(tcx);
10141021

@@ -1034,7 +1041,7 @@ pub(crate) fn start_codegen<'tcx>(
10341041
}
10351042
}
10361043

1037-
codegen
1044+
Ok(codegen)
10381045
}
10391046

10401047
fn get_recursion_limit(krate_attrs: &[ast::Attribute], sess: &Session) -> Limit {

compiler/rustc_interface/src/queries.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,7 @@ impl<'tcx> Queries<'tcx> {
126126

127127
pub fn codegen_and_build_linker(&'tcx self) -> Result<Linker> {
128128
self.global_ctxt()?.enter(|tcx| {
129-
// Don't do code generation if there were any errors. Likewise if
130-
// there were any delayed bugs, because codegen will likely cause
131-
// more ICEs, obscuring the original problem.
132-
if let Some(guar) = self.compiler.sess.dcx().has_errors_or_delayed_bugs() {
133-
return Err(guar);
134-
}
135-
136-
let ongoing_codegen = passes::start_codegen(&*self.compiler.codegen_backend, tcx);
129+
let ongoing_codegen = passes::start_codegen(&*self.compiler.codegen_backend, tcx)?;
137130

138131
Ok(Linker {
139132
dep_graph: tcx.dep_graph.clone(),

0 commit comments

Comments
 (0)