Skip to content

Commit 72f0205

Browse files
Rollup merge of #136705 - compiler-errors:edition-library, r=jhpratt
Some miscellaneous edition-related library tweaks Some library edition tweaks that can be done separately from upgrading the whole standard library to edition 2024 (which is blocked on getting the submodules upgraded, for example)
2 parents f471ce3 + 4312d7b commit 72f0205

File tree

73 files changed

+156
-152
lines changed

Some content is hidden

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

73 files changed

+156
-152
lines changed

library/alloc/src/alloc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use core::hint;
1010
#[cfg(not(test))]
1111
use core::ptr::{self, NonNull};
1212

13-
extern "Rust" {
13+
unsafe extern "Rust" {
1414
// These are the magic symbols to call the global allocator. rustc generates
1515
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
1616
// (the code expanding that attribute macro generates those functions), or to call
@@ -355,7 +355,7 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
355355
// # Allocation error handler
356356

357357
#[cfg(not(no_global_oom_handling))]
358-
extern "Rust" {
358+
unsafe extern "Rust" {
359359
// This is the magic symbol to call the global alloc error handler. rustc generates
360360
// it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the
361361
// default implementations below (`__rdl_oom`) otherwise.
@@ -426,7 +426,7 @@ pub mod __alloc_error_handler {
426426
// `#[alloc_error_handler]`.
427427
#[rustc_std_internal_symbol]
428428
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
429-
extern "Rust" {
429+
unsafe extern "Rust" {
430430
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
431431
// Its value depends on the -Zoom={panic,abort} compiler option.
432432
static __rust_alloc_error_handler_should_panic: u8;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<I: Iterator> MergeIterInner<I> {
7474
b_next = self.b.next();
7575
}
7676
}
77-
if let (Some(ref a1), Some(ref b1)) = (&a_next, &b_next) {
77+
if let (Some(a1), Some(b1)) = (&a_next, &b_next) {
7878
match cmp(a1, b1) {
7979
Ordering::Less => self.peeked = b_next.take().map(Peeked::B),
8080
Ordering::Greater => self.peeked = a_next.take().map(Peeked::A),

library/alloc/src/ffi/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl CString {
397397
// information about the size of the allocation is correct on Rust's
398398
// side.
399399
unsafe {
400-
extern "C" {
400+
unsafe extern "C" {
401401
/// Provided by libc or compiler_builtins.
402402
fn strlen(s: *const c_char) -> usize;
403403
}

library/core/src/ffi/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ const unsafe fn strlen(ptr: *const c_char) -> usize {
731731

732732
len
733733
} else {
734-
extern "C" {
734+
unsafe extern "C" {
735735
/// Provided by libc or compiler_builtins.
736736
fn strlen(s: *const c_char) -> usize;
737737
}

library/core/src/ffi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ impl fmt::Debug for c_void {
9090
cfg(not(target_feature = "crt-static"))
9191
)]
9292
#[link(name = "/defaultlib:libcmt", modifiers = "+verbatim", cfg(target_feature = "crt-static"))]
93-
extern "C" {}
93+
unsafe extern "C" {}

library/core/src/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4855,7 +4855,7 @@ pub const unsafe fn copysignf128(_x: f128, _y: f128) -> f128 {
48554855
#[cfg(miri)]
48564856
#[rustc_allow_const_fn_unstable(const_eval_select)]
48574857
pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize) {
4858-
extern "Rust" {
4858+
unsafe extern "Rust" {
48594859
/// Miri-provided extern function to promise that a given pointer is properly aligned for
48604860
/// "symbolic" alignment checks. Will fail if the pointer is not actually aligned or `align` is
48614861
/// not a power of two. Has no effect when alignment checks are concrete (which is the default).

library/core/src/iter/sources/once_with.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ use crate::iter::{FusedIterator, TrustedLen};
5858
/// ```
5959
#[inline]
6060
#[stable(feature = "iter_once_with", since = "1.43.0")]
61-
pub fn once_with<A, F: FnOnce() -> A>(gen: F) -> OnceWith<F> {
62-
OnceWith { gen: Some(gen) }
61+
pub fn once_with<A, F: FnOnce() -> A>(make: F) -> OnceWith<F> {
62+
OnceWith { make: Some(make) }
6363
}
6464

6565
/// An iterator that yields a single element of type `A` by
@@ -70,13 +70,13 @@ pub fn once_with<A, F: FnOnce() -> A>(gen: F) -> OnceWith<F> {
7070
#[derive(Clone)]
7171
#[stable(feature = "iter_once_with", since = "1.43.0")]
7272
pub struct OnceWith<F> {
73-
gen: Option<F>,
73+
make: Option<F>,
7474
}
7575

7676
#[stable(feature = "iter_once_with_debug", since = "1.68.0")]
7777
impl<F> fmt::Debug for OnceWith<F> {
7878
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
79-
if self.gen.is_some() {
79+
if self.make.is_some() {
8080
f.write_str("OnceWith(Some(_))")
8181
} else {
8282
f.write_str("OnceWith(None)")
@@ -90,13 +90,13 @@ impl<A, F: FnOnce() -> A> Iterator for OnceWith<F> {
9090

9191
#[inline]
9292
fn next(&mut self) -> Option<A> {
93-
let f = self.gen.take()?;
93+
let f = self.make.take()?;
9494
Some(f())
9595
}
9696

9797
#[inline]
9898
fn size_hint(&self) -> (usize, Option<usize>) {
99-
self.gen.iter().size_hint()
99+
self.make.iter().size_hint()
100100
}
101101
}
102102

@@ -110,7 +110,7 @@ impl<A, F: FnOnce() -> A> DoubleEndedIterator for OnceWith<F> {
110110
#[stable(feature = "iter_once_with", since = "1.43.0")]
111111
impl<A, F: FnOnce() -> A> ExactSizeIterator for OnceWith<F> {
112112
fn len(&self) -> usize {
113-
self.gen.iter().len()
113+
self.make.iter().len()
114114
}
115115
}
116116

library/core/src/panicking.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
5959

6060
// NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
6161
// that gets resolved to the `#[panic_handler]` function.
62-
extern "Rust" {
62+
unsafe extern "Rust" {
6363
#[lang = "panic_impl"]
6464
fn panic_impl(pi: &PanicInfo<'_>) -> !;
6565
}
@@ -100,7 +100,7 @@ pub const fn panic_nounwind_fmt(fmt: fmt::Arguments<'_>, force_no_backtrace: boo
100100

101101
// NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
102102
// that gets resolved to the `#[panic_handler]` function.
103-
extern "Rust" {
103+
unsafe extern "Rust" {
104104
#[lang = "panic_impl"]
105105
fn panic_impl(pi: &PanicInfo<'_>) -> !;
106106
}

library/core/src/ptr/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub struct DynMetadata<Dyn: ?Sized> {
155155
_phantom: crate::marker::PhantomData<Dyn>,
156156
}
157157

158-
extern "C" {
158+
unsafe extern "C" {
159159
/// Opaque type for accessing vtables.
160160
///
161161
/// Private implementation detail of `DynMetadata::size_of` etc.

library/coretests/tests/mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ fn offset_of_dst() {
648648
z: dyn Trait,
649649
}
650650

651-
extern "C" {
651+
unsafe extern "C" {
652652
type Extern;
653653
}
654654

0 commit comments

Comments
 (0)