Skip to content

Prepare standard library for Rust 2024 migration#136983

Merged
bors merged 13 commits into
rust-lang:masterfrom
ehuss:misc-2024-prep
Feb 15, 2025
Merged

Prepare standard library for Rust 2024 migration#136983
bors merged 13 commits into
rust-lang:masterfrom
ehuss:misc-2024-prep

Conversation

@ehuss

@ehuss ehuss commented Feb 13, 2025

Copy link
Copy Markdown
Contributor

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

rustbot commented Feb 13, 2025

Copy link
Copy Markdown
Collaborator

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

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

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 thread library/coretests/tests/pin.rs Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

rustbot commented Feb 13, 2025

Copy link
Copy Markdown
Collaborator

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

ehuss commented Feb 13, 2025

Copy link
Copy Markdown
Contributor Author

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

ehuss commented Feb 13, 2025

Copy link
Copy Markdown
Contributor Author

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 `!`.

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

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

"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
"zerocopy",
"zerocopy-derive",

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

ehuss commented Feb 13, 2025

Copy link
Copy Markdown
Contributor Author

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

Mark-Simulacrum commented Feb 14, 2025

Copy link
Copy Markdown
Member

Sounds good, not a concern then. Thanks!

@ehuss

ehuss commented Feb 14, 2025

Copy link
Copy Markdown
Contributor Author

@bors r=tgross35 rollup

@bors

bors commented Feb 14, 2025

Copy link
Copy Markdown
Collaborator

📌 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
@bors bors merged commit 922119b into rust-lang:master Feb 15, 2025
@rustbot rustbot added this to the 1.86.0 milestone Feb 15, 2025
@riking riking mentioned this pull request Feb 27, 2025
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