@@ -423,11 +423,12 @@ impl<'a> Checker<'a> {
423423 /// borrow-mode loan on the same handle (or an alias / may-share peer).
424424 fn check_a2_conflict ( & mut self , st : & FnState , cr : & CallRef , root : & str , idx : usize ) {
425425 let conflict = st. loans . iter ( ) . find ( |l| {
426+ let eff_last = self . effective_loan_last ( st, l) ;
426427 matches ! (
427428 & l. target,
428429 LoanTarget :: Handle { handle } if a3_paths_conflict( st, handle, root)
429430 ) && l. created <= idx
430- && idx <= l . last
431+ && idx <= eff_last
431432 } ) ;
432433 let Some ( loan) = conflict else { return } ;
433434 let msg = format ! ( "mutating call on `{}` while a borrow loan is live" , root) ;
@@ -538,7 +539,11 @@ impl<'a> Checker<'a> {
538539 val : & Expr ,
539540 idx : usize ,
540541 ) {
541- let Expr :: Ident { name : src, .. } = unwrap_parens ( val) else {
542+ let mut cur = val;
543+ while let Expr :: Paren { inner : e, .. } | Expr :: Move { operand : e, .. } = cur {
544+ cur = e;
545+ }
546+ let Expr :: Ident { name : src, .. } = cur else {
542547 return ;
543548 } ;
544549 let alias_last = st. last_use . get ( alias_name) . copied ( ) . unwrap_or ( idx) . max ( idx) ;
@@ -617,15 +622,17 @@ impl<'a> Checker<'a> {
617622 what : & str ,
618623 ) {
619624 let Some ( loan) = st. loans . iter ( ) . find ( |l| {
625+ let eff_last = self . effective_loan_last ( st, l) ;
620626 matches ! ( & l. target, LoanTarget :: MapSlot { binding, path: p, key: k }
621627 if owner != Some ( binding. as_str( ) )
622628 && a3_paths_conflict( st, p, path)
623629 && !matches!( ( k. as_deref( ) , key) , ( Some ( a) , Some ( b) ) if a != b) )
624630 && l. created <= idx
625- && idx <= l . last
631+ && idx <= eff_last
626632 } ) else {
627633 return ;
628634 } ;
635+ let eff_last = self . effective_loan_last ( st, loan) ;
629636 let LoanTarget :: MapSlot { binding, .. } = & loan. target else {
630637 unreachable ! ( "filtered above" ) ;
631638 } ;
@@ -636,7 +643,7 @@ impl<'a> Checker<'a> {
636643 let notes = vec ! [
637644 format!(
638645 "{} ({}:{}) is a unique loan on a slot of `{}`, live from creation to its last use (O8, non-lexical window ending at statement {})" ,
639- loan. desc, self . path, loan. span. start, path, loan . last
646+ loan. desc, self . path, loan. span. start, path, eff_last
640647 ) ,
641648 format!(
642649 "the loan lowers to copy-out / store-back, so this access and `{}` would silently overwrite each other — finish using `{}` first, or mutate the slot only through `{}`" ,
0 commit comments