Skip to content

Conversation

@VPaulV
Copy link
Contributor

@VPaulV VPaulV commented Apr 13, 2023

 //let xr = &mut x;     // Error - there is already an immutable ref, so we 

Should be xr1 (or any other name here), with xr it will compile just fine

```
 //let xr = &mut x;     // Error - there is already an immutable ref, so we 
```
Should be xr1 (or any other name here), with just xr it will compile just fine
Copy link
Owner

@nrc nrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! To make the error, I think it also needs a usage of xr after the creation of xr1 in order to keep xr alive long enough

//let xr = &mut x; // Error - there is already an immutable ref, so we
//let xr1 = &mut x; // Error - there is already an immutable ref, so we
// can't make a mutable one

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this actually error, we need another call to bar(xr) in here

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

Successfully merging this pull request may close these issues.

2 participants