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

Immutable atomics #13036

Merged
merged 5 commits into from
Mar 22, 2014
Merged

Immutable atomics #13036

merged 5 commits into from
Mar 22, 2014

Conversation

alexcrichton
Copy link
Member

Closes #11583, rebasing of #12430 now that we've got Share and better analysis with statics.

In Rust, the strongest guarantee that `&mut` provides is that the memory
pointed to is *not aliased*, whereas `&`'s guarantees are much weaker:
that the value can be aliased, and may be mutated under proper precautions
(interior mutability).

Our atomics though use `&mut` for mutation even while creating multiple
aliases, so this changes them to use 'interior mutability', mutating
through immutable references.
@brson
Copy link
Contributor

brson commented Mar 20, 2014

Thanks.

brson and others added 4 commits March 20, 2014 13:33
These mutate values behind references that are Freeze, which is not
allowed.
I'm not comfortable exposing public functions that purport to do
atomic operations on arbitrary T.
Support for this is less universal than for word-size things;
it has no users; i'd rather play it safe.
bors added a commit that referenced this pull request Mar 22, 2014
Closes #11583, rebasing of #12430 now that we've got `Share` and better analysis with statics.
@bors bors closed this Mar 22, 2014
@bors bors merged commit 9e66f2c into rust-lang:master Mar 22, 2014
@alexcrichton alexcrichton deleted the atomics branch March 22, 2014 15:57
lnicola pushed a commit to lnicola/rust that referenced this pull request Aug 23, 2022
…ses, r=Veykril

feat: Add an assist for inlining all type alias uses

## Description
`inline_type_alias_uses` assist tries to inline all selected type alias occurrences.

### Currently
Type alias used in `PathType` position are inlined.

### Not supported
- Removing type alias declaration if all uses are inlined.
- Removing redundant imports after inlining all uses in the file.
- Type alias not in `PathType` position, such as:
  - `A::new()`
  - `let x = A {}`
  - `let bits = A::BITS`
  - etc.

## Demonstration

![example](https://user-images.githubusercontent.com/45790125/184905226-9cb8ac81-1439-4387-a13b-e18ad4ecf208.gif)

## Related Issues
Partially fixes rust-lang#10881
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.

Atomics need to take &self rather than &mut sef
3 participants