From a8b0eb7c65bba72de8bc5cd5068a46ab4563d201 Mon Sep 17 00:00:00 2001 From: xizheyin Date: Tue, 8 Apr 2025 17:36:44 +0800 Subject: [PATCH] Update compiler/rustc_borrowck/src/diagnostics/region_errors.rs Co-authored-by: lcnr --- compiler/rustc_borrowck/src/diagnostics/region_errors.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 5b5cacdf4c81..8d530b51636a 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -198,7 +198,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { /// Returns `true` if a closure is inferred to be an `FnMut` closure. fn is_closure_fn_mut(&self, fr: RegionVid) -> bool { - if let Some(ty::ReLateParam(late_param)) = self.to_error_region(fr).map(|r| r.kind()) + if let Some(r) = self.to_error_region(fr) + && let ty::ReLateParam(late_param) = r.kind() && let ty::LateParamRegionKind::ClosureEnv = late_param.kind && let DefiningTy::Closure(_, args) = self.regioncx.universal_regions().defining_ty {