From e2a817d11caaa1706365908aaee6766b5853e7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E7=82=B3=E6=9D=83?= <695601626@qq.com> Date: Thu, 11 Apr 2024 06:08:23 +0800 Subject: [PATCH] chore: update to Rust 1.77.2 (#23262) update to Rust 1.77.2 --------- Co-authored-by: Matt Mastracci --- .github/workflows/ci.generate.ts | 2 +- .github/workflows/ci.yml | 8 ++++---- cli/npm/managed/cache.rs | 1 + cli/tools/vendor/build.rs | 11 ----------- cli/tools/vendor/test.rs | 8 -------- cli/util/fs.rs | 5 ++++- cli/worker.rs | 6 ------ ext/ffi/callback.rs | 2 +- ext/ffi/dlfcn.rs | 2 +- ext/http/http_next.rs | 25 +------------------------ ext/http/service.rs | 2 +- ext/napi/lib.rs | 2 +- ext/node/ops/vm_internal.rs | 4 +--- ext/web/stream_resource.rs | 2 +- rust-toolchain.toml | 2 +- tests/napi/src/promise.rs | 7 ++++++- 16 files changed, 24 insertions(+), 65 deletions(-) diff --git a/.github/workflows/ci.generate.ts b/.github/workflows/ci.generate.ts index 17c14a9b26..4133e12626 100755 --- a/.github/workflows/ci.generate.ts +++ b/.github/workflows/ci.generate.ts @@ -5,7 +5,7 @@ import { stringify } from "jsr:@std/yaml@^0.221/stringify"; // Bump this number when you want to purge the cache. // Note: the tools/release/01_bump_crate_versions.ts script will update this version // automatically via regex, so ensure that this line maintains this format. -const cacheVersion = 81; +const cacheVersion = 82; const ubuntuX86Runner = "ubuntu-22.04"; const ubuntuX86XlRunner = "ubuntu-22.04-xl"; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43a4b37f02..5ede2dfa30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -363,8 +363,8 @@ jobs: path: |- ~/.cargo/registry/index ~/.cargo/registry/cache - key: '81-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles(''Cargo.lock'') }}' - restore-keys: '81-cargo-home-${{ matrix.os }}-${{ matrix.arch }}' + key: '82-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles(''Cargo.lock'') }}' + restore-keys: '82-cargo-home-${{ matrix.os }}-${{ matrix.arch }}' if: '!(matrix.skip)' - name: Restore cache build output (PR) uses: actions/cache/restore@v4 @@ -376,7 +376,7 @@ jobs: !./target/*/*.zip !./target/*/*.tar.gz key: never_saved - restore-keys: '81-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-' + restore-keys: '82-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-' - name: Apply and update mtime cache if: '!(matrix.skip) && (!startsWith(github.ref, ''refs/tags/''))' uses: ./.github/mtime_cache @@ -670,7 +670,7 @@ jobs: !./target/*/gn_out !./target/*/*.zip !./target/*/*.tar.gz - key: '81-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' + key: '82-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' publish-canary: name: publish canary runs-on: ubuntu-22.04 diff --git a/cli/npm/managed/cache.rs b/cli/npm/managed/cache.rs index 89587b4303..9ba5c1c996 100644 --- a/cli/npm/managed/cache.rs +++ b/cli/npm/managed/cache.rs @@ -231,6 +231,7 @@ pub fn with_folder_sync_lock( match fs::OpenOptions::new() .write(true) .create(true) + .truncate(false) .open(&sync_lock_path) { Ok(_) => { diff --git a/cli/tools/vendor/build.rs b/cli/tools/vendor/build.rs index 1646a99592..0590992b04 100644 --- a/cli/tools/vendor/build.rs +++ b/cli/tools/vendor/build.rs @@ -2,7 +2,6 @@ use std::fmt::Write as _; use std::path::Path; -use std::path::PathBuf; use std::sync::Arc; use deno_ast::ModuleSpecifier; @@ -34,19 +33,13 @@ use super::specifiers::is_remote_specifier; /// Allows substituting the environment for testing purposes. pub trait VendorEnvironment { - fn cwd(&self) -> Result; fn create_dir_all(&self, dir_path: &Path) -> Result<(), AnyError>; fn write_file(&self, file_path: &Path, bytes: &[u8]) -> Result<(), AnyError>; - fn path_exists(&self, path: &Path) -> bool; } pub struct RealVendorEnvironment; impl VendorEnvironment for RealVendorEnvironment { - fn cwd(&self) -> Result { - Ok(std::env::current_dir()?) - } - fn create_dir_all(&self, dir_path: &Path) -> Result<(), AnyError> { Ok(std::fs::create_dir_all(dir_path)?) } @@ -55,10 +48,6 @@ impl VendorEnvironment for RealVendorEnvironment { std::fs::write(file_path, bytes) .with_context(|| format!("Failed writing {}", file_path.display())) } - - fn path_exists(&self, path: &Path) -> bool { - path.exists() - } } type BuildGraphFuture = LocalBoxFuture<'static, Result>; diff --git a/cli/tools/vendor/test.rs b/cli/tools/vendor/test.rs index c5e98c05e4..d54bf5dc5a 100644 --- a/cli/tools/vendor/test.rs +++ b/cli/tools/vendor/test.rs @@ -144,10 +144,6 @@ struct TestVendorEnvironment { } impl VendorEnvironment for TestVendorEnvironment { - fn cwd(&self) -> Result { - Ok(make_path("/")) - } - fn create_dir_all(&self, dir_path: &Path) -> Result<(), AnyError> { let mut directories = self.directories.borrow_mut(); for path in dir_path.ancestors() { @@ -169,10 +165,6 @@ impl VendorEnvironment for TestVendorEnvironment { ); Ok(()) } - - fn path_exists(&self, path: &Path) -> bool { - self.files.borrow().contains_key(&path.to_path_buf()) - } } pub struct VendorOutput { diff --git a/cli/util/fs.rs b/cli/util/fs.rs index ba55eb89dd..92820ebe87 100644 --- a/cli/util/fs.rs +++ b/cli/util/fs.rs @@ -676,7 +676,9 @@ impl Drop for LaxSingleProcessFsFlagInner { /// This should only be used in places where it's ideal for multiple /// processes to not update something on the file system at the same time, /// but it's not that big of a deal. -pub struct LaxSingleProcessFsFlag(Option); +pub struct LaxSingleProcessFsFlag( + #[allow(dead_code)] Option, +); impl LaxSingleProcessFsFlag { pub async fn lock(file_path: PathBuf, long_wait_message: &str) -> Self { @@ -688,6 +690,7 @@ impl LaxSingleProcessFsFlag { .read(true) .write(true) .create(true) + .truncate(false) .open(&file_path); match open_result { diff --git a/cli/worker.rs b/cli/worker.rs index be5a85cd6f..ed82f48720 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -72,12 +72,6 @@ pub trait ModuleLoaderFactory: Send + Sync { fn create_source_map_getter(&self) -> Option>; } -// todo(dsherret): this is temporary and we should remove this -// once we no longer conditionally initialize the node runtime -pub trait HasNodeSpecifierChecker: Send + Sync { - fn has_node_specifier(&self) -> bool; -} - #[async_trait::async_trait(?Send)] pub trait HmrRunner: Send + Sync { async fn start(&mut self) -> Result<(), AnyError>; diff --git a/ext/ffi/callback.rs b/ext/ffi/callback.rs index 556d215251..eeea49c239 100644 --- a/ext/ffi/callback.rs +++ b/ext/ffi/callback.rs @@ -34,7 +34,7 @@ use std::task::Poll; static THREAD_ID_COUNTER: AtomicU32 = AtomicU32::new(1); thread_local! { - static LOCAL_THREAD_ID: RefCell = RefCell::new(0); + static LOCAL_THREAD_ID: RefCell = const { RefCell::new(0) }; } #[derive(Clone)] diff --git a/ext/ffi/dlfcn.rs b/ext/ffi/dlfcn.rs index ad287b9d0c..bd46f14b23 100644 --- a/ext/ffi/dlfcn.rs +++ b/ext/ffi/dlfcn.rs @@ -101,7 +101,7 @@ struct ForeignStatic { #[derive(Debug)] enum ForeignSymbol { ForeignFunction(ForeignFunction), - ForeignStatic(ForeignStatic), + ForeignStatic(#[allow(dead_code)] ForeignStatic), } impl<'de> Deserialize<'de> for ForeignSymbol { diff --git a/ext/http/http_next.rs b/ext/http/http_next.rs index 99d602fcc8..a6527397f7 100644 --- a/ext/http/http_next.rs +++ b/ext/http/http_next.rs @@ -20,6 +20,7 @@ use crate::websocket_upgrade::WebSocketUpgrade; use crate::LocalExecutor; use cache_control::CacheControl; use deno_core::error::AnyError; +use deno_core::external; use deno_core::futures::future::poll_fn; use deno_core::futures::TryFutureExt; use deno_core::op2; @@ -130,30 +131,6 @@ impl< #[repr(transparent)] struct RcHttpRecord(Rc); -// Temp copy -/// Define an external type. -macro_rules! external { - ($type:ident, $name:literal) => { - impl deno_core::Externalizable for $type { - fn external_marker() -> usize { - // Use the address of a static mut as a way to get around lack of usize-sized TypeId. Because it is mutable, the - // compiler cannot collapse multiple definitions into one. - static mut DEFINITION: deno_core::ExternalDefinition = - deno_core::ExternalDefinition::new($name); - // Wash the pointer through black_box so the compiler cannot see what we're going to do with it and needs - // to assume it will be used for valid purposes. - // SAFETY: temporary while waiting on deno core bump - let ptr = std::hint::black_box(unsafe { &mut DEFINITION } as *mut _); - ptr as usize - } - - fn external_name() -> &'static str { - $name - } - } - }; -} - // Register the [`HttpRecord`] as an external. external!(RcHttpRecord, "http record"); diff --git a/ext/http/service.rs b/ext/http/service.rs index 654da25b3d..932575e37c 100644 --- a/ext/http/service.rs +++ b/ext/http/service.rs @@ -150,7 +150,7 @@ impl std::ops::Deref for HttpServerState { enum RequestBodyState { Incoming(Incoming), - Resource(HttpRequestBodyAutocloser), + Resource(#[allow(dead_code)] HttpRequestBodyAutocloser), } impl From for RequestBodyState { diff --git a/ext/napi/lib.rs b/ext/napi/lib.rs index 5205978918..b3313f0fec 100644 --- a/ext/napi/lib.rs +++ b/ext/napi/lib.rs @@ -79,7 +79,7 @@ pub const napi_would_deadlock: napi_status = 21; pub const NAPI_AUTO_LENGTH: usize = usize::MAX; thread_local! { - pub static MODULE_TO_REGISTER: RefCell> = RefCell::new(None); + pub static MODULE_TO_REGISTER: RefCell> = const { RefCell::new(None) }; } type napi_addon_register_func = diff --git a/ext/node/ops/vm_internal.rs b/ext/node/ops/vm_internal.rs index 274fac91a4..b4bef5adb2 100644 --- a/ext/node/ops/vm_internal.rs +++ b/ext/node/ops/vm_internal.rs @@ -155,9 +155,7 @@ impl ContextifyContext { scope: &mut v8::HandleScope<'a>, object: v8::Local<'a, v8::Object>, ) -> Option<&'c ContextifyContext> { - let Some(context) = object.get_creation_context(scope) else { - return None; - }; + let context = object.get_creation_context(scope)?; let context_ptr = context.get_aligned_pointer_from_embedder_data(0); // SAFETY: We are storing a pointer to the ContextifyContext diff --git a/ext/web/stream_resource.rs b/ext/web/stream_resource.rs index 9a46b6d478..b96ac36bc5 100644 --- a/ext/web/stream_resource.rs +++ b/ext/web/stream_resource.rs @@ -594,7 +594,7 @@ mod tests { static V8_GLOBAL: OnceLock<()> = OnceLock::new(); thread_local! { - static ISOLATE: OnceCell> = OnceCell::new(); + static ISOLATE: OnceCell> = const { OnceCell::new() }; } fn with_isolate(mut f: impl FnMut(&mut v8::Isolate) -> T) -> T { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a436857e58..27610ca75a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.76.0" +channel = "1.77.2" components = ["rustfmt", "clippy"] diff --git a/tests/napi/src/promise.rs b/tests/napi/src/promise.rs index 82cd7a1606..1f1c31f1eb 100644 --- a/tests/napi/src/promise.rs +++ b/tests/napi/src/promise.rs @@ -5,6 +5,7 @@ use crate::napi_get_callback_info; use crate::napi_new_property; use napi_sys::*; use std::ptr; +use std::ptr::addr_of_mut; static mut CURRENT_DEFERRED: napi_deferred = ptr::null_mut(); @@ -13,7 +14,11 @@ extern "C" fn test_promise_new( _info: napi_callback_info, ) -> napi_value { let mut value: napi_value = ptr::null_mut(); - assert_napi_ok!(napi_create_promise(env, &mut CURRENT_DEFERRED, &mut value)); + assert_napi_ok!(napi_create_promise( + env, + addr_of_mut!(CURRENT_DEFERRED), + &mut value + )); value }