Add comment on cap_to_weakly_not

Co-authored-by: Guillaume Boisseau <Nadrieril@users.noreply.github.com>
This commit is contained in:
Jules Bertholet 2024-05-10 13:53:48 -04:00 committed by GitHub
parent 7951311c1b
commit 6d5c6f541f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2141,6 +2141,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut inherited_ref_mutbl_match = false;
if match_ergonomics_mode != MatchErgonomicsMode::Legacy {
if pat_mutbl == Mutability::Not {
// Prevent the inner pattern from binding with `ref mut`.
pat_info.max_ref_mutbl = pat_info.max_ref_mutbl.cap_to_weakly_not(
inner.span.find_ancestor_inside(pat.span).map(|end| pat.span.until(end)),
);