-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Conversation
There was a problem hiding this 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.
library/coretests/tests/pin.rs
Outdated
let _ = unsafe { Pin::new(&mut 2).get_unchecked_mut() }; | ||
let r = &mut 2; | ||
let _ = unsafe { Pin::new(r).get_unchecked_mut() }; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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();
}
bcdcf7a
to
3c25135
Compare
The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging. These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
Sure, I added a commit that updates rand instead. |
I realized I missed a commit for deprecated_safe_2024, so I added it (0f80413). |
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 `!`.
0f80413
to
ef20a1b
Compare
There was a problem hiding this 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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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) |
This PR shouldn't bring in wit-bindgen, as this uses |
Sounds good, not a concern then. Thanks! |
@bors r=tgross35 rollup |
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.
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
…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
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.
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.