Skip to content

Create Atomic<T> type alias #130543

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

CAD97
Copy link
Contributor

@CAD97 CAD97 commented Sep 19, 2024

and use it in core/alloc/std where possible, ignoring test files for now.

This is step one, creating the alias from Atomic<T> to AtomicT. The next step of flipping this and aliasing AtomicT to Atomic<T> will have a bigger impact, since AtomicT imports can be dropped once Atomic::new is a usable name.

First commit is the true change. Second commit is mostly mechanical replacement of AtomicT type names with Atomic<T>.

See how this was done for NonZero for the rough blueprint I'm following.

@rustbot
Copy link
Collaborator

rustbot commented Sep 19, 2024

r? @Noratrieb

rustbot has assigned @Noratrieb.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added O-hermit Operating System: Hermit O-itron Operating System: ITRON O-SGX Target: SGX O-unix Operating system: Unix-like O-wasm Target: WASM (WebAssembly), http://webassembly.org/ O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 19, 2024
@CAD97

This comment was marked as outdated.

@CAD97
Copy link
Contributor Author

CAD97 commented Sep 19, 2024

Alright that's the merge conflicts fixed. If I end up needing to continue playing catch-up on some of the touched files, I'll probably just drop files' touch-up to use Atomic<T> from this PR instead of continuously rebasing, as they create conflicts.

@rust-log-analyzer

This comment has been minimized.

@Noratrieb
Copy link
Member

r=me after fixing the import issues

@CAD97 CAD97 force-pushed the generic-atomic branch 2 times, most recently from 67a79e8 to fbf092e Compare September 19, 2024 05:37
@CAD97
Copy link
Contributor Author

CAD97 commented Sep 19, 2024

Also found a similar conflict with the windows futex impl plumbing via local check, so that's also resolved by the amend (hopefully; my local checkout suddenly is complaining about duplicate rmeta for crate object for some reason).

IIRC I don't have perms to do this but might as well try:

@bors r=Noratrieb rollup=iffy

@bors
Copy link
Collaborator

bors commented Sep 19, 2024

@CAD97: 🔑 Insufficient privileges: Not in reviewers

@bors
Copy link
Collaborator

bors commented Sep 19, 2024

@CAD97: 🔑 Insufficient privileges: not in try users

@workingjubilee
Copy link
Member

@bors r=Noratrieb rollup=iffy

@bors
Copy link
Collaborator

bors commented Sep 19, 2024

📌 Commit fbf092e has been approved by Noratrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 19, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Sep 19, 2024
Create `Atomic<T>` type alias

and use it in core/alloc/std where possible, ignoring test files for now.

This is step one, creating the alias from `Atomic<T>` to `AtomicT`. The next step of flipping this and aliasing `AtomicT` to `Atomic<T>` will have a bigger impact, since `AtomicT` imports can be dropped once `Atomic::new` is a usable name.

First commit is the true change. Second commit is mostly mechanical replacement of `AtomicT` type names with `Atomic<T>`.

See [how this was done for `NonZero`](rust-lang#120257) for the rough blueprint I'm following.

- ACP: rust-lang/libs-team#443 (comment)
- Tracking issue: rust-lang#130539
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

in core/alloc/std only for now, and ignoring test files

Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
@CAD97
Copy link
Contributor Author

CAD97 commented Feb 1, 2025

That should be fixed now

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 1, 2025
@Noratrieb
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Feb 5, 2025

📌 Commit 8ae16dd has been approved by Noratrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 5, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 6, 2025
Create `Atomic<T>` type alias

and use it in core/alloc/std where possible, ignoring test files for now.

This is step one, creating the alias from `Atomic<T>` to `AtomicT`. The next step of flipping this and aliasing `AtomicT` to `Atomic<T>` will have a bigger impact, since `AtomicT` imports can be dropped once `Atomic::new` is a usable name.

First commit is the true change. Second commit is mostly mechanical replacement of `AtomicT` type names with `Atomic<T>`.

See [how this was done for `NonZero`](rust-lang#120257) for the rough blueprint I'm following.

- ACP: rust-lang/libs-team#443 (comment)
- Tracking issue: rust-lang#130539
@bors
Copy link
Collaborator

bors commented Feb 6, 2025

⌛ Testing commit 8ae16dd with merge 7c80d00...

@bors
Copy link
Collaborator

bors commented Feb 6, 2025

☔ The latest upstream changes (presumably #136572) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 6, 2025
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-fuchsia failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] object test:false 7.804
error[E0107]: missing generics for type alias `core::sync::atomic::Atomic`
   --> library/std/src/sys/pal/unix/futex.rs:259:48
    |
259 |     pub type zx_futex_t = crate::sync::atomic::Atomic;
    |                                                ^^^^^^ expected 1 generic argument
note: type alias defined here, with 1 generic parameter: `T`
   --> /checkout/library/core/src/sync/atomic.rs:341:10
    |
    |
341 | pub type Atomic<T> = <T as AtomicPrimitive>::AtomicInner;
help: add missing generic argument
    |
    |
259 |     pub type zx_futex_t = crate::sync::atomic::Atomic<T>;

For more information about this error, try `rustc --explain E0107`.
[RUSTC-TIMING] std test:false 4.941
error: could not compile `std` (lib) due to 1 previous error

@bors
Copy link
Collaborator

bors commented Feb 6, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 6, 2025
@CAD97
Copy link
Contributor Author

CAD97 commented Feb 6, 2025

🤦

Will fix that when I get a chance.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 6, 2025
github-merge-queue bot pushed a commit to rust-lang/rust-clippy that referenced this pull request Feb 11, 2025
…solve `<T as Trait>::AssocT` projections (#14125)

changelog: [`declare_interior_mutable_const`,
`borrow_interior_mutable_const`]: resolve `<T as Trait>::AssocT`
projections

---

This came up during rust-lang/rust#130543 where
we have `<T as AtomicPrimitive>::Assoc = AtomicT` instead of just
`AtomicT` and clippy failed to resolve that properly.

This really needs a review, because

- I don't know if `try_normalize_erasing_regions` is the right thing to
call here.
- I'm not sure if I peel off the correct amount of `ValTree::Branch`
layers (I think I do).

Also, shouldn't this lint's infrastructure rely on `Freeze` trait
(rust-lang/rust#121675) instead of hardcoding
a list of known-to-be-interior-mutable types?

---

Previously filed this in the main rust repo
(rust-lang/rust#136369), was asked to do it here
instead
(rust-lang/rust#136369 (comment)).
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-rustc-dev-guide Area: rustc-dev-guide O-hermit Operating System: Hermit O-itron Operating System: ITRON O-SGX Target: SGX O-unix Operating system: Unix-like O-wasm Target: WASM (WebAssembly), http://webassembly.org/ O-windows Operating system: Windows S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue. T-style Relevant to the style team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants