Skip to content

Commit 3f893e1

Browse files
committed
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: #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 bd12347 commit 3f893e1

Some content is hidden

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

41 files changed

+1378
-472
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
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.62.0-2
10+
container: ghcr.io/rust-for-linux/ci:Rust-1.66.0
1111
timeout-minutes: 25
1212

1313
strategy:

Documentation/process/changes.rst

Lines changed: 1 addition & 1 deletion
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

drivers/android/process.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ impl ProcessInner {
149149
thread: Option<&Thread>,
150150
) -> NodeRef {
151151
self.update_node_refcount(&node, true, strong, false, thread);
152+
#[allow(clippy::bool_to_int_with_if)]
152153
let strong_count = if strong { 1 } else { 0 };
153154
NodeRef::new(node, strong_count, 1 - strong_count)
154155
}
@@ -430,6 +431,7 @@ impl Process {
430431
}
431432

432433
// Find id.
434+
#[allow(clippy::bool_to_int_with_if)]
433435
let mut target = if is_mananger { 0 } else { 1 };
434436
for handle in refs.by_handle.keys() {
435437
if *handle > target {

drivers/android/thread.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ impl DeliverToRead for ThreadError {
858858
let code = self.error_code.load(Ordering::Relaxed);
859859

860860
// Return the `ThreadError` to the thread.
861+
#[allow(clippy::explicit_auto_deref)]
861862
(self.return_fn)(&mut *thread.inner.lock(), self);
862863

863864
// Deliver the error code to userspace.

rust/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ rust-analyzer:
394394

395395
$(obj)/core.o: private skip_clippy = 1
396396
$(obj)/core.o: private skip_flags = -Dunreachable_pub
397-
$(obj)/core.o: private rustc_target_flags = $(core-cfgs)
397+
$(obj)/core.o: private rustc_target_flags = $(core-cfgs) -Aunused-imports
398398
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs $(obj)/target.json FORCE
399399
$(call if_changed_dep,rustc_library)
400400

rust/alloc/alloc.rs

Lines changed: 18 additions & 8 deletions
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"]

rust/alloc/borrow.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use Cow::*;
2323
impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
2424
where
2525
B: ToOwned,
26-
<B as ToOwned>::Owned: 'a,
2726
{
2827
fn borrow(&self) -> &B {
2928
&**self
@@ -62,21 +61,20 @@ pub trait ToOwned {
6261

6362
/// Uses borrowed data to replace owned data, usually by cloning.
6463
///
65-
/// This is borrow-generalized version of `Clone::clone_from`.
64+
/// This is borrow-generalized version of [`Clone::clone_from`].
6665
///
6766
/// # Examples
6867
///
6968
/// Basic usage:
7069
///
7170
/// ```
72-
/// # #![feature(toowned_clone_into)]
7371
/// let mut s: String = String::new();
7472
/// "hello".clone_into(&mut s);
7573
///
7674
/// let mut v: Vec<i32> = Vec::new();
7775
/// [1, 2][..].clone_into(&mut v);
7876
/// ```
79-
#[unstable(feature = "toowned_clone_into", reason = "recently added", issue = "41263")]
77+
#[stable(feature = "toowned_clone_into", since = "1.63.0")]
8078
fn clone_into(&self, target: &mut Self::Owned) {
8179
*target = self.to_owned();
8280
}

0 commit comments

Comments
 (0)