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

library: Use size_of from the prelude instead of imported #138034

Merged
merged 2 commits into from
Mar 7, 2025

Conversation

thaliaarchi
Copy link
Contributor

@thaliaarchi thaliaarchi commented Mar 5, 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.

try-job: test-various
try-job: x86_64-gnu
try-job: x86_64-msvc-1

@rustbot
Copy link
Collaborator

rustbot commented Mar 5, 2025

r? @jieyouxu

rustbot has assigned @jieyouxu.
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 A-compiletest Area: The compiletest test runner A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-testsuite Area: The testsuite used to check the correctness of rustc O-itron Operating System: ITRON O-SGX Target: SGX O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-windows Operating system: Windows PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Mar 5, 2025
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

compiler-errors commented Mar 5, 2025

Please revert all the changes to tests. We don't typically "correct" tests for things like this, formatting, etc. It's simply unnecessary churn. Especially unless you want to verify that every test that was changed doesn't implicitly change the meaning or intention of the test that when it was originally committed (e.g. that the test wasn't exercising minutiae of resolver or path semantics or something else).

You also probably should split this out between library, compiler, and changes to the various tools in src/tools. Different parts of the repository are the responsibility of different teams, and right now the review-ability of a 444 file test is really not great.

@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 Mar 5, 2025
@rustbot
Copy link
Collaborator

rustbot commented Mar 5, 2025

Some changes occurred to the CTFE / Miri interpreter

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

Some changes occurred in src/tools/compiletest

cc @jieyouxu

Some changes occurred in coverage tests.

cc @Zalathar

This PR changes Stable MIR

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

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

The Miri subtree was changed

cc @rust-lang/miri

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

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

Portable SIMD is developed in its own repository. If possible, consider making this change to rust-lang/portable-simd instead.

cc @calebzulawski, @programmerjake

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

Some changes occurred in const_evaluatable.rs

cc @BoxyUwU

Some changes occurred in tests/ui/sanitizer

cc @rust-lang/project-exploit-mitigations, @rcvalle

@rust-log-analyzer

This comment has been minimized.

@thaliaarchi thaliaarchi force-pushed the use-prelude-size-of branch from 88cec8c to ae1a15a Compare March 5, 2025 05:53
@thaliaarchi
Copy link
Contributor Author

Please revert all the changes to tests.

I've removed changes to files in the following directories:

src/tools/clippy/tests/
src/tools/miri/tests/
src/tools/rustfmt/tests/
tests/

@rust-log-analyzer

This comment has been minimized.

@thaliaarchi
Copy link
Contributor Author

Roughly by team, the distribution is now:

library/: 124 files
compiler/: 31 files
src/tools/rust-analyzer/: 11 files
src/tools/clippy/: 4 files
src/bootstrap/: 2 files
src/tools/compiletest/: 1 file
src/tools/miri/: 1 file

Unless I'm splitting library/ somehow, compiler/ might not even be worth splitting out. It's just a lot of files. But, I'm open if you have ideas on how to split it well.

@compiler-errors
Copy link
Member

compiler-errors commented Mar 5, 2025

By split, I mean there's no reason this needs to happen in a single PR, since it's not like this changes something that needs to be applied concurrently across all the repository in a singular PR. It's just a bunch of changes squashed into one by choice.

The 31 changes in compiler/ can get reviewed and approved by a compiler reviewer separately. Same with library/, which should have a dedicated reviewer, though that likely requires a bunch of CI back and forth with all the platform cfg's that aren't tested locally. What I mean is to split this into several PRs.

This PR also touches several tools that really should have PRs made to their own repositories, like rust-analyzer, rustfmt, etc (pls re-read the rustbot ping list for some of those submodules by name), since this is not a critical change or something that breaks rust-analyzer or rustfmt in CI or anything.

@thaliaarchi thaliaarchi requested a review from tgross35 March 7, 2025 01:18
@tgross35
Copy link
Contributor

tgross35 commented Mar 7, 2025

portable-simd should go through its subtree at https://github.com/rust-lang/portable-simd so as to avoid conflicts during sync. Everything else LGTM.

Might as well run a try to double check the changes to platform-specific files.

@bors try

@bors
Copy link
Contributor

bors commented Mar 7, 2025

⌛ Trying commit b4a107d with merge 937b979...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 7, 2025
…try>

library: 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.

These functions were added to all preludes in Rust 1.80.

try-job: test-various
try-job: x86_64-gnu
try-job: x86_64-msvc-1
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
Copy link
Contributor Author

Would pushing the portable-simd removal cancel the bors try?

@tgross35
Copy link
Contributor

tgross35 commented Mar 7, 2025

No idea, I thought it did but recently it seems like it leaves them running. It hasn't been very long in any case.

@compiler-errors
Copy link
Member

pushing cancels a try

@thaliaarchi thaliaarchi force-pushed the use-prelude-size-of branch from b4a107d to 5dfa2f5 Compare March 7, 2025 04:27
@thaliaarchi
Copy link
Contributor Author

Well, it hasn't been long, so I pushed anyways.

@tgross35
Copy link
Contributor

tgross35 commented Mar 7, 2025

pushing cancels a try

It seems to be going still. I had the same thing at #138087, two jobs with a push in between ran in parallel until they both failed.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

In any case, r=me after try completes

@thaliaarchi
Copy link
Contributor Author

I don't see it in the queue, but I also don't mind waiting anyways

@tgross35
Copy link
Contributor

tgross35 commented Mar 7, 2025

Yeah looks like bors doesn't show it in the UI after a push, but it is still running https://github.com/rust-lang-ci/rust/actions/runs/13713644338

@thaliaarchi
Copy link
Contributor Author

@tgross35 The try run passed.

@tgross35
Copy link
Contributor

tgross35 commented Mar 7, 2025

@bors r+

@bors
Copy link
Contributor

bors commented Mar 7, 2025

📌 Commit 5dfa2f5 has been approved by tgross35

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 7, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Mar 7, 2025

pushing cancels a try

(it does not, you can run concurrent try-jobs, you may just confuse rust-log-analyzer)

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 7, 2025
…=tgross35

library: 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.

These functions were added to all preludes in Rust 1.80.

try-job: test-various
try-job: x86_64-gnu
try-job: x86_64-msvc-1
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 7, 2025
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#137674 (Enable `f16` for LoongArch)
 - rust-lang#138034 (library: Use `size_of` from the prelude instead of imported)
 - rust-lang#138060 (Revert rust-lang#138019 after further discussion about how hir-pretty printing should work)
 - rust-lang#138073 (Break critical edges in inline asm before code generation)
 - rust-lang#138107 (`librustdoc`: clippy fixes)
 - rust-lang#138111 (Use `default_field_values` for `rustc_errors::Context`, `rustc_session::config::NextSolverConfig` and `rustc_session::config::ErrorOutputType`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b834632 into rust-lang:master Mar 7, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 7, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 7, 2025
Rollup merge of rust-lang#138034 - thaliaarchi:use-prelude-size-of, r=tgross35

library: 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.

These functions were added to all preludes in Rust 1.80.

try-job: test-various
try-job: x86_64-gnu
try-job: x86_64-msvc-1
@thaliaarchi thaliaarchi deleted the use-prelude-size-of branch March 7, 2025 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc O-itron Operating System: ITRON O-SGX Target: SGX O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-windows Operating system: Windows PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants