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

Remove uses of last-use analysis #3754

Merged
merged 18 commits into from
Oct 13, 2012

Conversation

catamorphism
Copy link
Contributor

This pull request removes the reliance of kind checking and trans on last-use analysis. This means two main things:

  1. Kind checking doesn't treat last-uses of vars as implicit moves, so you have to insert explicit moves to avoid warnings and errors.
  2. Trans doesn't automatically translate last uses as moves. It ignores the results of last use.

There is also one separate change (I know, I know) which is to change the kind checker to make struct fields non-copyable as per #3481.

Only 9abc7f0 , c4155f5, and c6780fb need any review. The other patches are mostly just inserting implicit moves.

I had said that these patches caused a performance regression, but on further investigation, it doesn't. Either the performance hit comes from code I already checked in long ago (adding explicit moves), or -- more likely -- I was comparing between optimized and unoptimized builds :-( So I'm pretty confident that merging this pull request won't harm performance significantly.

I know we are potentially going to implement @nmatsakis's type-based move proposal, but in the meantime, this work is done and we might as well merge it to avoid the problems described in #2633.

@catamorphism
Copy link
Contributor Author

r? @nikomatsakis

@nikomatsakis
Copy link
Contributor

r+

@nikomatsakis
Copy link
Contributor

One thought: to avoid errors with inconsistent messages (like "Try adding a move"), you could use a const tryadding: &str = "Try adding a move". I think that'd work fine.

@catamorphism catamorphism merged commit c6780fb into rust-lang:incoming Oct 13, 2012
bors pushed a commit to rust-lang-ci/rust that referenced this pull request May 15, 2021
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Aug 18, 2024
Make unused states of Reserved unrepresentable

In the [previous TB update](rust-lang/miri#3742) we discovered that the existence of `Reserved + !ty_is_freeze + protected` is undesirable.

This has the side effect of making `Reserved { conflicted: true, ty_is_freeze: false }` unreachable.
As such it is desirable that this state would also be unrepresentable.

This PR eliminates the unused configuration by changing
```rs
enum PermissionPriv {
    Reserved { ty_is_freeze: bool, conflicted: bool },
    ...
}
```
into
```rs
enum PermissionPriv {
    ReservedFrz { conflicted: bool },
    ReservedIM,
    ...
}
```
but this is not the only solution and `Reserved(Activable | Conflicted | InteriorMut)` could be discussed.
In addition to making the unreachable state not representable anymore, this change has the nice side effect of enabling `foreign_read` to no longer depend explicitly on the `protected` flag.

Currently waiting for
- `@JoJoDeveloping` to confirm that this is the same representation of `Reserved` as what is being implemented in simuliris,
- `@RalfJung` to approve that this does not introduce too much overhead in the trusted codebase.
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