From 4d64bb4a4fc91fb3cb9d6513b99f30102e7121cd Mon Sep 17 00:00:00 2001 From: Max Niederman 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 941ed20a3f033..242bd0de1ac8a 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -259,8 +259,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) => {