Skip to content

Commit 70f0397

Browse files
committed
Merge ref '5a30e4307f05' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 5a30e43 Filtered ref: 59749e9f8c765d3021796a9fe0c188643c4b8d77 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents 36c599b + bd9c133 commit 70f0397

File tree

234 files changed

+2822
-3383
lines changed

Some content is hidden

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

234 files changed

+2822
-3383
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

alloc/src/boxed/thin.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use core::error::Error;
66
use core::fmt::{self, Debug, Display, Formatter};
77
#[cfg(not(no_global_oom_handling))]
8-
use core::intrinsics::const_allocate;
8+
use core::intrinsics::{const_allocate, const_make_global};
99
use core::marker::PhantomData;
1010
#[cfg(not(no_global_oom_handling))]
1111
use core::marker::Unsize;
@@ -340,9 +340,10 @@ impl<H> WithHeader<H> {
340340
alloc.add(metadata_offset).cast();
341341
// SAFETY: `*metadata_ptr` is within the allocation.
342342
metadata_ptr.write(ptr::metadata::<Dyn>(ptr::dangling::<T>() as *const Dyn));
343-
343+
// SAFETY: valid heap allocation
344+
const_make_global(alloc);
344345
// SAFETY: we have just written the metadata.
345-
&*(metadata_ptr)
346+
&*metadata_ptr
346347
}
347348
};
348349

alloc/src/collections/vec_deque/drain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> {
192192
// this branch is never taken.
193193
// We use `#[cold]` instead of `#[inline(never)]`, because inlining this
194194
// function into the general case (`.drain(n..m)`) is fine.
195-
// See `tests/codegen/vecdeque-drain.rs` for a test.
195+
// See `tests/codegen-llvm/vecdeque-drain.rs` for a test.
196196
#[cold]
197197
fn join_head_and_tail_wrapping<T, A: Allocator>(
198198
source_deque: &mut VecDeque<T, A>,

alloc/src/fmt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,13 @@
348348
//! format := '{' [ argument ] [ ':' format_spec ] [ ws ] * '}'
349349
//! argument := integer | identifier
350350
//!
351-
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision]type
351+
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision][type]
352352
//! fill := character
353353
//! align := '<' | '^' | '>'
354354
//! sign := '+' | '-'
355355
//! width := count
356356
//! precision := count | '*'
357-
//! type := '' | '?' | 'x?' | 'X?' | identifier
357+
//! type := '?' | 'x?' | 'X?' | identifier
358358
//! count := parameter | integer
359359
//! parameter := argument '$'
360360
//! ```

alloc/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@
107107
#![feature(char_max_len)]
108108
#![feature(clone_to_uninit)]
109109
#![feature(coerce_unsized)]
110+
#![feature(const_default)]
110111
#![feature(const_eval_select)]
111112
#![feature(const_heap)]
113+
#![feature(const_trait_impl)]
112114
#![feature(core_intrinsics)]
113115
#![feature(deprecated_suggestion)]
114116
#![feature(deref_pure_trait)]
@@ -153,6 +155,7 @@
153155
#![feature(try_trait_v2)]
154156
#![feature(try_with_capacity)]
155157
#![feature(tuple_trait)]
158+
#![feature(ub_checks)]
156159
#![feature(unicode_internals)]
157160
#![feature(unsize)]
158161
#![feature(unwrap_infallible)]

alloc/src/raw_vec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ impl<A: Allocator> RawVecInner<A> {
761761
}
762762

763763
// not marked inline(never) since we want optimizers to be able to observe the specifics of this
764-
// function, see tests/codegen/vec-reserve-extend.rs.
764+
// function, see tests/codegen-llvm/vec-reserve-extend.rs.
765765
#[cold]
766766
fn finish_grow<A>(
767767
new_layout: Layout,

alloc/src/string.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2611,7 +2611,8 @@ impl_eq! { Cow<'a, str>, &'b str }
26112611
impl_eq! { Cow<'a, str>, String }
26122612

26132613
#[stable(feature = "rust1", since = "1.0.0")]
2614-
impl Default for String {
2614+
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
2615+
impl const Default for String {
26152616
/// Creates an empty `String`.
26162617
#[inline]
26172618
fn default() -> String {

alloc/src/vec/mod.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
6464
use core::ops::{self, Index, IndexMut, Range, RangeBounds};
6565
use core::ptr::{self, NonNull};
6666
use core::slice::{self, SliceIndex};
67-
use core::{fmt, intrinsics};
67+
use core::{fmt, intrinsics, ub_checks};
6868

6969
#[stable(feature = "extract_if", since = "1.87.0")]
7070
pub use self::extract_if::ExtractIf;
@@ -1058,6 +1058,11 @@ impl<T, A: Allocator> Vec<T, A> {
10581058
#[inline]
10591059
#[unstable(feature = "allocator_api", issue = "32838")]
10601060
pub unsafe fn from_raw_parts_in(ptr: *mut T, length: usize, capacity: usize, alloc: A) -> Self {
1061+
ub_checks::assert_unsafe_precondition!(
1062+
check_library_ub,
1063+
"Vec::from_raw_parts_in requires that length <= capacity",
1064+
(length: usize = length, capacity: usize = capacity) => length <= capacity
1065+
);
10611066
unsafe { Vec { buf: RawVec::from_raw_parts_in(ptr, capacity, alloc), len: length } }
10621067
}
10631068

@@ -1174,6 +1179,11 @@ impl<T, A: Allocator> Vec<T, A> {
11741179
#[unstable(feature = "allocator_api", reason = "new API", issue = "32838")]
11751180
// #[unstable(feature = "box_vec_non_null", issue = "130364")]
11761181
pub unsafe fn from_parts_in(ptr: NonNull<T>, length: usize, capacity: usize, alloc: A) -> Self {
1182+
ub_checks::assert_unsafe_precondition!(
1183+
check_library_ub,
1184+
"Vec::from_parts_in requires that length <= capacity",
1185+
(length: usize = length, capacity: usize = capacity) => length <= capacity
1186+
);
11771187
unsafe { Vec { buf: RawVec::from_nonnull_in(ptr, capacity, alloc), len: length } }
11781188
}
11791189

@@ -1950,7 +1960,11 @@ impl<T, A: Allocator> Vec<T, A> {
19501960
#[inline]
19511961
#[stable(feature = "rust1", since = "1.0.0")]
19521962
pub unsafe fn set_len(&mut self, new_len: usize) {
1953-
debug_assert!(new_len <= self.capacity());
1963+
ub_checks::assert_unsafe_precondition!(
1964+
check_library_ub,
1965+
"Vec::set_len requires that new_len <= capacity()",
1966+
(new_len: usize = new_len, capacity: usize = self.capacity()) => new_len <= capacity
1967+
);
19541968

19551969
self.len = new_len;
19561970
}
@@ -3695,7 +3709,7 @@ impl<T, A: Allocator> Vec<T, A> {
36953709
/// This is optimal if:
36963710
///
36973711
/// * The tail (elements in the vector after `range`) is empty,
3698-
/// * or `replace_with` yields fewer or equal elements than `range`s length
3712+
/// * or `replace_with` yields fewer or equal elements than `range`'s length
36993713
/// * or the lower bound of its `size_hint()` is exact.
37003714
///
37013715
/// Otherwise, a temporary vector is allocated and the tail is moved twice.
@@ -3895,7 +3909,8 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for Vec<T, A> {
38953909
}
38963910

38973911
#[stable(feature = "rust1", since = "1.0.0")]
3898-
impl<T> Default for Vec<T> {
3912+
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
3913+
impl<T> const Default for Vec<T> {
38993914
/// Creates an empty `Vec<T>`.
39003915
///
39013916
/// The vector will not allocate until elements are pushed onto it.

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,25 @@ jobs:
195195
run: ./ci/update-musl.sh
196196
- run: cargo clippy --workspace --all-targets
197197

198+
build-custom:
199+
name: Build custom target
200+
runs-on: ubuntu-24.04
201+
timeout-minutes: 10
202+
steps:
203+
- uses: actions/checkout@v4
204+
- name: Install Rust
205+
run: |
206+
rustup update nightly --no-self-update
207+
rustup default nightly
208+
rustup component add rust-src
209+
- uses: Swatinem/rust-cache@v2
210+
- run: |
211+
# Ensure we can build with custom target.json files (these can interact
212+
# poorly with build scripts)
213+
cargo build -p compiler_builtins -p libm \
214+
--target etc/thumbv7em-none-eabi-renamed.json \
215+
-Zbuild-std=core
216+
198217
benchmarks:
199218
name: Benchmarks
200219
timeout-minutes: 20
@@ -331,6 +350,7 @@ jobs:
331350
success:
332351
needs:
333352
- benchmarks
353+
- build-custom
334354
- clippy
335355
- extensive
336356
- miri
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Perform a subtree sync (pull) using the josh-sync tool once every few days (or on demand).
2+
name: rustc-pull
3+
4+
on:
5+
workflow_dispatch:
6+
schedule:
7+
# Run at 04:00 UTC every Monday and Thursday
8+
- cron: '0 4 * * 1,4'
9+
10+
jobs:
11+
pull:
12+
if: github.repository == 'rust-lang/compiler-builtins'
13+
uses: rust-lang/josh-sync/.github/workflows/rustc-pull.yml@main
14+
with:
15+
# https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/compiler-builtins.20subtree.20sync.20automation/with/528482375
16+
zulip-stream-id: 219381
17+
zulip-topic: 'compiler-builtins subtree sync automation'
18+
zulip-bot-email: "[email protected]"
19+
pr-base-branch: master
20+
branch-name: rustc-pull
21+
secrets:
22+
zulip-api-token: ${{ secrets.ZULIP_API_TOKEN }}
23+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)