Skip to content

Commit 4758198

Browse files
committed
Auto merge of rust-lang#138162 - ehuss:library-2024, r=<try>
Update the standard library to Rust 2024 This updates the standard library to Rust 2024. This includes the following notable changes: - Macros are updated to use new expression fragment specifiers. This PR includes a test to illustrate the changes, primarily allowing `const {...}` expressions now. - Some tests show a change in MIR drop order. We do not believe this will be an observable change ([see zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/268952-edition/topic/standard.20library.20migration/near/500972873)). Fixes rust-lang#133081 (Draft while I do some try jobs, as this is a high-risk of breakage.) try-job: dist-powerpc64le-linux try-job: i686-gnu-1 try-job: i686-msvc-1 try-job: i686-msvc-2 try-job: x86_64-apple-1 try-job: x86_64-gnu-tools try-job: x86_64-mingw-1 try-job: x86_64-mingw-2 try-job: x86_64-msvc-1 try-job: x86_64-msvc-2 try-job: x86_64-msvc-ext1 try-job: x86_64-msvc-ext2 try-job: x86_64-msvc-ext3
2 parents 07292cc + 39d5d92 commit 4758198

File tree

23 files changed

+44
-31
lines changed

23 files changed

+44
-31
lines changed

library/alloc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repository = "https://github.com/rust-lang/rust.git"
88
description = "The Rust core allocation and collections library"
99
autotests = false
1010
autobenches = false
11-
edition = "2021"
11+
edition = "2024"
1212

1313
[lib]
1414
test = false

library/core/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ autobenches = false
99
# If you update this, be sure to update it in a bunch of other places too!
1010
# As of 2024, it was src/tools/opt-dist, the core-no-fp-fmt-parse test and
1111
# the version of the prelude imported in core/lib.rs.
12-
edition = "2021"
12+
edition = "2024"
1313

1414
[lib]
1515
test = false

library/core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ extern crate self as core;
226226

227227
#[prelude_import]
228228
#[allow(unused)]
229-
use prelude::rust_2021::*;
229+
use prelude::rust_2024::*;
230230

231231
#[cfg(not(test))] // See #65860
232232
#[macro_use]

library/panic_abort/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
license = "MIT OR Apache-2.0"
55
repository = "https://github.com/rust-lang/rust.git"
66
description = "Implementation of Rust panics via process aborts"
7-
edition = "2021"
7+
edition = "2024"
88

99
[lib]
1010
test = false

library/panic_unwind/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
44
license = "MIT OR Apache-2.0"
55
repository = "https://github.com/rust-lang/rust.git"
66
description = "Implementation of Rust panics via stack unwinding"
7-
edition = "2021"
7+
edition = "2024"
88

99
[lib]
1010
test = false

library/proc_macro/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "proc_macro"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
std = { path = "../std" }

library/profiler_builtins/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "profiler_builtins"
33
version = "0.0.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[lib]
77
test = false

library/rustc-std-workspace-alloc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
55
description = """
66
Hack for the compiler's own build system
77
"""
8-
edition = "2021"
8+
edition = "2024"
99

1010
[lib]
1111
path = "lib.rs"

library/rustc-std-workspace-core/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
55
description = """
66
Hack for the compiler's own build system
77
"""
8-
edition = "2021"
8+
edition = "2024"
99

1010
[lib]
1111
path = "lib.rs"

library/rustc-std-workspace-std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = 'MIT OR Apache-2.0'
55
description = """
66
Hack for the compiler's own build system
77
"""
8-
edition = "2021"
8+
edition = "2024"
99

1010
[lib]
1111
path = "lib.rs"

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ version = "0.0.0"
66
license = "MIT OR Apache-2.0"
77
repository = "https://github.com/rust-lang/rust.git"
88
description = "The Rust Standard Library"
9-
edition = "2021"
9+
edition = "2024"
1010
autobenches = false
1111

1212
[lib]

library/std/src/keyword_docs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ mod move_keyword {}
10641064
/// ```rust,compile_fail,E0502
10651065
/// let mut v = vec![0, 1];
10661066
/// let mut_ref_v = &mut v;
1067-
/// ##[allow(unused)]
1067+
/// # #[allow(unused)]
10681068
/// let ref_v = &v;
10691069
/// mut_ref_v.push(2);
10701070
/// ```

library/std/src/os/windows/process.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ impl<'a> ProcThreadAttributeListBuilder<'a> {
531531
/// pub Y: i16,
532532
/// }
533533
///
534-
/// extern "system" {
534+
/// unsafe extern "system" {
535535
/// fn CreatePipe(
536536
/// hreadpipe: *mut HANDLE,
537537
/// hwritepipe: *mut HANDLE,

library/sysroot/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cargo-features = ["public-dependency"]
33
[package]
44
name = "sysroot"
55
version = "0.0.0"
6-
edition = "2021"
6+
edition = "2024"
77

88
# this is a dummy crate to ensure that all required crates appear in the sysroot
99
[dependencies]

library/test/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cargo-features = ["public-dependency"]
33
[package]
44
name = "test"
55
version = "0.0.0"
6-
edition = "2021"
6+
edition = "2024"
77

88
[dependencies]
99
getopts = { version = "0.2.21", features = ['rustc-dep-of-std'] }

library/unwind/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "unwind"
33
version = "0.0.0"
44
license = "MIT OR Apache-2.0"
55
repository = "https://github.com/rust-lang/rust.git"
6-
edition = "2021"
6+
edition = "2024"
77
include = [
88
'/libunwind/*',
99
]

library/windows_targets/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "windows-targets"
33
description = "A drop-in replacement for the real windows-targets crate for use in std only."
44
version = "0.0.0"
5-
edition = "2021"
5+
edition = "2024"
66

77
[features]
88
# Enable using raw-dylib for Windows imports.

library/windows_targets/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub macro link {
1212
($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
1313
#[cfg_attr(not(target_arch = "x86"), link(name = $library, kind = "raw-dylib", modifiers = "+verbatim"))]
1414
#[cfg_attr(target_arch = "x86", link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated"))]
15-
extern $abi {
15+
unsafe extern $abi {
1616
$(#[link_name=$link_name])?
1717
pub fn $($function)*;
1818
}
@@ -26,7 +26,7 @@ pub macro link {
2626
// libraries below by using an empty extern block. This works because extern blocks are not
2727
// connected to the library given in the #[link] attribute.
2828
#[link(name = "kernel32")]
29-
extern $abi {
29+
unsafe extern $abi {
3030
$(#[link_name=$link_name])?
3131
pub fn $($function)*;
3232
}

tests/mir-opt/gvn_clone.{impl#0}-clone.GVN.diff

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@
5555
bb3: {
5656
StorageDead(_9);
5757
- _0 = AllCopy { a: move _2, b: move _5, c: move _8 };
58+
- StorageDead(_10);
5859
+ _0 = copy (*_1);
60+
+ nop;
5961
StorageDead(_8);
60-
StorageDead(_5);
61-
StorageDead(_2);
62-
- StorageDead(_10);
6362
- StorageDead(_7);
64-
- StorageDead(_4);
65-
+ nop;
6663
+ nop;
64+
StorageDead(_5);
65+
- StorageDead(_4);
6766
+ nop;
67+
StorageDead(_2);
6868
return;
6969
}
7070
}

tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify-after-simplifycfg.panic-abort.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@
5353
bb3: {
5454
StorageDead(_9);
5555
_0 = MyThing::<T> { v: move _2, i: move _5, a: move _8 };
56-
StorageDead(_8);
57-
StorageDead(_5);
58-
StorageDead(_2);
5956
StorageDead(_10);
57+
StorageDead(_8);
6058
StorageDead(_7);
59+
StorageDead(_5);
6160
StorageDead(_4);
61+
StorageDead(_2);
6262
return;
6363
}
6464
}

tests/mir-opt/instsimplify/combine_clone_of_primitives.{impl#0}-clone.InstSimplify-after-simplifycfg.panic-unwind.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@
5353
bb3: {
5454
StorageDead(_9);
5555
_0 = MyThing::<T> { v: move _2, i: move _5, a: move _8 };
56-
StorageDead(_8);
57-
StorageDead(_5);
58-
StorageDead(_2);
5956
StorageDead(_10);
57+
StorageDead(_8);
6058
StorageDead(_7);
59+
StorageDead(_5);
6160
StorageDead(_4);
61+
StorageDead(_2);
6262
return;
6363
}
6464

tests/run-make/core-no-fp-fmt-parse/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use run_make_support::{rustc, source_root};
55

66
fn main() {
77
rustc()
8-
.edition("2021")
8+
.edition("2024")
99
.arg("-Dwarnings")
1010
.crate_type("rlib")
1111
.input(source_root().join("library/core/src/lib.rs"))

tests/ui/macros/std-2024-macros.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Tests a small handful of macros in the standard library how they handle the
2+
// new behavior introduced in 2024.
3+
4+
//@ check-pass
5+
6+
fn main() {
7+
assert_eq!(0, const { 0 });
8+
assert_eq!(const { 0 }, const { 0 });
9+
assert_eq!(const { 0 }, 0);
10+
11+
let _: Vec<Vec<String>> = vec![const { vec![] }];
12+
let _: Vec<Vec<String>> = vec![const { vec![] }; 10];
13+
}

0 commit comments

Comments
 (0)