Add an ErrorGuaranteed to ast::TyKind::Err.

This makes it more like `hir::TyKind::Err`, and avoids a
`span_delayed_bug` call in `LoweringContext::lower_ty_direct`.

It also requires adding `ast::TyKind::Dummy`, now that
`ast::TyKind::Err` can't be used for that purpose in the absence of an
error emission.

There are a couple of cases that aren't as neat as I would have liked,
marked with `FIXME` comments.
This commit is contained in:
Nicholas Nethercote 2024-02-14 14:50:49 +11:00
parent 502ce8287b
commit 5233bc91da
14 changed files with 75 additions and 36 deletions

View file

@ -346,8 +346,10 @@ impl<'a> Parser<'a> {
AllowCVariadic::No => {
// FIXME(Centril): Should we just allow `...` syntactically
// anywhere in a type and use semantic restrictions instead?
self.dcx().emit_err(NestedCVariadicType { span: lo.to(self.prev_token.span) });
TyKind::Err
let guar = self
.dcx()
.emit_err(NestedCVariadicType { span: lo.to(self.prev_token.span) });
TyKind::Err(guar)
}
}
} else {
@ -493,8 +495,8 @@ impl<'a> Parser<'a> {
{
// Recover from `[LIT; EXPR]` and `[LIT]`
self.bump();
err.emit();
self.mk_ty(self.prev_token.span, TyKind::Err)
let guar = err.emit();
self.mk_ty(self.prev_token.span, TyKind::Err(guar))
}
Err(err) => return Err(err),
};