about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-02-16 00:27:32 +0100
committerGitHub <noreply@github.com>2024-02-16 00:27:32 +0100
commitc73aa787f67a234fc830979eefe1a6a3682145b9 (patch)
tree0b9f588deb881e85428cf13e55b02607340c16e2 /compiler/rustc_ast_lowering/src
parenta7e486a76e6f6a68464711c19ec67b549f9e871b (diff)
parent5233bc91da2f48f5bc79c688b5cfad846a8127da (diff)
downloadrust-c73aa787f67a234fc830979eefe1a6a3682145b9.tar.gz
rust-c73aa787f67a234fc830979eefe1a6a3682145b9.zip
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```
Diffstat (limited to 'compiler/rustc_ast_lowering/src')
-rw-r--r--compiler/rustc_ast_lowering/src/lib.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index eab1383b635..e9e1095a4ae 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -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) }