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

Prepare standard library for Rust 2024 migration #136983

Merged
merged 13 commits into from
Feb 15, 2025

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Feb 13, 2025

This includes a variety of commits preparing the standard library for migration to Rust 2024.

The actual migration is blocked on a few things, so I wanted to get this out of the way in a relatively digestable PR.

@rustbot
Copy link
Collaborator

rustbot commented Feb 13, 2025

r? @tgross35

rustbot has assigned @tgross35.
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-SGX Target: SGX O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface 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 Feb 13, 2025
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.

The changes here mostly look good to me. However, rand marked Rng::gen deprecated and introduced Rng::random to replace it in version 0.9, released 2 weeks ago. If bumping rand isn't terribly painful (seems pretty compatible), I think it might make sense to do that separately first, which would mean updating the existing uses of gen. Rather than r#gen now and then needing to update again to avoid the deprecation warning.

Comment on lines 31 to 32
let _ = unsafe { Pin::new(&mut 2).get_unchecked_mut() };
let r = &mut 2;
let _ = unsafe { Pin::new(r).get_unchecked_mut() };
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, what makes this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tail expression scope changes. In 2024 the temporary &mut 2 would go out of scope at the end of the unsafe block, but get_unchecked_mut is returning a reference tied to it. In 2021, the temporary is extended to the end of the statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You know, thinking about this more, I decided it would be a little less weird to write it as:

        unsafe {
            let _ = Pin::new(&mut 2).get_unchecked_mut();
        }

@rustbot rustbot added A-tidy Area: The tidy tool T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Feb 13, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 13, 2025

The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging.

cc @davidtwco, @wesleywiser

These commits modify the library/Cargo.lock file. Unintentional changes to library/Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@ehuss
Copy link
Contributor Author

ehuss commented Feb 13, 2025

If bumping rand isn't terribly painful (seems pretty compatible), I think it might make sense to do that separately first,

Sure, I added a commit that updates rand instead.

@rustbot rustbot added the O-windows Operating system: Windows label Feb 13, 2025
@ehuss
Copy link
Contributor Author

ehuss commented Feb 13, 2025

I realized I missed a commit for deprecated_safe_2024, so I added it (0f80413).

ehuss added 11 commits February 13, 2025 13:10
A small workaround for rust-lang#136899,
rustdoc's invalid_rust_codeblocks was not handling this well in 2024.
This may be needed when migrating to 2024 when building with stage0.
This generates a warning of irrefutable patterns. I decided to slightly
tweak the example so the closure returns unit, since the intent wasn't
to show the weird behavior of returning `!`.
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.

One question then r=me

@@ -496,6 +500,8 @@ const PERMITTED_STDLIB_DEPENDENCIES: &[&str] = &[
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
"zerocopy",
"zerocopy-derive",
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is zerocopy-derive coming from? We have default features off for rand so it shouldn't be through there, I'm not seeing it pop up anywhere in cargo tree for the library.

rand is only a dev dependency so it doesn't really matter, the extra items are just surprising.

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'm guessing it is getting confused by this unusual pinning approach in zerocopy:

[target."cfg(any())".dependencies.zerocopy-derive]
version = "=0.8.17"

The dependency list here unconditionally includes all target dependencies.

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, that is interesting. The deps appear in library/Cargo.lock though, I guess the pinning causes them to show up there even if they aren't used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, cargo does the same thing. Cargo.lock is generated as if all the [target] tables are included unconditionally.

I don't think I've ever seen someone use this approach of cfg(any()), it's quite interesting.

@Mark-Simulacrum
Copy link
Member

Can we hold off on the rand update? See discussion in #136395 around the binaries that adds to the compiler deps (if only actually linked in on wasm)

@ehuss
Copy link
Contributor Author

ehuss commented Feb 13, 2025

See discussion in #136395 around the binaries that adds to the compiler deps (if only actually linked in on wasm)

This PR shouldn't bring in wit-bindgen, as this uses default-features=false, none of the wasi stuff is being brought in.

@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented Feb 14, 2025

Sounds good, not a concern then. Thanks!

@ehuss
Copy link
Contributor Author

ehuss commented Feb 14, 2025

@bors r=tgross35 rollup

@bors
Copy link
Contributor

bors commented Feb 14, 2025

📌 Commit ef20a1b 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 Feb 14, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Feb 14, 2025
Prepare standard library for Rust 2024 migration

This includes a variety of commits preparing the standard library for migration to Rust 2024.

The actual migration is blocked on a few things, so I wanted to get this out of the way in a relatively digestable PR.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 14, 2025
Rollup of 11 pull requests

Successful merges:

 - rust-lang#133312 (triagebot: automatically add more rustdoc related labels)
 - rust-lang#134016 (Stabilize `const_is_char_boundary` and `const_str_split_at`.)
 - rust-lang#135813 (CI: split i686-mingw job to three free runners)
 - rust-lang#136879 (Add safe new() to NotAllOnes)
 - rust-lang#136971 (Add a new check-pass UI test for returning `impl Fn(T) -> impl Trait`)
 - rust-lang#136983 (Prepare standard library for Rust 2024 migration)
 - rust-lang#137002 (Fix early lint check desc in query)
 - rust-lang#137006 (borrowck diagnostics cleanup: remove an unused and a barely-used field)
 - rust-lang#137026 (Stabilize (and const-stabilize) `integer_sign_cast`)
 - rust-lang#137028 (mir_build: Clarify some code for lowering `hir::PatExpr` to THIR)
 - rust-lang#137032 (Decode metadata buffer in one go)

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

Rollup of 10 pull requests

Successful merges:

 - rust-lang#133312 (triagebot: automatically add more rustdoc related labels)
 - rust-lang#134016 (Stabilize `const_is_char_boundary` and `const_str_split_at`.)
 - rust-lang#136971 (Add a new check-pass UI test for returning `impl Fn(T) -> impl Trait`)
 - rust-lang#136983 (Prepare standard library for Rust 2024 migration)
 - rust-lang#137002 (Fix early lint check desc in query)
 - rust-lang#137006 (borrowck diagnostics cleanup: remove an unused and a barely-used field)
 - rust-lang#137032 (Decode metadata buffer in one go)
 - rust-lang#137035 (Normalize closure instance before eagerly monomorphizing it)
 - rust-lang#137037 (add x86-sse2 (32bit) ABI that requires SSE2 target feature)
 - rust-lang#137038 (llvm: Tolerate captures in tests)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 922119b into rust-lang:master Feb 15, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Feb 15, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 15, 2025
Rollup merge of rust-lang#136983 - ehuss:misc-2024-prep, r=tgross35

Prepare standard library for Rust 2024 migration

This includes a variety of commits preparing the standard library for migration to Rust 2024.

The actual migration is blocked on a few things, so I wanted to get this out of the way in a relatively digestable PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tidy Area: The tidy tool O-hermit Operating System: Hermit O-SGX Target: SGX O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-windows Operating system: Windows S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants