Skip to content

Commit 1a8c9cf

Browse files
committed
Merge ref '73e6c9ebd912' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 73e6c9e Filtered ref: e8bb3cae4cd2b04bdc252cdf79102717db2b2d8d Upstream diff: rust-lang/rust@32e7a4b...73e6c9e This merge was created using https://github.com/rust-lang/josh-sync.
2 parents 54a5e0f + d56e2be commit 1a8c9cf

File tree

744 files changed

+32923
-13730
lines changed

Some content is hidden

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

744 files changed

+32923
-13730
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,3 @@ rustflags = ["-Cpanic=abort"]
5959
rustc-std-workspace-core = { path = 'rustc-std-workspace-core' }
6060
rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' }
6161
rustc-std-workspace-std = { path = 'rustc-std-workspace-std' }
62-
compiler_builtins = { path = "compiler-builtins/compiler-builtins" }

alloc/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ compiler_builtins = { path = "../compiler-builtins/compiler-builtins", features
2222
compiler-builtins-mem = ['compiler_builtins/mem']
2323
compiler-builtins-c = ["compiler_builtins/c"]
2424
compiler-builtins-no-f16-f128 = ["compiler_builtins/no-f16-f128"]
25-
# Make panics and failed asserts immediately abort without formatting any message
26-
panic_immediate_abort = ["core/panic_immediate_abort"]
2725
# Choose algorithms that are optimized for binary size instead of runtime performance
2826
optimize_for_size = ["core/optimize_for_size"]
2927

alloc/src/alloc.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ unsafe extern "Rust" {
1717
#[rustc_allocator]
1818
#[rustc_nounwind]
1919
#[rustc_std_internal_symbol]
20+
#[rustc_allocator_zeroed_variant = "__rust_alloc_zeroed"]
2021
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
2122
#[rustc_deallocator]
2223
#[rustc_nounwind]
@@ -360,7 +361,7 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
360361
unsafe extern "Rust" {
361362
// This is the magic symbol to call the global alloc error handler. rustc generates
362363
// it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the
363-
// default implementations below (`__rdl_oom`) otherwise.
364+
// default implementations below (`__rdl_alloc_error_handler`) otherwise.
364365
#[rustc_std_internal_symbol]
365366
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;
366367
}
@@ -407,12 +408,12 @@ pub const fn handle_alloc_error(layout: Layout) -> ! {
407408
}
408409
}
409410

410-
#[cfg(not(feature = "panic_immediate_abort"))]
411+
#[cfg(not(panic = "immediate-abort"))]
411412
{
412413
core::intrinsics::const_eval_select((layout,), ct_error, rt_error)
413414
}
414415

415-
#[cfg(feature = "panic_immediate_abort")]
416+
#[cfg(panic = "immediate-abort")]
416417
ct_error(layout)
417418
}
418419

@@ -424,7 +425,7 @@ pub mod __alloc_error_handler {
424425
// called via generated `__rust_alloc_error_handler` if there is no
425426
// `#[alloc_error_handler]`.
426427
#[rustc_std_internal_symbol]
427-
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
428+
pub unsafe fn __rdl_alloc_error_handler(size: usize, _align: usize) -> ! {
428429
unsafe extern "Rust" {
429430
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
430431
// Its value depends on the -Zoom={panic,abort} compiler option.

alloc/src/borrow.rs

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ use crate::fmt;
1616
#[cfg(not(no_global_oom_handling))]
1717
use crate::string::String;
1818

19+
// FIXME(inference): const bounds removed due to inference regressions found by crater;
20+
// see https://github.com/rust-lang/rust/issues/147964
21+
// #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
1922
#[stable(feature = "rust1", since = "1.0.0")]
20-
impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
21-
where
22-
B: ToOwned,
23+
impl<'a, B: ?Sized + ToOwned> Borrow<B> for Cow<'a, B>
24+
// where
25+
// B::Owned: [const] Borrow<B>,
2326
{
2427
fn borrow(&self) -> &B {
2528
&**self
@@ -212,43 +215,51 @@ impl<B: ?Sized + ToOwned> Clone for Cow<'_, B> {
212215
impl<B: ?Sized + ToOwned> Cow<'_, B> {
213216
/// Returns true if the data is borrowed, i.e. if `to_mut` would require additional work.
214217
///
218+
/// Note: this is an associated function, which means that you have to call
219+
/// it as `Cow::is_borrowed(&c)` instead of `c.is_borrowed()`. This is so
220+
/// that there is no conflict with a method on the inner type.
221+
///
215222
/// # Examples
216223
///
217224
/// ```
218225
/// #![feature(cow_is_borrowed)]
219226
/// use std::borrow::Cow;
220227
///
221228
/// let cow = Cow::Borrowed("moo");
222-
/// assert!(cow.is_borrowed());
229+
/// assert!(Cow::is_borrowed(&cow));
223230
///
224231
/// let bull: Cow<'_, str> = Cow::Owned("...moo?".to_string());
225-
/// assert!(!bull.is_borrowed());
232+
/// assert!(!Cow::is_borrowed(&bull));
226233
/// ```
227234
#[unstable(feature = "cow_is_borrowed", issue = "65143")]
228-
pub const fn is_borrowed(&self) -> bool {
229-
match *self {
235+
pub const fn is_borrowed(c: &Self) -> bool {
236+
match *c {
230237
Borrowed(_) => true,
231238
Owned(_) => false,
232239
}
233240
}
234241

235242
/// Returns true if the data is owned, i.e. if `to_mut` would be a no-op.
236243
///
244+
/// Note: this is an associated function, which means that you have to call
245+
/// it as `Cow::is_owned(&c)` instead of `c.is_owned()`. This is so that
246+
/// there is no conflict with a method on the inner type.
247+
///
237248
/// # Examples
238249
///
239250
/// ```
240251
/// #![feature(cow_is_borrowed)]
241252
/// use std::borrow::Cow;
242253
///
243254
/// let cow: Cow<'_, str> = Cow::Owned("moo".to_string());
244-
/// assert!(cow.is_owned());
255+
/// assert!(Cow::is_owned(&cow));
245256
///
246257
/// let bull = Cow::Borrowed("...moo?");
247-
/// assert!(!bull.is_owned());
258+
/// assert!(!Cow::is_owned(&bull));
248259
/// ```
249260
#[unstable(feature = "cow_is_borrowed", issue = "65143")]
250-
pub const fn is_owned(&self) -> bool {
251-
!self.is_borrowed()
261+
pub const fn is_owned(c: &Self) -> bool {
262+
!Cow::is_borrowed(c)
252263
}
253264

254265
/// Acquires a mutable reference to the owned form of the data.
@@ -325,10 +336,13 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
325336
}
326337
}
327338

339+
// FIXME(inference): const bounds removed due to inference regressions found by crater;
340+
// see https://github.com/rust-lang/rust/issues/147964
341+
// #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
328342
#[stable(feature = "rust1", since = "1.0.0")]
329343
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B>
330-
where
331-
B::Owned: Borrow<B>,
344+
// where
345+
// B::Owned: [const] Borrow<B>,
332346
{
333347
type Target = B;
334348

@@ -438,8 +452,14 @@ where
438452
}
439453
}
440454

455+
// FIXME(inference): const bounds removed due to inference regressions found by crater;
456+
// see https://github.com/rust-lang/rust/issues/147964
457+
// #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
441458
#[stable(feature = "rust1", since = "1.0.0")]
442-
impl<T: ?Sized + ToOwned> AsRef<T> for Cow<'_, T> {
459+
impl<T: ?Sized + ToOwned> AsRef<T> for Cow<'_, T>
460+
// where
461+
// T::Owned: [const] Borrow<T>,
462+
{
443463
fn as_ref(&self) -> &T {
444464
self
445465
}

0 commit comments

Comments
 (0)