From 33492c714b5d43292efb167fa36646d6a967dbc3 Mon Sep 17 00:00:00 2001 From: Max Niederman <max@maxniederman.com> Date: Sun, 15 Sep 2024 00:25:08 -0700 Subject: [PATCH] typecheck guard pattern conditions --- compiler/rustc_hir_typeck/src/pat.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 90c35cdd8d1d..ebaa7eb88206 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -260,8 +260,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { PatKind::Struct(ref qpath, fields, has_rest_pat) => { self.check_pat_struct(pat, qpath, fields, has_rest_pat, expected, pat_info) } - PatKind::Guard(pat, _) => { + PatKind::Guard(pat, cond) => { self.check_pat(pat, expected, pat_info); + self.check_expr_has_type_or_error(cond, self.tcx.types.bool, |_| {}); expected } PatKind::Or(pats) => {