From 80d5ffbe7c4109229571bf94182cf3f40397795e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E7=82=B3=E6=9D=83?= <695601626@qq.com> Date: Mon, 12 Feb 2024 11:00:33 +0800 Subject: [PATCH] chore: update to Rust 1.76 (#22376) Update to Rust 1.76 --- cli/napi/util.rs | 21 +++------------------ cli/tools/info.rs | 2 +- ext/cron/local.rs | 4 +--- rust-toolchain.toml | 2 +- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/cli/napi/util.rs b/cli/napi/util.rs index ac6145a8f2..edf109460f 100644 --- a/cli/napi/util.rs +++ b/cli/napi/util.rs @@ -1,23 +1,8 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - use deno_runtime::deno_napi::*; -use std::cell::Cell; - -unsafe fn get_backing_store_slice( - backing_store: &mut v8::SharedRef, - byte_offset: usize, - byte_length: usize, -) -> &mut [u8] { - let cells: *const [Cell] = - &backing_store[byte_offset..byte_offset + byte_length]; - let mut bytes = cells as *mut [u8]; - &mut *bytes -} pub fn get_array_buffer_ptr(ab: v8::Local) -> *mut u8 { - let mut backing_store = ab.get_backing_store(); - let byte_length = ab.byte_length(); - let mut slice = - unsafe { get_backing_store_slice(&mut backing_store, 0, byte_length) }; - slice.as_mut_ptr() + // SAFETY: Thanks to the null pointer optimization, NonNull and Option> are guaranteed + // to have the same size and alignment. + unsafe { std::mem::transmute(ab.data()) } } diff --git a/cli/tools/info.rs b/cli/tools/info.rs index 30ceb98e46..dd820f24f1 100644 --- a/cli/tools/info.rs +++ b/cli/tools/info.rs @@ -284,7 +284,7 @@ fn print_tree_node( fn print_children( writer: &mut TWrite, prefix: &str, - children: &Vec, + children: &[TreeNode], ) -> fmt::Result { const SIBLING_CONNECTOR: char = '├'; const LAST_SIBLING_CONNECTOR: char = '└'; diff --git a/ext/cron/local.rs b/ext/cron/local.rs index cc3f57569b..31d001bc3d 100644 --- a/ext/cron/local.rs +++ b/ext/cron/local.rs @@ -318,9 +318,7 @@ fn compute_next_deadline(cron_expression: &str) -> Result { Ok(next_deadline.timestamp_millis() as u64) } -fn validate_backoff_schedule( - backoff_schedule: &Vec, -) -> Result<(), AnyError> { +fn validate_backoff_schedule(backoff_schedule: &[u32]) -> Result<(), AnyError> { if backoff_schedule.len() > MAX_BACKOFF_COUNT { return Err(type_error("Invalid backoff schedule")); } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c1f5c7bd1f..a436857e58 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.75.0" +channel = "1.76.0" components = ["rustfmt", "clippy"]