Skip to content

Commit 7ed2299

Browse files
author
gitbot
committed
Merge branch 'subtree/library'
2 parents 80da01f + aad53ec commit 7ed2299

File tree

289 files changed

+7924
-7382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+7924
-7382
lines changed

library/alloc/src/collections/btree/map.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT;
135135
/// ]);
136136
/// ```
137137
///
138+
/// ## `Entry` API
139+
///
138140
/// `BTreeMap` implements an [`Entry API`], which allows for complex
139141
/// methods of getting, setting, updating and removing keys and their values:
140142
///

library/alloc/src/ffi/c_str.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ impl From<&CStr> for CString {
10991099
}
11001100
}
11011101

1102-
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
1102+
#[stable(feature = "c_string_eq_c_str", since = "1.90.0")]
11031103
impl PartialEq<CStr> for CString {
11041104
#[inline]
11051105
fn eq(&self, other: &CStr) -> bool {
@@ -1112,7 +1112,7 @@ impl PartialEq<CStr> for CString {
11121112
}
11131113
}
11141114

1115-
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
1115+
#[stable(feature = "c_string_eq_c_str", since = "1.90.0")]
11161116
impl PartialEq<&CStr> for CString {
11171117
#[inline]
11181118
fn eq(&self, other: &&CStr) -> bool {
@@ -1126,7 +1126,7 @@ impl PartialEq<&CStr> for CString {
11261126
}
11271127

11281128
#[cfg(not(no_global_oom_handling))]
1129-
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
1129+
#[stable(feature = "c_string_eq_c_str", since = "1.90.0")]
11301130
impl PartialEq<Cow<'_, CStr>> for CString {
11311131
#[inline]
11321132
fn eq(&self, other: &Cow<'_, CStr>) -> bool {
@@ -1221,7 +1221,7 @@ impl CStr {
12211221
}
12221222
}
12231223

1224-
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
1224+
#[stable(feature = "c_string_eq_c_str", since = "1.90.0")]
12251225
impl PartialEq<CString> for CStr {
12261226
#[inline]
12271227
fn eq(&self, other: &CString) -> bool {
@@ -1235,7 +1235,7 @@ impl PartialEq<CString> for CStr {
12351235
}
12361236

12371237
#[cfg(not(no_global_oom_handling))]
1238-
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
1238+
#[stable(feature = "c_string_eq_c_str", since = "1.90.0")]
12391239
impl PartialEq<Cow<'_, Self>> for CStr {
12401240
#[inline]
12411241
fn eq(&self, other: &Cow<'_, Self>) -> bool {
@@ -1249,7 +1249,7 @@ impl PartialEq<Cow<'_, Self>> for CStr {
12491249
}
12501250

12511251
#[cfg(not(no_global_oom_handling))]
1252-
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
1252+
#[stable(feature = "c_string_eq_c_str", since = "1.90.0")]
12531253
impl PartialEq<CStr> for Cow<'_, CStr> {
12541254
#[inline]
12551255
fn eq(&self, other: &CStr) -> bool {
@@ -1263,7 +1263,7 @@ impl PartialEq<CStr> for Cow<'_, CStr> {
12631263
}
12641264

12651265
#[cfg(not(no_global_oom_handling))]
1266-
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
1266+
#[stable(feature = "c_string_eq_c_str", since = "1.90.0")]
12671267
impl PartialEq<&CStr> for Cow<'_, CStr> {
12681268
#[inline]
12691269
fn eq(&self, other: &&CStr) -> bool {
@@ -1277,7 +1277,7 @@ impl PartialEq<&CStr> for Cow<'_, CStr> {
12771277
}
12781278

12791279
#[cfg(not(no_global_oom_handling))]
1280-
#[stable(feature = "c_string_eq_c_str", since = "CURRENT_RUSTC_VERSION")]
1280+
#[stable(feature = "c_string_eq_c_str", since = "1.90.0")]
12811281
impl PartialEq<CString> for Cow<'_, CStr> {
12821282
#[inline]
12831283
fn eq(&self, other: &CString) -> bool {

library/alloc/src/vec/mod.rs

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,27 @@
4949
//! v[1] = v[1] + 5;
5050
//! ```
5151
//!
52+
//! # Memory layout
53+
//!
54+
//! When the type is non-zero-sized and the capacity is nonzero, [`Vec`] uses the [`Global`]
55+
//! allocator for its allocation. It is valid to convert both ways between such a [`Vec`] and a raw
56+
//! pointer allocated with the [`Global`] allocator, provided that the [`Layout`] used with the
57+
//! allocator is correct for a sequence of `capacity` elements of the type, and the first `len`
58+
//! values pointed to by the raw pointer are valid. More precisely, a `ptr: *mut T` that has been
59+
//! allocated with the [`Global`] allocator with [`Layout::array::<T>(capacity)`][Layout::array] may
60+
//! be converted into a vec using
61+
//! [`Vec::<T>::from_raw_parts(ptr, len, capacity)`](Vec::from_raw_parts). Conversely, the memory
62+
//! backing a `value: *mut T` obtained from [`Vec::<T>::as_mut_ptr`] may be deallocated using the
63+
//! [`Global`] allocator with the same layout.
64+
//!
65+
//! For zero-sized types (ZSTs), or when the capacity is zero, the `Vec` pointer must be non-null
66+
//! and sufficiently aligned. The recommended way to build a `Vec` of ZSTs if [`vec!`] cannot be
67+
//! used is to use [`ptr::NonNull::dangling`].
68+
//!
5269
//! [`push`]: Vec::push
70+
//! [`ptr::NonNull::dangling`]: NonNull::dangling
71+
//! [`Layout`]: crate::alloc::Layout
72+
//! [Layout::array]: crate::alloc::Layout::array
5373
5474
#![stable(feature = "rust1", since = "1.0.0")]
5575

@@ -523,18 +543,23 @@ impl<T> Vec<T> {
523543
/// This is highly unsafe, due to the number of invariants that aren't
524544
/// checked:
525545
///
526-
/// * `ptr` must have been allocated using the global allocator, such as via
527-
/// the [`alloc::alloc`] function.
528-
/// * `T` needs to have the same alignment as what `ptr` was allocated with.
546+
/// * If `T` is not a zero-sized type and the capacity is nonzero, `ptr` must have
547+
/// been allocated using the global allocator, such as via the [`alloc::alloc`]
548+
/// function. If `T` is a zero-sized type or the capacity is zero, `ptr` need
549+
/// only be non-null and aligned.
550+
/// * `T` needs to have the same alignment as what `ptr` was allocated with,
551+
/// if the pointer is required to be allocated.
529552
/// (`T` having a less strict alignment is not sufficient, the alignment really
530553
/// needs to be equal to satisfy the [`dealloc`] requirement that memory must be
531554
/// allocated and deallocated with the same layout.)
532-
/// * The size of `T` times the `capacity` (ie. the allocated size in bytes) needs
533-
/// to be the same size as the pointer was allocated with. (Because similar to
534-
/// alignment, [`dealloc`] must be called with the same layout `size`.)
555+
/// * The size of `T` times the `capacity` (ie. the allocated size in bytes), if
556+
/// nonzero, needs to be the same size as the pointer was allocated with.
557+
/// (Because similar to alignment, [`dealloc`] must be called with the same
558+
/// layout `size`.)
535559
/// * `length` needs to be less than or equal to `capacity`.
536560
/// * The first `length` values must be properly initialized values of type `T`.
537-
/// * `capacity` needs to be the capacity that the pointer was allocated with.
561+
/// * `capacity` needs to be the capacity that the pointer was allocated with,
562+
/// if the pointer is required to be allocated.
538563
/// * The allocated size in bytes must be no larger than `isize::MAX`.
539564
/// See the safety documentation of [`pointer::offset`].
540565
///
@@ -770,12 +795,16 @@ impl<T> Vec<T> {
770795
/// order as the arguments to [`from_raw_parts`].
771796
///
772797
/// After calling this function, the caller is responsible for the
773-
/// memory previously managed by the `Vec`. The only way to do
774-
/// this is to convert the raw pointer, length, and capacity back
775-
/// into a `Vec` with the [`from_raw_parts`] function, allowing
776-
/// the destructor to perform the cleanup.
798+
/// memory previously managed by the `Vec`. Most often, one does
799+
/// this by converting the raw pointer, length, and capacity back
800+
/// into a `Vec` with the [`from_raw_parts`] function; more generally,
801+
/// if `T` is non-zero-sized and the capacity is nonzero, one may use
802+
/// any method that calls [`dealloc`] with a layout of
803+
/// `Layout::array::<T>(capacity)`; if `T` is zero-sized or the
804+
/// capacity is zero, nothing needs to be done.
777805
///
778806
/// [`from_raw_parts`]: Vec::from_raw_parts
807+
/// [`dealloc`]: crate::alloc::GlobalAlloc::dealloc
779808
///
780809
/// # Examples
781810
///
@@ -1755,6 +1784,12 @@ impl<T, A: Allocator> Vec<T, A> {
17551784
/// may still invalidate this pointer.
17561785
/// See the second example below for how this guarantee can be used.
17571786
///
1787+
/// The method also guarantees that, as long as `T` is not zero-sized and the capacity is
1788+
/// nonzero, the pointer may be passed into [`dealloc`] with a layout of
1789+
/// `Layout::array::<T>(capacity)` in order to deallocate the backing memory. If this is done,
1790+
/// be careful not to run the destructor of the `Vec`, as dropping it will result in
1791+
/// double-frees. Wrapping the `Vec` in a [`ManuallyDrop`] is the typical way to achieve this.
1792+
///
17581793
/// # Examples
17591794
///
17601795
/// ```
@@ -1787,9 +1822,24 @@ impl<T, A: Allocator> Vec<T, A> {
17871822
/// }
17881823
/// ```
17891824
///
1825+
/// Deallocating a vector using [`Box`] (which uses [`dealloc`] internally):
1826+
///
1827+
/// ```
1828+
/// use std::mem::{ManuallyDrop, MaybeUninit};
1829+
///
1830+
/// let mut v = ManuallyDrop::new(vec![0, 1, 2]);
1831+
/// let ptr = v.as_mut_ptr();
1832+
/// let capacity = v.capacity();
1833+
/// let slice_ptr: *mut [MaybeUninit<i32>] =
1834+
/// std::ptr::slice_from_raw_parts_mut(ptr.cast(), capacity);
1835+
/// drop(unsafe { Box::from_raw(slice_ptr) });
1836+
/// ```
1837+
///
17901838
/// [`as_mut_ptr`]: Vec::as_mut_ptr
17911839
/// [`as_ptr`]: Vec::as_ptr
17921840
/// [`as_non_null`]: Vec::as_non_null
1841+
/// [`dealloc`]: crate::alloc::GlobalAlloc::dealloc
1842+
/// [`ManuallyDrop`]: core::mem::ManuallyDrop
17931843
#[stable(feature = "vec_as_ptr", since = "1.37.0")]
17941844
#[rustc_const_stable(feature = "const_vec_string_slice", since = "1.87.0")]
17951845
#[rustc_never_returns_null_ptr]

library/compiler-builtins/.github/workflows/main.yaml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ jobs:
3434
- name: Fetch pull request ref
3535
run: git fetch origin "$GITHUB_REF:$GITHUB_REF"
3636
if: github.event_name == 'pull_request'
37-
- run: python3 ci/ci-util.py generate-matrix >> "$GITHUB_OUTPUT"
37+
- run: |
38+
set -eo pipefail # Needed to actually fail the job if ci-util fails
39+
python3 ci/ci-util.py generate-matrix | tee "$GITHUB_OUTPUT"
3840
id: script
3941
4042
test:
@@ -50,7 +52,6 @@ jobs:
5052
os: ubuntu-24.04-arm
5153
- target: aarch64-pc-windows-msvc
5254
os: windows-2025
53-
test_verbatim: 1
5455
build_only: 1
5556
- target: arm-unknown-linux-gnueabi
5657
os: ubuntu-24.04
@@ -70,8 +71,12 @@ jobs:
7071
os: ubuntu-24.04
7172
- target: powerpc64le-unknown-linux-gnu
7273
os: ubuntu-24.04
74+
- target: powerpc64le-unknown-linux-gnu
75+
os: ubuntu-24.04-ppc64le
7376
- target: riscv64gc-unknown-linux-gnu
7477
os: ubuntu-24.04
78+
- target: s390x-unknown-linux-gnu
79+
os: ubuntu-24.04-s390x
7580
- target: thumbv6m-none-eabi
7681
os: ubuntu-24.04
7782
- target: thumbv7em-none-eabi
@@ -88,10 +93,8 @@ jobs:
8893
os: macos-13
8994
- target: i686-pc-windows-msvc
9095
os: windows-2025
91-
test_verbatim: 1
9296
- target: x86_64-pc-windows-msvc
9397
os: windows-2025
94-
test_verbatim: 1
9598
- target: i686-pc-windows-gnu
9699
os: windows-2025
97100
channel: nightly-i686-gnu
@@ -102,11 +105,23 @@ jobs:
102105
needs: [calculate_vars]
103106
env:
104107
BUILD_ONLY: ${{ matrix.build_only }}
105-
TEST_VERBATIM: ${{ matrix.test_verbatim }}
106108
MAY_SKIP_LIBM_CI: ${{ needs.calculate_vars.outputs.may_skip_libm_ci }}
107109
steps:
110+
- name: Print $HOME
111+
shell: bash
112+
run: |
113+
set -x
114+
echo "${HOME:-not found}"
115+
pwd
116+
printenv
108117
- name: Print runner information
109118
run: uname -a
119+
120+
# Native ppc and s390x runners don't have rustup by default
121+
- name: Install rustup
122+
if: matrix.os == 'ubuntu-24.04-ppc64le' || matrix.os == 'ubuntu-24.04-s390x'
123+
run: sudo apt-get update && sudo apt-get install -y rustup
124+
110125
- uses: actions/checkout@v4
111126
- name: Install Rust (rustup)
112127
shell: bash
@@ -117,7 +132,12 @@ jobs:
117132
rustup update "$channel" --no-self-update
118133
rustup default "$channel"
119134
rustup target add "${{ matrix.target }}"
135+
136+
# Our scripts use nextest if possible. This is skipped on the native ppc
137+
# and s390x runners since install-action doesn't support them.
120138
- uses: taiki-e/install-action@nextest
139+
if: "!(matrix.os == 'ubuntu-24.04-ppc64le' || matrix.os == 'ubuntu-24.04-s390x')"
140+
121141
- uses: Swatinem/rust-cache@v2
122142
with:
123143
key: ${{ matrix.target }}
@@ -144,7 +164,7 @@ jobs:
144164
shell: bash
145165
- run: echo "RUST_COMPILER_RT_ROOT=$(realpath ./compiler-rt)" >> "$GITHUB_ENV"
146166
shell: bash
147-
167+
148168
- name: Download musl source
149169
run: ./ci/update-musl.sh
150170
shell: bash
@@ -256,7 +276,7 @@ jobs:
256276
with:
257277
name: ${{ env.BASELINE_NAME }}
258278
path: ${{ env.BASELINE_NAME }}.tar.xz
259-
279+
260280
- name: Run wall time benchmarks
261281
run: |
262282
# Always use the same seed for benchmarks. Ideally we should switch to a
@@ -311,8 +331,8 @@ jobs:
311331
timeout-minutes: 10
312332
steps:
313333
- uses: actions/checkout@v4
314-
- name: Install stable `rustfmt`
315-
run: rustup set profile minimal && rustup default stable && rustup component add rustfmt
334+
- name: Install nightly `rustfmt`
335+
run: rustup set profile minimal && rustup default nightly && rustup component add rustfmt
316336
- run: cargo fmt -- --check
317337

318338
extensive:

library/compiler-builtins/.github/workflows/rustc-pull.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ jobs:
1212
if: github.repository == 'rust-lang/compiler-builtins'
1313
uses: rust-lang/josh-sync/.github/workflows/rustc-pull.yml@main
1414
with:
15+
github-app-id: ${{ vars.APP_CLIENT_ID }}
1516
# https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/compiler-builtins.20subtree.20sync.20automation/with/528482375
1617
zulip-stream-id: 219381
1718
zulip-topic: 'compiler-builtins subtree sync automation'
18-
zulip-bot-email: "[email protected]"
19+
zulip-bot-email: "[email protected]"
1920
pr-base-branch: master
2021
branch-name: rustc-pull
2122
secrets:
2223
zulip-api-token: ${{ secrets.ZULIP_API_TOKEN }}
23-
token: ${{ secrets.GITHUB_TOKEN }}
24+
github-app-secret: ${{ secrets.APP_PRIVATE_KEY }}

library/compiler-builtins/builtins-shim/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ default = ["compiler-builtins"]
3737
# implementations and also filling in unimplemented intrinsics
3838
c = ["dep:cc"]
3939

40-
# Workaround for the Cranelift codegen backend. Disables any implementations
41-
# which use inline assembly and fall back to pure Rust versions (if available).
40+
# For implementations where there is both a generic version and a platform-
41+
# specific version, use the generic version. This is meant to enable testing
42+
# the generic versions on all platforms.
4243
no-asm = []
4344

4445
# Workaround for codegen backends which haven't yet implemented `f16` and

0 commit comments

Comments
 (0)