Skip to content

Commit aac1474

Browse files
ojedaasahilina
authored andcommitted
rust: upgrade to Rust 1.66.0
Upgrade the Rust version from 1.62.0 to 1.66.0. The overwhelming majority of the commit is about upgrading our `alloc` fork to the new version from upstream [1]. License has not changed [2][3] (there were changes in the `COPYRIGHT` file, but unrelated to `alloc`). As in the previous version upgrades (done out of tree so far), upgrading `alloc` requires checking that our small additions (`try_*`) still match their original (non`-try_*`) versions. With this version upgrade, the following unstable Rust features were stabilized: `bench_black_box` (1.66.0), `const_ptr_offset_from` (1.65.0), `core_ffi_c` (1.64.0) and `generic_associated_types` (1.65.0). Thus remove them. This also implies that only two unstable features remain allowed for non-`rust/` code: `allocator_api` and `const_refs_to_cell`. There are some new Clippy warnings that we are triggering (i.e. introduced since 1.62.0), as well as a few others that were not triggered before, thus allow them in this commit and clean up or remove them as needed later on: - `borrow_deref_ref` (new in 1.63.0). - `explicit_auto_deref` (new in 1.64.0). - `bool_to_int_with_if` (new in 1.65.0). - `needless_borrow`. - `type_complexity`. - `unnecessary_cast` (allowed only on `CONFIG_ARM`). Furthermore, `rustdoc` lint `broken_intra_doc_links` is triggering on links pointing to `macro_export` `macro_rules` defined in the same module (i.e. appearing in the crate root). However, even if the warning appears, the link still gets generated like in previous versions, thus it is a bit confusing. An issue has been opened upstream [4], and it appears that the link still being generated was a compatibility measure, thus we will need to adapt to the new behavior (done in the next patch). In addition, there is an added `#[const_trait]` attribute in `RawDeviceId`, due to 1.66.0's PR "Require `#[const_trait]` on `Trait` for `impl const Trait`") [5]. Finally, the `-Aunused-imports` was added for compiling `core`. This was fixed upstream for 1.67.0 in PR "Fix warning when libcore is compiled with no_fp_fmt_parse" [6], and prevented for the future for that `cfg` in PR "core: ensure `no_fp_fmt_parse builds` are warning-free" [7]. Reviewed-by: Björn Roy Baron <[email protected]> Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Tested-by: Martin Rodriguez Reboredo <[email protected]> Reviewed-by: Gary Guo <[email protected]> Reviewed-by: Vincenzo Palazzo <[email protected]> Reviewed-by: Alice Ferrazzi <[email protected]> Tested-by: Alice Ferrazzi <[email protected]> Reviewed-by: Neal Gompa <[email protected]> Tested-by: Neal Gompa <[email protected]> Link: Rust-for-Linux#947 Link: https://github.com/rust-lang/rust/tree/1.66.0/library/alloc/src [1] Link: https://github.com/rust-lang/rust/blob/1.66.0/library/alloc/Cargo.toml#L4 [2] Link: https://github.com/rust-lang/rust/blob/1.66.0/COPYRIGHT [3] Link: rust-lang/rust#106142 [4] Link: rust-lang/rust#100982 [5] Link: rust-lang/rust#105434 [6] Link: rust-lang/rust#105811 [7] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 0351080 commit aac1474

22 files changed

+1019
-257
lines changed

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.62.0 rustc --version
34+
Rust (optional) 1.66.0 rustc --version
3535
bindgen (optional) 0.56.0 bindgen --version
3636
GNU make 3.82 make --version
3737
bash 4.2 bash --version

rust/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ endif
392392
$(obj)/core.o: private skip_clippy = 1
393393
$(obj)/core.o: private skip_flags = -Dunreachable_pub
394394
$(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
395-
$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
395+
$(obj)/core.o: private rustc_target_flags = $(core-cfgs) -Aunused-imports
396396
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs scripts/target.json FORCE
397397
$(call if_changed_dep,rustc_library)
398398

rust/alloc/alloc.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,23 @@ extern "Rust" {
2727
// (the code expanding that attribute macro generates those functions), or to call
2828
// the default implementations in libstd (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
2929
// otherwise.
30-
// The rustc fork of LLVM also special-cases these function names to be able to optimize them
30+
// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them
3131
// like `malloc`, `realloc`, and `free`, respectively.
3232
#[rustc_allocator]
33-
#[rustc_allocator_nounwind]
33+
#[cfg_attr(not(bootstrap), rustc_nounwind)]
34+
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
3435
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
35-
#[rustc_allocator_nounwind]
36+
#[rustc_deallocator]
37+
#[cfg_attr(not(bootstrap), rustc_nounwind)]
38+
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
3639
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
37-
#[rustc_allocator_nounwind]
40+
#[rustc_reallocator]
41+
#[cfg_attr(not(bootstrap), rustc_nounwind)]
42+
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
3843
fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8;
39-
#[rustc_allocator_nounwind]
44+
#[rustc_allocator_zeroed]
45+
#[cfg_attr(not(bootstrap), rustc_nounwind)]
46+
#[cfg_attr(bootstrap, rustc_allocator_nounwind)]
4047
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
4148
}
4249

@@ -72,11 +79,14 @@ pub use std::alloc::Global;
7279
/// # Examples
7380
///
7481
/// ```
75-
/// use std::alloc::{alloc, dealloc, Layout};
82+
/// use std::alloc::{alloc, dealloc, handle_alloc_error, Layout};
7683
///
7784
/// unsafe {
7885
/// let layout = Layout::new::<u16>();
7986
/// let ptr = alloc(layout);
87+
/// if ptr.is_null() {
88+
/// handle_alloc_error(layout);
89+
/// }
8090
///
8191
/// *(ptr as *mut u16) = 42;
8292
/// assert_eq!(*(ptr as *mut u16), 42);
@@ -400,13 +410,13 @@ pub mod __alloc_error_handler {
400410

401411
// if there is no `#[alloc_error_handler]`
402412
#[rustc_std_internal_symbol]
403-
pub unsafe extern "C-unwind" fn __rdl_oom(size: usize, _align: usize) -> ! {
413+
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
404414
panic!("memory allocation of {size} bytes failed")
405415
}
406416

407417
// if there is an `#[alloc_error_handler]`
408418
#[rustc_std_internal_symbol]
409-
pub unsafe extern "C-unwind" fn __rg_oom(size: usize, align: usize) -> ! {
419+
pub unsafe fn __rg_oom(size: usize, align: usize) -> ! {
410420
let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
411421
extern "Rust" {
412422
#[lang = "oom"]

0 commit comments

Comments
 (0)