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

compiler: Use size_of from the prelude instead of imported #138040

Merged
merged 1 commit into from
Mar 9, 2025

Conversation

thaliaarchi
Copy link
Contributor

Use std::mem::{size_of, size_of_val, align_of, align_of_val} from the prelude instead of importing or qualifying them. Apply this change across the compiler.

These functions were added to all preludes in Rust 1.80.

r? @compiler-errors

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 5, 2025
@rustbot
Copy link
Collaborator

rustbot commented Mar 5, 2025

This PR changes Stable MIR

cc @oli-obk, @celinval, @ouz-a

Some changes occurred in const_evaluatable.rs

cc @BoxyUwU

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@@ -155,7 +155,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}

// Simple case, either no projections, or only fully-qualified.
// E.g., `std::mem::size_of` or `<I as Iterator>::Item`.
Copy link
Member

Choose a reason for hiding this comment

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

this is just a random example of a multi segment path, so please choose another one. maybe std::iter::zip or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just reverted that

@@ -15,10 +13,10 @@ pub const fn align_of<T: ?Sized + Aligned>() -> Alignment {
/// # Safety
///
/// `Self::ALIGN` must be equal to the alignment of `Self`. For sized types it
/// is [`mem::align_of<Self>()`], for unsized types it depends on the type, for
Copy link
Member

Choose a reason for hiding this comment

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

put turbofish here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did add a turbofish. It's now align_of::<Self>(). You replied on the deleted line, so maybe you missed that?

Copy link
Member

Choose a reason for hiding this comment

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

whoops

@compiler-errors
Copy link
Member

Few nits then I can approve.

@rust-log-analyzer

This comment has been minimized.

@thaliaarchi thaliaarchi force-pushed the use-prelude-size-of.compiler branch from b46c1a2 to 3efe87b Compare March 5, 2025 07:51
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Mar 5, 2025

📌 Commit 3efe87b has been approved by compiler-errors

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 Mar 5, 2025
@rust-log-analyzer

This comment has been minimized.

@workingjubilee
Copy link
Member

needs rustfmt
@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 Mar 5, 2025
@thaliaarchi thaliaarchi force-pushed the use-prelude-size-of.compiler branch from 3efe87b to bcb1dbf Compare March 5, 2025 08:46
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Mar 5, 2025

📌 Commit bcb1dbf has been approved by compiler-errors

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 5, 2025
@compiler-errors
Copy link
Member

compiler-errors commented Mar 5, 2025

hold up ci is broken

@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 Mar 5, 2025
@thaliaarchi thaliaarchi force-pushed the use-prelude-size-of.compiler branch from bcb1dbf to 1444614 Compare March 5, 2025 22:39
@thaliaarchi
Copy link
Contributor Author

Since I missed a #[cfg(not(feature = "nightly"))] gate, I manually reviewed everything again. The imports are good in all configurations.

@thaliaarchi
Copy link
Contributor Author

thaliaarchi commented Mar 6, 2025

@rustbot review

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 6, 2025
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 6, 2025
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the
prelude instead of importing or qualifying them.

These functions were added to all preludes in Rust 1.80.
@thaliaarchi thaliaarchi force-pushed the use-prelude-size-of.compiler branch from 1444614 to 38fad98 Compare March 7, 2025 22:14
@rustbot
Copy link
Collaborator

rustbot commented Mar 7, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@thaliaarchi
Copy link
Contributor Author

I don't know why that ping went out now, instead of before, since that push didn't change the changes to rustc_codegen_ssa. Anyways, that push was a style thing, reducing the diff, not correctness.

@WaffleLapkin
Copy link
Member

The ping went out because it was just configured in #138108.

@bors r=compiler-errors

@bors
Copy link
Collaborator

bors commented Mar 8, 2025

📌 Commit 38fad98 has been approved by compiler-errors

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 Mar 8, 2025
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Mar 9, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…mpiler, r=compiler-errors

compiler: Use `size_of` from the prelude instead of imported

Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. Apply this change across the compiler.

These functions were added to all preludes in Rust 1.80.

r? `@compiler-errors`
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 9, 2025
Rollup of 16 pull requests

Successful merges:

 - rust-lang#122790 (Apply dllimport in ThinLTO)
 - rust-lang#136127 (Allow `*const W<dyn A> -> *const dyn A` ptr cast)
 - rust-lang#136968 (Turn order dependent trait objects future incompat warning into a hard error)
 - rust-lang#137147 (Add exclude to config.toml)
 - rust-lang#137319 (Stabilize `const_vec_string_slice`)
 - rust-lang#137885 (tidy: add triagebot checks)
 - rust-lang#138040 (compiler: Use `size_of` from the prelude instead of imported)
 - rust-lang#138052 (strip `-Wlinker-messages` wrappers from `rust-lld` rmake test)
 - rust-lang#138084 (Use workspace lints for crates in `compiler/`)
 - rust-lang#138158 (Move more layouting logic to `rustc_abi`)
 - rust-lang#138160 (depend more on attr_data_structures and move find_attr! there)
 - rust-lang#138192 (crashes: couple more tests)
 - rust-lang#138216 (bootstrap: Fix stack printing when a step cycle is detected)
 - rust-lang#138232 (Reduce verbosity of GCC build log)
 - rust-lang#138233 (Windows: Don't link std (and run-make) against advapi32, except on win7)
 - rust-lang#138242 (Revert "Don't test new error messages with the stage 0 compiler")

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 9, 2025
…iaskrgr

Rollup of 12 pull requests

Successful merges:

 - rust-lang#136127 (Allow `*const W<dyn A> -> *const dyn A` ptr cast)
 - rust-lang#136968 (Turn order dependent trait objects future incompat warning into a hard error)
 - rust-lang#137319 (Stabilize `const_vec_string_slice`)
 - rust-lang#137885 (tidy: add triagebot checks)
 - rust-lang#138040 (compiler: Use `size_of` from the prelude instead of imported)
 - rust-lang#138084 (Use workspace lints for crates in `compiler/`)
 - rust-lang#138158 (Move more layouting logic to `rustc_abi`)
 - rust-lang#138160 (depend more on attr_data_structures and move find_attr! there)
 - rust-lang#138192 (crashes: couple more tests)
 - rust-lang#138216 (bootstrap: Fix stack printing when a step cycle is detected)
 - rust-lang#138232 (Reduce verbosity of GCC build log)
 - rust-lang#138242 (Revert "Don't test new error messages with the stage 0 compiler")

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c666287 into rust-lang:master Mar 9, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 9, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 9, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Rollup merge of rust-lang#138040 - thaliaarchi:use-prelude-size-of.compiler, r=compiler-errors

compiler: Use `size_of` from the prelude instead of imported

Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. Apply this change across the compiler.

These functions were added to all preludes in Rust 1.80.

r? ``@compiler-errors``
@thaliaarchi thaliaarchi deleted the use-prelude-size-of.compiler branch March 9, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants