Skip to content

Commit 801d973

Browse files
committed
Move has_errors_or_delayed_bugs check into start_codegen
1 parent e6ff364 commit 801d973

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

compiler/rustc_interface/src/passes.rs

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

@@ -1035,7 +1042,7 @@ pub(crate) fn start_codegen<'tcx>(
10351042
}
10361043
}
10371044

1038-
codegen
1045+
Ok(codegen)
10391046
}
10401047

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

compiler/rustc_interface/src/queries.rs

Lines changed: 1 addition & 8 deletions
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)