Skip to content

Commit c8d1ae2

Browse files
authored
Merge pull request #1017 from ojeda/rust-rust-1.70
Rust 1.70.0
2 parents bc22545 + b1b4b5f commit c8d1ae2

32 files changed

+486
-765
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
ci:
99
runs-on: ubuntu-20.04
10-
container: ghcr.io/rust-for-linux/ci:Rust-1.66.0
10+
container: ghcr.io/rust-for-linux/ci:Rust-1.70.0
1111
timeout-minutes: 25
1212

1313
strategy:

.github/workflows/kernel-arm-debug.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y
18171817
#
18181818
# Rust hacking
18191819
#
1820-
CONFIG_RUST_DEBUG_ASSERTIONS=y
1820+
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
18211821
CONFIG_RUST_OVERFLOW_CHECKS=y
18221822
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
18231823
# CONFIG_RUST_OPT_LEVEL_0 is not set

.github/workflows/kernel-arm64-debug-thinlto.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y
14651465
#
14661466
# Rust hacking
14671467
#
1468-
CONFIG_RUST_DEBUG_ASSERTIONS=y
1468+
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
14691469
CONFIG_RUST_OVERFLOW_CHECKS=y
14701470
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
14711471
# CONFIG_RUST_OPT_LEVEL_0 is not set

.github/workflows/kernel-arm64-debug.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y
14601460
#
14611461
# Rust hacking
14621462
#
1463-
CONFIG_RUST_DEBUG_ASSERTIONS=y
1463+
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
14641464
CONFIG_RUST_OVERFLOW_CHECKS=y
14651465
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
14661466
# CONFIG_RUST_OPT_LEVEL_0 is not set

.github/workflows/kernel-ppc64le-debug.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ CONFIG_RUNTIME_TESTING_MENU=y
15821582
#
15831583
# Rust hacking
15841584
#
1585-
CONFIG_RUST_DEBUG_ASSERTIONS=y
1585+
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
15861586
CONFIG_RUST_OVERFLOW_CHECKS=y
15871587
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
15881588
CONFIG_RUST_OPT_LEVEL_0=y

.github/workflows/kernel-riscv64-debug.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y
13101310
#
13111311
# Rust hacking
13121312
#
1313-
CONFIG_RUST_DEBUG_ASSERTIONS=y
1313+
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
13141314
CONFIG_RUST_OVERFLOW_CHECKS=y
13151315
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
13161316
CONFIG_RUST_OPT_LEVEL_0=y

.github/workflows/kernel-x86_64-debug-thinlto.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ CONFIG_RUNTIME_TESTING_MENU=y
15331533
#
15341534
# Rust hacking
15351535
#
1536-
CONFIG_RUST_DEBUG_ASSERTIONS=y
1536+
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
15371537
CONFIG_RUST_OVERFLOW_CHECKS=y
15381538
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
15391539
CONFIG_RUST_OPT_LEVEL_0=y

.github/workflows/kernel-x86_64-debug.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ CONFIG_RUNTIME_TESTING_MENU=y
15361536
#
15371537
# Rust hacking
15381538
#
1539-
CONFIG_RUST_DEBUG_ASSERTIONS=y
1539+
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
15401540
CONFIG_RUST_OVERFLOW_CHECKS=y
15411541
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
15421542
CONFIG_RUST_OPT_LEVEL_0=y

Documentation/process/changes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ you probably needn't concern yourself with pcmciautils.
3131
====================== =============== ========================================
3232
GNU C 5.1 gcc --version
3333
Clang/LLVM (optional) 11.0.0 clang --version
34-
Rust (optional) 1.66.0 rustc --version
34+
Rust (optional) 1.70.0 rustc --version
3535
bindgen (optional) 0.56.0 bindgen --version
3636
GNU make 3.82 make --version
3737
bash 4.2 bash --version

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ export rust_common_flags := --edition=2021 \
466466
-Dclippy::let_unit_value -Dclippy::mut_mut \
467467
-Dclippy::needless_bitwise_bool \
468468
-Dclippy::needless_continue \
469+
-Dclippy::no_mangle_with_rust_abi \
469470
-Wclippy::dbg_macro
470471

471472
KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)

rust/alloc/alloc.rs

+22-33
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,28 @@ use core::ptr::{self, NonNull};
1616
#[doc(inline)]
1717
pub use core::alloc::*;
1818

19-
use core::marker::Destruct;
20-
2119
#[cfg(test)]
2220
mod tests;
2321

2422
extern "Rust" {
25-
// These are the magic symbols to call the global allocator. rustc generates
23+
// These are the magic symbols to call the global allocator. rustc generates
2624
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
2725
// (the code expanding that attribute macro generates those functions), or to call
28-
// the default implementations in libstd (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
26+
// the default implementations in std (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
2927
// otherwise.
3028
// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them
3129
// like `malloc`, `realloc`, and `free`, respectively.
3230
#[rustc_allocator]
33-
#[cfg_attr(not(bootstrap), rustc_nounwind)]
34-
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
31+
#[rustc_nounwind]
3532
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
3633
#[rustc_deallocator]
37-
#[cfg_attr(not(bootstrap), rustc_nounwind)]
38-
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
34+
#[rustc_nounwind]
3935
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
4036
#[rustc_reallocator]
41-
#[cfg_attr(not(bootstrap), rustc_nounwind)]
42-
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
37+
#[rustc_nounwind]
4338
fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8;
4439
#[rustc_allocator_zeroed]
45-
#[cfg_attr(not(bootstrap), rustc_nounwind)]
46-
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
40+
#[rustc_nounwind]
4741
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
4842
}
4943

@@ -337,16 +331,12 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
337331

338332
#[cfg_attr(not(test), lang = "box_free")]
339333
#[inline]
340-
#[rustc_const_unstable(feature = "const_box", issue = "92521")]
341334
// This signature has to be the same as `Box`, otherwise an ICE will happen.
342335
// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as
343336
// well.
344337
// For example if `Box` is changed to `struct Box<T: ?Sized, A: Allocator>(Unique<T>, A)`,
345338
// this function has to be changed to `fn box_free<T: ?Sized, A: Allocator>(Unique<T>, A)` as well.
346-
pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Destruct>(
347-
ptr: Unique<T>,
348-
alloc: A,
349-
) {
339+
pub(crate) unsafe fn box_free<T: ?Sized, A: Allocator>(ptr: Unique<T>, alloc: A) {
350340
unsafe {
351341
let size = size_of_val(ptr.as_ref());
352342
let align = min_align_of_val(ptr.as_ref());
@@ -359,7 +349,7 @@ pub(crate) const unsafe fn box_free<T: ?Sized, A: ~const Allocator + ~const Dest
359349

360350
#[cfg(not(no_global_oom_handling))]
361351
extern "Rust" {
362-
// This is the magic symbol to call the global alloc error handler. rustc generates
352+
// This is the magic symbol to call the global alloc error handler. rustc generates
363353
// it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the
364354
// default implementations below (`__rdl_oom`) otherwise.
365355
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;
@@ -404,25 +394,24 @@ pub use std::alloc::handle_alloc_error;
404394
#[allow(unused_attributes)]
405395
#[unstable(feature = "alloc_internals", issue = "none")]
406396
pub mod __alloc_error_handler {
407-
use crate::alloc::Layout;
408-
409-
// called via generated `__rust_alloc_error_handler`
410-
411-
// if there is no `#[alloc_error_handler]`
397+
// called via generated `__rust_alloc_error_handler` if there is no
398+
// `#[alloc_error_handler]`.
412399
#[rustc_std_internal_symbol]
413400
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
414-
panic!("memory allocation of {size} bytes failed")
415-
}
416-
417-
// if there is an `#[alloc_error_handler]`
418-
#[rustc_std_internal_symbol]
419-
pub unsafe fn __rg_oom(size: usize, align: usize) -> ! {
420-
let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
421401
extern "Rust" {
422-
#[lang = "oom"]
423-
fn oom_impl(layout: Layout) -> !;
402+
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
403+
// Its value depends on the -Zoom={panic,abort} compiler option.
404+
static __rust_alloc_error_handler_should_panic: u8;
405+
}
406+
407+
#[allow(unused_unsafe)]
408+
if unsafe { __rust_alloc_error_handler_should_panic != 0 } {
409+
panic!("memory allocation of {size} bytes failed")
410+
} else {
411+
core::panicking::panic_nounwind_fmt(format_args!(
412+
"memory allocation of {size} bytes failed"
413+
))
424414
}
425-
unsafe { oom_impl(layout) }
426415
}
427416
}
428417

rust/alloc/borrow.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,9 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
330330
}
331331

332332
#[stable(feature = "rust1", since = "1.0.0")]
333-
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
334-
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
333+
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B>
335334
where
336-
B::Owned: ~const Borrow<B>,
335+
B::Owned: Borrow<B>,
337336
{
338337
type Target = B;
339338

0 commit comments

Comments
 (0)