1
Fork 0

Continue to borrowck even if there were previous errors

This commit is contained in:
Oli Scherer 2024-02-01 22:45:00 +00:00
parent e5461de392
commit eab2adb660
198 changed files with 3222 additions and 494 deletions

View file

@ -666,7 +666,7 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
let yield_ty = args.yield_ty();
let return_ty = args.return_ty();
(
vec![closure_ty, args.resume_ty()],
vec![closure_ty, resume_ty],
return_ty,
Some(Box::new(CoroutineInfo::initial(
tcx.coroutine_kind(def_id).unwrap(),
@ -675,8 +675,23 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
))),
)
}
_ => {
span_bug!(span, "expected type of closure body to be a closure or coroutine");
ty::CoroutineClosure(did, _args) => {
// FIXME(async_closures): Recover the proper error signature
let inputs = tcx
.closure_user_provided_sig(did.expect_local())
.value
.skip_binder()
.inputs();
let err = Ty::new_error(tcx, guar);
(inputs.iter().map(|_| err).collect(), err, None)
}
ty::Error(_) => (vec![closure_ty, closure_ty], closure_ty, None),
kind => {
span_bug!(
span,
"expected type of closure body to be a closure or coroutine, got {kind:?}"
);
}
}
}

View file

@ -655,7 +655,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let drops = if destination.is_some() {
&mut self.scopes.breakable_scopes[break_index].break_drops
} else {
self.scopes.breakable_scopes[break_index].continue_drops.as_mut().unwrap()
let Some(drops) = self.scopes.breakable_scopes[break_index].continue_drops.as_mut()
else {
self.tcx.dcx().span_delayed_bug(
source_info.span,
"unlabelled `continue` within labelled block",
);
self.cfg.terminate(block, source_info, TerminatorKind::Unreachable);
return self.cfg.start_new_block().unit();
};
drops
};
let drop_idx = self.scopes.scopes[scope_index + 1..]