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

Create Atomic<T> type alias #130543

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.

macro impl_atomic_primitive(
$Atom:ident $(<$T:ident>)? ($Primitive:ty),
size($size:literal),
align($align:literal) $(,)?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI the align is given to impl_atomic_primitive! because while it isn't actually used in this form, it's needed for the form where Atomic<T> is the struct definition. So it'll make the next diff a little cleaner (and here is kinda just residual from paring this back to just do an alias initially).

@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

in core/alloc/std only for now, and ignoring test files
@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
Contributor

bors commented Sep 19, 2024

@CAD97: 🔑 Insufficient privileges: Not in reviewers

@bors
Copy link
Contributor

bors commented Sep 19, 2024

@CAD97: 🔑 Insufficient privileges: not in try users

@workingjubilee
Copy link
Member

@bors r=Noratrieb rollup=iffy

@bors
Copy link
Contributor

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
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
assertion failed: progress.is_finished()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

FAILED TEST: tests/ui/borrow_interior_mutable_const/others.rs
command: CLIPPY_CONF_DIR="tests" RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "--error-format=json" "--emit=metadata" "-Aunused" "-Ainternal_features" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Dwarnings" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "--extern=clippy_config=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_config-5b6bdc670bebd0f1.rlib" "--extern=clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-536bdfcbf155d4ec.rlib" "--extern=clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-c69049b0a05d2e27.rlib" "--extern=futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-014329971e659014.rlib" "--extern=if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-49fd91c51cbf146b.rlib" "--extern=itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-a4b4cb2e17d4d2b3.rlib" "--extern=parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-608416dfddef6875.rlib" "--extern=quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-c813e0e7f4f9d2ff.rlib" "--extern=regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-ad85a18b6c78c875.rlib" "--extern=serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-67d93c74d46e97d4.rlib" "--extern=serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libserde_derive-d1700cdd722b1862.so" "--extern=syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-65f69184e16d38fe.rlib" "--extern=tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-f492a0afd48fb163.rlib" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui_test/tests/ui/borrow_interior_mutable_const" "tests/ui/borrow_interior_mutable_const/others.rs" "--edition" "2021"
error: actual output differed from expected
Execute `cargo uibless` to update `tests/ui/borrow_interior_mutable_const/others.stderr` to the actual output
--- tests/ui/borrow_interior_mutable_const/others.stderr
+++ <stderr output>
+++ <stderr output>
 error: a `const` item with interior mutability should not be borrowed
   --> tests/ui/borrow_interior_mutable_const/others.rs:54:5
... 18 lines skipped ...
 
 error: a `const` item with interior mutability should not be borrowed
-  --> tests/ui/borrow_interior_mutable_const/others.rs:58:22
-   |
-LL |     let _once_ref = &ONCE_INIT;
-   |
-   = help: assign this const to a local or static variable, and use the variable here
-
-error: a `const` item with interior mutability should not be borrowed
-error: a `const` item with interior mutability should not be borrowed
-  --> tests/ui/borrow_interior_mutable_const/others.rs:59:25
-   |
-LL |     let _once_ref_2 = &&ONCE_INIT;
-   |
-   = help: assign this const to a local or static variable, and use the variable here
-
-error: a `const` item with interior mutability should not be borrowed
-error: a `const` item with interior mutability should not be borrowed
-  --> tests/ui/borrow_interior_mutable_const/others.rs:60:27
-   |
-LL |     let _once_ref_4 = &&&&ONCE_INIT;
-   |
-   = help: assign this const to a local or static variable, and use the variable here
-
-error: a `const` item with interior mutability should not be borrowed
---

error: `interior mutability` not found in diagnostics on line 58
##[error]  --> tests/ui/borrow_interior_mutable_const/others.rs:58:44
   |
58 |     let _once_ref = &ONCE_INIT; //~ ERROR: interior mutability
   |

error: `interior mutability` not found in diagnostics on line 59
##[error]  --> tests/ui/borrow_interior_mutable_const/others.rs:59:47
##[error]  --> tests/ui/borrow_interior_mutable_const/others.rs:59:47
   |
59 |     let _once_ref_2 = &&ONCE_INIT; //~ ERROR: interior mutability
   |

error: `interior mutability` not found in diagnostics on line 60
##[error]  --> tests/ui/borrow_interior_mutable_const/others.rs:60:49
##[error]  --> tests/ui/borrow_interior_mutable_const/others.rs:60:49
   |
60 |     let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR: interior mutability
   |

error: `interior mutability` not found in diagnostics on line 61
##[error]  --> tests/ui/borrow_interior_mutable_const/others.rs:61:48
##[error]  --> tests/ui/borrow_interior_mutable_const/others.rs:61:48
   |
61 |     let _once_mut = &mut ONCE_INIT; //~ ERROR: interior mutability
   |


FAILED TEST: tests/ui/declare_interior_mutable_const/others.rs
FAILED TEST: tests/ui/declare_interior_mutable_const/others.rs
command: CLIPPY_CONF_DIR="tests" RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "--error-format=json" "--emit=metadata" "-Aunused" "-Ainternal_features" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Dwarnings" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "--extern=clippy_config=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_config-5b6bdc670bebd0f1.rlib" "--extern=clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-536bdfcbf155d4ec.rlib" "--extern=clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-c69049b0a05d2e27.rlib" "--extern=futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-014329971e659014.rlib" "--extern=if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-49fd91c51cbf146b.rlib" "--extern=itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-a4b4cb2e17d4d2b3.rlib" "--extern=parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-608416dfddef6875.rlib" "--extern=quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-c813e0e7f4f9d2ff.rlib" "--extern=regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-ad85a18b6c78c875.rlib" "--extern=serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-67d93c74d46e97d4.rlib" "--extern=serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libserde_derive-d1700cdd722b1862.so" "--extern=syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-65f69184e16d38fe.rlib" "--extern=tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-f492a0afd48fb163.rlib" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui_test/tests/ui/declare_interior_mutable_const" "tests/ui/declare_interior_mutable_const/others.rs" "--edition" "2021"
error: actual output differed from expected
Execute `cargo uibless` to update `tests/ui/declare_interior_mutable_const/others.stderr` to the actual output
--- tests/ui/declare_interior_mutable_const/others.stderr
+++ <stderr output>
+++ <stderr output>
 error: a `const` item should not be interior mutable
   --> tests/ui/declare_interior_mutable_const/others.rs:10:1
... 23 lines skipped ...
 
 error: a `const` item should not be interior mutable
-  --> tests/ui/declare_interior_mutable_const/others.rs:17:9
-   |
-LL |         const $name: $ty = $e;
-...
-...
-LL | declare_const!(_ONCE: Once = Once::new());
-   |
-   = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: a `const` item should not be interior mutable
---

error: `interior mutable` not found in diagnostics on line 17
##[error]  --> tests/ui/declare_interior_mutable_const/others.rs:18:21
   |
18 |         //~^ ERROR: interior mutable
   |

FAILURES:
    tests/ui/borrow_interior_mutable_const/others.rs

@workingjubilee
Copy link
Member

whups
@bors r-

@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 Sep 19, 2024
@CAD97
Copy link
Contributor Author

CAD97 commented Sep 19, 2024

I

  • don't really see how this could cause UI changes, especially to the test that was reported; and
  • locally have weird link errors happening (the most recent ones I think in LLVM) even for a clean; build on git master;

so it might take me a while to diagnose and fix whatever's going on. I did say rollup was iffy 😅

@workingjubilee
Copy link
Member

@CAD97 I usually give PRs a shot in a rollup even if they're iffy if they haven't ever been tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants