Skip to content

Add detailed diagnostics for E0386. #27758

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

Merged
merged 3 commits into from
Aug 13, 2015
Merged

Conversation

nathankleyn
Copy link
Contributor

This adds detailed diagnostics for E0386, 'cannot assign to data in an
immutable container'.

This is part of #24407.

r? @Manishearth

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

**y = 2; // error, cannot assign to data in an immutable container
```

This error can be fixed by making the container mutable:
Copy link
Member

Choose a reason for hiding this comment

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

Or using internal mutability, using std::cell

@nathankleyn
Copy link
Contributor Author

@Manishearth This one is ready to be re-reviewed as well now. 😄

r? @Manishearth

`RefCell`:

```
let y: Cell<_> = Cell::new(1);
Copy link
Member

Choose a reason for hiding this comment

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

Go along the lines of the example above, let y: Box<Cell<_>> = Box::new(Cell::new(x)), and then y.set(2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes much more sense! Fixing now! 👍

This adds detailed diagnostics for E0386, 'cannot assign to data in an
immutable container'.
Types with interior mutability like `Cell` and `RefCell` can be used to
skirt the restriction on mutating mutable values inside an immutable
container.
@nathankleyn
Copy link
Contributor Author

@Manishearth Good for another round. 😄

@Manishearth
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 13, 2015

📌 Commit b0b2952 has been approved by Manishearth

bors added a commit that referenced this pull request Aug 13, 2015
This adds detailed diagnostics for E0386, 'cannot assign to data in an
immutable container'.

This is part of #24407.

r? @Manishearth
@bors
Copy link
Collaborator

bors commented Aug 13, 2015

⌛ Testing commit b0b2952 with merge 677b4c5...

@bors
Copy link
Collaborator

bors commented Aug 13, 2015

💔 Test failed - auto-linux-64-opt

@nathankleyn
Copy link
Contributor Author

@Manishearth Tests here failed, but for reasons seemingly unrelated to the changes in this PR. What do you peeps normally do in this circumstance? Retry the build?

@Manishearth
Copy link
Member

@bors retry

it's an intermittent tcp issue

@bors
Copy link
Collaborator

bors commented Aug 13, 2015

⌛ Testing commit b0b2952 with merge a406627...

bors added a commit that referenced this pull request Aug 13, 2015
This adds detailed diagnostics for E0386, 'cannot assign to data in an
immutable container'.

This is part of #24407.

r? @Manishearth
@bors bors merged commit b0b2952 into rust-lang:master Aug 13, 2015
@nathankleyn nathankleyn deleted the diagnostics-386 branch August 13, 2015 22:52
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.

4 participants