1
Fork 0

Rollup merge of #121109 - nnethercote:TyKind-Err-guar-2, r=oli-obk

Add an ErrorGuaranteed to ast::TyKind::Err (attempt 2)

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

r? ```@oli-obk```
This commit is contained in:
Guillaume Gomez 2024-02-16 00:27:32 +01:00 committed by GitHub
commit c73aa787f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 75 additions and 36 deletions

View file

@ -1286,7 +1286,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn lower_ty_direct(&mut self, t: &Ty, itctx: ImplTraitContext) -> hir::Ty<'hir> {
let kind = match &t.kind {
TyKind::Infer => hir::TyKind::Infer,
TyKind::Err => hir::TyKind::Err(self.dcx().has_errors().unwrap()),
TyKind::Err(guar) => hir::TyKind::Err(*guar),
// Lower the anonymous structs or unions in a nested lowering context.
//
// ```
@ -1504,6 +1504,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
);
hir::TyKind::Err(guar)
}
TyKind::Dummy => panic!("`TyKind::Dummy` should never be lowered"),
};
hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.lower_node_id(t.id) }