Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circle misses borrowck conflict #67

Open
seanbaxter opened this issue Oct 8, 2024 · 0 comments
Open

Circle misses borrowck conflict #67

seanbaxter opened this issue Oct 8, 2024 · 0 comments

Comments

@seanbaxter
Copy link
Collaborator

seanbaxter commented Oct 8, 2024

fn main() {
  let mut x = 1;

  let r1 = &mut x;
  let r2 = &mut *r1;

  let x = *r1;
  *r2 = 200;
}
error[E0503]: cannot use `*r1` because it was mutably borrowed
 --> foo.rs:7:11
  |
5 |   let r2 = &mut *r1;
  |            -------- `*r1` is borrowed here
6 |
7 |   let x = *r1;
  |           ^^^ use of borrowed `*r1`
8 |   *r2 = 200;
  |   --------- borrow later used here

Rust flags the use of *r1 when there's a live reborrow *r2. Circle doesn't do that. This compiles:
(Compiler Explorer)

#feature on safety

int main() {
  int x = 1;

  int^ r1 = ^x;
  int^ r2 = ^*r1;

  *r1 = 100;
  *r2 = 200;
}

It's not clear how to determine that the loan on *r1 is a relevant loan that should raise the conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant