Skip to content

0.4.1 - Check Simultaneous Borrows

Choose a tag to compare

@github-actions github-actions released this 23 Apr 09:00

This release fixes a bug where the same object could have a const and a mut reference pointing to it at the same time:

class C {}
fn test() {
  var c: exclusive C = C()
  trigger(c, c)
}
fn trigger(borrow a: mut C, borrow b: const C) {}

this would previously pass, but is now rejected:

(ERROR) Cannot borrow `c` as const here, because it is already borrowed as mut

   |  
36 |    var c: exclusive C = C()
   |            👇 borrowed as mut here
37 |    trigger(c, c)
   |               👆 attempting to borrow as const while a mut borrow is still active
38 |  }
   |