Skip to content

Commit

Permalink
Merge pull request #1017 from ojeda/rust-rust-1.70
Browse files Browse the repository at this point in the history
Rust 1.70.0
  • Loading branch information
ojeda committed Jun 21, 2023
2 parents bc22545 + b1b4b5f commit c8d1ae2
Show file tree
Hide file tree
Showing 32 changed files with 486 additions and 765 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
ci:
runs-on: ubuntu-20.04
container: ghcr.io/rust-for-linux/ci:Rust-1.66.0
container: ghcr.io/rust-for-linux/ci:Rust-1.70.0
timeout-minutes: 25

strategy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kernel-arm-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y
#
# Rust hacking
#
CONFIG_RUST_DEBUG_ASSERTIONS=y
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
CONFIG_RUST_OVERFLOW_CHECKS=y
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
# CONFIG_RUST_OPT_LEVEL_0 is not set
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kernel-arm64-debug-thinlto.config
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y
#
# Rust hacking
#
CONFIG_RUST_DEBUG_ASSERTIONS=y
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
CONFIG_RUST_OVERFLOW_CHECKS=y
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
# CONFIG_RUST_OPT_LEVEL_0 is not set
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kernel-arm64-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y
#
# Rust hacking
#
CONFIG_RUST_DEBUG_ASSERTIONS=y
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
CONFIG_RUST_OVERFLOW_CHECKS=y
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
# CONFIG_RUST_OPT_LEVEL_0 is not set
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kernel-ppc64le-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ CONFIG_RUNTIME_TESTING_MENU=y
#
# Rust hacking
#
CONFIG_RUST_DEBUG_ASSERTIONS=y
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
CONFIG_RUST_OVERFLOW_CHECKS=y
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
CONFIG_RUST_OPT_LEVEL_0=y
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kernel-riscv64-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ CONFIG_CC_HAS_SANCOV_TRACE_PC=y
#
# Rust hacking
#
CONFIG_RUST_DEBUG_ASSERTIONS=y
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
CONFIG_RUST_OVERFLOW_CHECKS=y
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
CONFIG_RUST_OPT_LEVEL_0=y
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kernel-x86_64-debug-thinlto.config
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ CONFIG_RUNTIME_TESTING_MENU=y
#
# Rust hacking
#
CONFIG_RUST_DEBUG_ASSERTIONS=y
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
CONFIG_RUST_OVERFLOW_CHECKS=y
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
CONFIG_RUST_OPT_LEVEL_0=y
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kernel-x86_64-debug.config
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ CONFIG_RUNTIME_TESTING_MENU=y
#
# Rust hacking
#
CONFIG_RUST_DEBUG_ASSERTIONS=y
#CONFIG_RUST_DEBUG_ASSERTIONS is not set
CONFIG_RUST_OVERFLOW_CHECKS=y
# CONFIG_RUST_OPT_LEVEL_SIMILAR_AS_CHOSEN_FOR_C is not set
CONFIG_RUST_OPT_LEVEL_0=y
Expand Down
2 changes: 1 addition & 1 deletion Documentation/process/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ you probably needn't concern yourself with pcmciautils.
====================== =============== ========================================
GNU C 5.1 gcc --version
Clang/LLVM (optional) 11.0.0 clang --version
Rust (optional) 1.66.0 rustc --version
Rust (optional) 1.70.0 rustc --version
bindgen (optional) 0.56.0 bindgen --version
GNU make 3.82 make --version
bash 4.2 bash --version
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ export rust_common_flags := --edition=2021 \
-Dclippy::let_unit_value -Dclippy::mut_mut \
-Dclippy::needless_bitwise_bool \
-Dclippy::needless_continue \
-Dclippy::no_mangle_with_rust_abi \
-Wclippy::dbg_macro

KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
Expand Down
55 changes: 22 additions & 33 deletions rust/alloc/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,28 @@ use core::ptr::{self, NonNull};
#[doc(inline)]
pub use core::alloc::*;

use core::marker::Destruct;

#[cfg(test)]
mod tests;

extern "Rust" {
// These are the magic symbols to call the global allocator. rustc generates
// These are the magic symbols to call the global allocator. rustc generates
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
// (the code expanding that attribute macro generates those functions), or to call
// the default implementations in libstd (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
// the default implementations in std (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
// otherwise.
// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them
// like `malloc`, `realloc`, and `free`, respectively.
#[rustc_allocator]
#[cfg_attr(not(bootstrap), rustc_nounwind)]
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
#[rustc_nounwind]
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
#[rustc_deallocator]
#[cfg_attr(not(bootstrap), rustc_nounwind)]
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
#[rustc_nounwind]
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
#[rustc_reallocator]
#[cfg_attr(not(bootstrap), rustc_nounwind)]
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
#[rustc_nounwind]
fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8;
#[rustc_allocator_zeroed]
#[cfg_attr(not(bootstrap), rustc_nounwind)]
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
#[rustc_nounwind]
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
}

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

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

#[cfg(not(no_global_oom_handling))]
extern "Rust" {
// This is the magic symbol to call the global alloc error handler. rustc generates
// This is the magic symbol to call the global alloc error handler. rustc generates
// it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the
// default implementations below (`__rdl_oom`) otherwise.
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;
Expand Down Expand Up @@ -404,25 +394,24 @@ pub use std::alloc::handle_alloc_error;
#[allow(unused_attributes)]
#[unstable(feature = "alloc_internals", issue = "none")]
pub mod __alloc_error_handler {
use crate::alloc::Layout;

// called via generated `__rust_alloc_error_handler`

// if there is no `#[alloc_error_handler]`
// called via generated `__rust_alloc_error_handler` if there is no
// `#[alloc_error_handler]`.
#[rustc_std_internal_symbol]
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
panic!("memory allocation of {size} bytes failed")
}

// if there is an `#[alloc_error_handler]`
#[rustc_std_internal_symbol]
pub unsafe fn __rg_oom(size: usize, align: usize) -> ! {
let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
extern "Rust" {
#[lang = "oom"]
fn oom_impl(layout: Layout) -> !;
// This symbol is emitted by rustc next to __rust_alloc_error_handler.
// Its value depends on the -Zoom={panic,abort} compiler option.
static __rust_alloc_error_handler_should_panic: u8;
}

#[allow(unused_unsafe)]
if unsafe { __rust_alloc_error_handler_should_panic != 0 } {
panic!("memory allocation of {size} bytes failed")
} else {
core::panicking::panic_nounwind_fmt(format_args!(
"memory allocation of {size} bytes failed"
))
}
unsafe { oom_impl(layout) }
}
}

Expand Down
5 changes: 2 additions & 3 deletions rust/alloc/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,9 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
}

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

Expand Down
Loading

0 comments on commit c8d1ae2

Please sign in to comment.