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

Update the standard library to Rust 2024 #138162

Merged
merged 13 commits into from
Mar 13, 2025
2 changes: 1 addition & 1 deletion library/alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repository = "https://github.com/rust-lang/rust.git"
description = "The Rust core allocation and collections library"
autotests = false
autobenches = false
edition = "2021"
edition = "2024"

[lib]
test = false
Expand Down
2 changes: 1 addition & 1 deletion library/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ autobenches = false
# If you update this, be sure to update it in a bunch of other places too!
# As of 2024, it was src/tools/opt-dist, the core-no-fp-fmt-parse test and
# the version of the prelude imported in core/lib.rs.
edition = "2021"
edition = "2024"

[lib]
test = false
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ extern crate self as core;

#[prelude_import]
#[allow(unused)]
use prelude::rust_2021::*;
use prelude::rust_2024::*;

#[cfg(not(test))] // See #65860
#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion library/panic_abort/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust.git"
description = "Implementation of Rust panics via process aborts"
edition = "2021"
edition = "2024"

[lib]
test = false
Expand Down
2 changes: 1 addition & 1 deletion library/panic_unwind/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust.git"
description = "Implementation of Rust panics via stack unwinding"
edition = "2021"
edition = "2024"

[lib]
test = false
Expand Down
2 changes: 1 addition & 1 deletion library/proc_macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "proc_macro"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
std = { path = "../std" }
Expand Down
2 changes: 1 addition & 1 deletion library/profiler_builtins/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "profiler_builtins"
version = "0.0.0"
edition = "2021"
edition = "2024"

[lib]
test = false
Expand Down
2 changes: 1 addition & 1 deletion library/rustc-std-workspace-alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
description = """
Hack for the compiler's own build system
"""
edition = "2021"
edition = "2024"

[lib]
path = "lib.rs"
Expand Down
2 changes: 1 addition & 1 deletion library/rustc-std-workspace-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
description = """
Hack for the compiler's own build system
"""
edition = "2021"
edition = "2024"

[lib]
path = "lib.rs"
Expand Down
2 changes: 1 addition & 1 deletion library/rustc-std-workspace-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
description = """
Hack for the compiler's own build system
"""
edition = "2021"
edition = "2024"

[lib]
path = "lib.rs"
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = "0.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust.git"
description = "The Rust Standard Library"
edition = "2021"
edition = "2024"
autobenches = false

[lib]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/keyword_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ mod move_keyword {}
/// ```rust,compile_fail,E0502
/// let mut v = vec![0, 1];
/// let mut_ref_v = &mut v;
/// ##[allow(unused)]
/// # #[allow(unused)]
Copy link
Member

Choose a reason for hiding this comment

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

What is this ## -> # #?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a workaround for #136899. Sorry, should have mentioned that in the description.

/// let ref_v = &v;
/// mut_ref_v.push(2);
/// ```
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/os/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ impl<'a> ProcThreadAttributeListBuilder<'a> {
/// pub Y: i16,
/// }
///
/// extern "system" {
/// unsafe extern "system" {
/// fn CreatePipe(
/// hreadpipe: *mut HANDLE,
/// hwritepipe: *mut HANDLE,
Expand Down
2 changes: 1 addition & 1 deletion library/sysroot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cargo-features = ["public-dependency"]
[package]
name = "sysroot"
version = "0.0.0"
edition = "2021"
edition = "2024"

# this is a dummy crate to ensure that all required crates appear in the sysroot
[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion library/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cargo-features = ["public-dependency"]
[package]
name = "test"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
getopts = { version = "0.2.21", features = ['rustc-dep-of-std'] }
Expand Down
2 changes: 1 addition & 1 deletion library/unwind/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "unwind"
version = "0.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust.git"
edition = "2021"
edition = "2024"
include = [
'/libunwind/*',
]
Expand Down
2 changes: 1 addition & 1 deletion library/windows_targets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "windows-targets"
description = "A drop-in replacement for the real windows-targets crate for use in std only."
version = "0.0.0"
edition = "2021"
edition = "2024"

[features]
# Enable using raw-dylib for Windows imports.
Expand Down
4 changes: 2 additions & 2 deletions library/windows_targets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub macro link {
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
#[cfg_attr(not(target_arch = "x86"), link(name = $library, kind = "raw-dylib", modifiers = "+verbatim"))]
#[cfg_attr(target_arch = "x86", link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated"))]
extern $abi {
unsafe extern $abi {
$(#[link_name=$link_name])?
pub fn $($function)*;
}
Expand All @@ -26,7 +26,7 @@ pub macro link {
// libraries below by using an empty extern block. This works because extern blocks are not
// connected to the library given in the #[link] attribute.
#[link(name = "kernel32")]
extern $abi {
unsafe extern $abi {
$(#[link_name=$link_name])?
pub fn $($function)*;
}
Expand Down
10 changes: 5 additions & 5 deletions tests/mir-opt/gvn_clone.{impl#0}-clone.GVN.diff
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@
bb3: {
StorageDead(_9);
- _0 = AllCopy { a: move _2, b: move _5, c: move _8 };
- StorageDead(_10);
+ _0 = copy (*_1);
+ nop;
StorageDead(_8);
StorageDead(_5);
StorageDead(_2);
- StorageDead(_10);
- StorageDead(_7);
- StorageDead(_4);
+ nop;
+ nop;
StorageDead(_5);
- StorageDead(_4);
+ nop;
StorageDead(_2);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
bb3: {
StorageDead(_9);
_0 = MyThing::<T> { v: move _2, i: move _5, a: move _8 };
StorageDead(_8);
StorageDead(_5);
StorageDead(_2);
StorageDead(_10);
StorageDead(_8);
StorageDead(_7);
StorageDead(_5);
StorageDead(_4);
StorageDead(_2);
Comment on lines -56 to +61
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 obviously not the main point of e2024, but it's fun to see that these just end up in decreasing order now. It obviously doesn't actually matter, but it's a nice indication that how the temporaries are getting cleaned up really is in a more reasonable order.

return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
bb3: {
StorageDead(_9);
_0 = MyThing::<T> { v: move _2, i: move _5, a: move _8 };
StorageDead(_8);
StorageDead(_5);
StorageDead(_2);
StorageDead(_10);
StorageDead(_8);
StorageDead(_7);
StorageDead(_5);
StorageDead(_4);
StorageDead(_2);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/core-no-fp-fmt-parse/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use run_make_support::{rustc, source_root};

fn main() {
rustc()
.edition("2021")
.edition("2024")
.arg("-Dwarnings")
.crate_type("rlib")
.input(source_root().join("library/core/src/lib.rs"))
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/macros/std-2024-macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Tests a small handful of macros in the standard library how they handle the
// new behavior introduced in 2024 that allows `const{}` expressions.

//@ check-pass

fn main() {
assert_eq!(0, const { 0 });
assert_eq!(const { 0 }, const { 0 });
assert_eq!(const { 0 }, 0);

let _: Vec<Vec<String>> = vec![const { vec![] }];
let _: Vec<Vec<String>> = vec![const { vec![] }; 10];
}
Loading