diff --git a/.github/workflows/ci.generate.ts b/.github/workflows/ci.generate.ts index 6a4e3744a8c6e0..6371c0880277b3 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 = 73; +const cacheVersion = 74; const ubuntuX86Runner = "ubuntu-24.04"; const ubuntuX86XlRunner = "ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04"; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30afb3f82ae354..95fe482c1ada9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,8 +188,8 @@ jobs: ~/.cargo/registry/index ~/.cargo/registry/cache ~/.cargo/git/db - key: '73-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles(''Cargo.lock'') }}' - restore-keys: '73-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-' + key: '74-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles(''Cargo.lock'') }}' + restore-keys: '74-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-' if: '!(matrix.skip)' - uses: dsherret/rust-toolchain-file@v1 if: '!(matrix.skip)' @@ -391,7 +391,7 @@ jobs: !./target/*/*.zip !./target/*/*.tar.gz key: never_saved - restore-keys: '73-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-' + restore-keys: '74-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 @@ -772,7 +772,7 @@ jobs: !./target/*/gn_root !./target/*/*.zip !./target/*/*.tar.gz - key: '73-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' + key: '74-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' libs: name: build libs needs: diff --git a/Cargo.lock b/Cargo.lock index 8eade0c0dbcc83..126f8e59c32409 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5760,9 +5760,9 @@ dependencies = [ [[package]] name = "libffi" -version = "4.0.0" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9434b6fc77375fb624698d5f8c49d7e80b10d59eb1219afda27d1f824d4074" +checksum = "b0feebbe0ccd382a2790f78d380540500d7b78ed7a3498b68fcfbc1593749a94" dependencies = [ "libc", "libffi-sys", @@ -5770,9 +5770,9 @@ dependencies = [ [[package]] name = "libffi-sys" -version = "3.2.0" +version = "3.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ead36a2496acfc8edd6cc32352110e9478ac5b9b5f5b9856ebd3d28019addb84" +checksum = "90c6c6e17136d4bc439d43a2f3c6ccf0731cccc016d897473a29791d3c2160c3" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index 10fe34b89235fc..d011bec5149e4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -372,8 +372,8 @@ x509-parser = "0.15.0" cranelift = "0.116" cranelift-native = "0.116" dlopen2 = "0.6.1" -libffi = "=4.0.0" -libffi-sys = "=3.2.0" +libffi = "=4.1.2" +libffi-sys = "=3.3.3" memmap2 = "0.9" # napi diff --git a/cli/cdp.rs b/cli/cdp.rs index 6f7a2d5a7c4fc9..faa64b02ab1782 100644 --- a/cli/cdp.rs +++ b/cli/cdp.rs @@ -355,12 +355,15 @@ pub struct ScriptCoverage { /// #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] +#[allow(dead_code)] pub struct StartPreciseCoverageArgs { pub call_count: bool, pub detailed: bool, pub allow_triggered_updates: bool, } +// TODO(bartlomieju): in Rust 1.90 some structs started getting flagged as not used +#[allow(dead_code)] /// #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -371,6 +374,7 @@ pub struct StartPreciseCoverageResponse { /// #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] +#[allow(dead_code)] pub struct TakePreciseCoverageResponse { pub result: Vec, pub timestamp: f64, diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 7e095a88158dfe..2a4d8a3b84468d 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -2167,6 +2167,8 @@ impl DocumentSpan { } } +// TODO(bartlomieju): in Rust 1.90 some structs started getting flagged as not used +#[allow(dead_code)] #[derive(Debug, Clone, Deserialize)] pub enum MatchKind { #[serde(rename = "exact")] diff --git a/cli/tools/bundle/mod.rs b/cli/tools/bundle/mod.rs index fa3f6f9c85a318..0a0c925b81c456 100644 --- a/cli/tools/bundle/mod.rs +++ b/cli/tools/bundle/mod.rs @@ -801,6 +801,8 @@ impl DenoPluginHandler { } } +// TODO(bartlomieju): in Rust 1.90 some structs started getting flagged as not used +#[allow(dead_code)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "kebab-case")] enum PluginImportKind { @@ -831,6 +833,8 @@ impl From for PluginImportKind { } } +// TODO(bartlomieju): in Rust 1.90 some structs started getting flagged as not used +#[allow(dead_code)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] struct PluginOnResolveArgs { @@ -842,6 +846,8 @@ struct PluginOnResolveArgs { with: IndexMap, } +// TODO(bartlomieju): in Rust 1.90 some structs started getting flagged as not used +#[allow(dead_code)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] struct PluginOnLoadArgs { diff --git a/cli/tools/test/mod.rs b/cli/tools/test/mod.rs index 7f698331312d72..e3b1011ba2cfe7 100644 --- a/cli/tools/test/mod.rs +++ b/cli/tools/test/mod.rs @@ -493,6 +493,8 @@ pub struct TestPlan { pub used_only: bool, } +// TODO(bartlomieju): in Rust 1.90 some structs started getting flagged as not used +#[allow(dead_code)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Deserialize)] pub enum TestStdioStream { Stdout, diff --git a/cli/tools/test/reporters/dot.rs b/cli/tools/test/reporters/dot.rs index 5e8ed2766adc56..07eb672c7c3e79 100644 --- a/cli/tools/test/reporters/dot.rs +++ b/cli/tools/test/reporters/dot.rs @@ -41,7 +41,7 @@ impl DotTestReporter { return; } - if self.n != 0 && self.n % self.width == 0 { + if self.n != 0 && self.n.is_multiple_of(self.width) { println!(); } self.n += 1; diff --git a/ext/crypto/generate_key.rs b/ext/crypto/generate_key.rs index 26c3f0622ad1d3..4001c638857b39 100644 --- a/ext/crypto/generate_key.rs +++ b/ext/crypto/generate_key.rs @@ -137,7 +137,7 @@ fn generate_key_ec( } fn generate_key_aes(length: usize) -> Result, GenerateKeyError> { - if length % 8 != 0 || length > 256 { + if !length.is_multiple_of(8) || length > 256 { return Err(GenerateKeyError::InvalidAESKeyLength); } diff --git a/ext/crypto/key.rs b/ext/crypto/key.rs index f629de830261fd..3b85aecd7e8d2d 100644 --- a/ext/crypto/key.rs +++ b/ext/crypto/key.rs @@ -9,14 +9,6 @@ use aws_lc_rs::signature::EcdsaVerificationAlgorithm; use serde::Deserialize; use serde::Serialize; -#[derive(Serialize, Deserialize, Copy, Clone)] -#[serde(rename_all = "camelCase")] -pub enum KeyType { - Public, - Private, - Secret, -} - #[derive(Serialize, Deserialize, Copy, Clone, Eq, PartialEq)] pub enum CryptoHash { #[serde(rename = "SHA-1")] @@ -98,19 +90,6 @@ impl hkdf::KeyType for HkdfOutput { } } -#[derive(Serialize, Deserialize, Copy, Clone, Debug, Eq, PartialEq)] -#[serde(rename_all = "camelCase")] -pub enum KeyUsage { - Encrypt, - Decrypt, - Sign, - Verify, - DeriveKey, - DeriveBits, - WrapKey, - UnwrapKey, -} - #[derive(Serialize, Deserialize, Clone, Copy)] pub enum Algorithm { #[serde(rename = "RSASSA-PKCS1-v1_5")] diff --git a/ext/crypto/lib.rs b/ext/crypto/lib.rs index 3512ee224c58ed..fb5dbe4e05cc3b 100644 --- a/ext/crypto/lib.rs +++ b/ext/crypto/lib.rs @@ -595,7 +595,7 @@ pub async fn op_crypto_derive_bits( let salt = &*zero_copy; // The caller must validate these cases. assert!(args.length > 0); - assert!(args.length % 8 == 0); + assert!(args.length.is_multiple_of(8)); let algorithm = match args.hash.ok_or_else(JsErrorBox::not_supported)? { CryptoHash::Sha1 => pbkdf2::PBKDF2_HMAC_SHA1, @@ -791,7 +791,7 @@ pub fn op_crypto_wrap_key( Algorithm::AesKw => { let key = args.key.as_secret_key()?; - if data.len() % 8 != 0 { + if !data.len().is_multiple_of(8) { return Err(CryptoError::DataInvalidSize); } @@ -820,7 +820,7 @@ pub fn op_crypto_unwrap_key( Algorithm::AesKw => { let key = args.key.as_secret_key()?; - if data.len() % 8 != 0 { + if !data.len().is_multiple_of(8) { return Err(CryptoError::DataInvalidSize); } diff --git a/ext/net/tunnel.rs b/ext/net/tunnel.rs index f432f690ee18e6..fea48b99d0edcd 100644 --- a/ext/net/tunnel.rs +++ b/ext/net/tunnel.rs @@ -169,6 +169,7 @@ impl Resource for TunnelStreamResource { } } +#[allow(dead_code)] #[derive(Debug, serde::Serialize, serde::Deserialize)] enum StreamHeader { Control { @@ -183,6 +184,7 @@ enum StreamHeader { Agent {}, } +#[allow(dead_code)] #[derive(Debug, serde::Serialize, serde::Deserialize)] enum ControlMessage { Authenticated { diff --git a/ext/node/ops/crypto/cipher.rs b/ext/node/ops/crypto/cipher.rs index 040f6df0d7bdad..4342335c4b56e3 100644 --- a/ext/node/ops/crypto/cipher.rs +++ b/ext/node/ops/crypto/cipher.rs @@ -292,25 +292,25 @@ impl Cipher { use Cipher::*; match self { Aes128Cbc(encryptor) => { - assert!(input.len() % 16 == 0); + assert!(input.len().is_multiple_of(16)); for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) { encryptor.encrypt_block_b2b_mut(input.into(), output.into()); } } Aes128Ecb(encryptor) => { - assert!(input.len() % 16 == 0); + assert!(input.len().is_multiple_of(16)); for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) { encryptor.encrypt_block_b2b_mut(input.into(), output.into()); } } Aes192Ecb(encryptor) => { - assert!(input.len() % 16 == 0); + assert!(input.len().is_multiple_of(16)); for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) { encryptor.encrypt_block_b2b_mut(input.into(), output.into()); } } Aes256Ecb(encryptor) => { - assert!(input.len() % 16 == 0); + assert!(input.len().is_multiple_of(16)); for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) { encryptor.encrypt_block_b2b_mut(input.into(), output.into()); } @@ -324,7 +324,7 @@ impl Cipher { cipher.encrypt(output); } Aes256Cbc(encryptor) => { - assert!(input.len() % 16 == 0); + assert!(input.len().is_multiple_of(16)); for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) { encryptor.encrypt_block_b2b_mut(input.into(), output.into()); } @@ -631,25 +631,25 @@ impl Decipher { use Decipher::*; match self { Aes128Cbc(decryptor) => { - assert!(input.len() % 16 == 0); + assert!(input.len().is_multiple_of(16)); for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) { decryptor.decrypt_block_b2b_mut(input.into(), output.into()); } } Aes128Ecb(decryptor) => { - assert!(input.len() % 16 == 0); + assert!(input.len().is_multiple_of(16)); for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) { decryptor.decrypt_block_b2b_mut(input.into(), output.into()); } } Aes192Ecb(decryptor) => { - assert!(input.len() % 16 == 0); + assert!(input.len().is_multiple_of(16)); for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) { decryptor.decrypt_block_b2b_mut(input.into(), output.into()); } } Aes256Ecb(decryptor) => { - assert!(input.len() % 16 == 0); + assert!(input.len().is_multiple_of(16)); for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) { decryptor.decrypt_block_b2b_mut(input.into(), output.into()); } @@ -663,7 +663,7 @@ impl Decipher { decipher.decrypt(output); } Aes256Cbc(decryptor) => { - assert!(input.len() % 16 == 0); + assert!(input.len().is_multiple_of(16)); for (input, output) in input.chunks(16).zip(output.chunks_mut(16)) { decryptor.decrypt_block_b2b_mut(input.into(), output.into()); } diff --git a/ext/node/ops/zlib/mod.rs b/ext/node/ops/zlib/mod.rs index c8552ffd3533b0..e89006618275ea 100644 --- a/ext/node/ops/zlib/mod.rs +++ b/ext/node/ops/zlib/mod.rs @@ -743,7 +743,7 @@ unsafe impl deno_core::GarbageCollected for BrotliDecoder { fn decoder_param( i: u32, -) -> ffi::decompressor::ffi::interface::BrotliDecoderParameter { +) -> Option { const _: () = { assert!( std::mem::size_of::< @@ -752,8 +752,11 @@ fn decoder_param( == std::mem::size_of::(), ); }; - // SAFETY: `i` is a valid u32 value that corresponds to a BrotliDecoderParameter. - unsafe { std::mem::transmute(i) } + match i { + 0 => Some(ffi::decompressor::ffi::interface::BrotliDecoderParameter::BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION), + 1 => Some(ffi::decompressor::ffi::interface::BrotliDecoderParameter::BROTLI_DECODER_PARAM_LARGE_WINDOW), + _ => None + } } #[op2] @@ -780,11 +783,11 @@ impl BrotliDecoder { std::ptr::null_mut(), ); for (i, &value) in params.iter().enumerate() { - ffi::decompressor::ffi::BrotliDecoderSetParameter( - state, - decoder_param(i as u32), - value, - ); + if let Some(param) = decoder_param(i as u32) { + ffi::decompressor::ffi::BrotliDecoderSetParameter( + state, param, value, + ); + } } state diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 908d2ecba8ca93..43e5784a18b32e 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.89.0" +channel = "1.90.0" components = ["rustfmt", "clippy"] diff --git a/tests/specs/compile/ffi/__test__.jsonc b/tests/specs/compile/ffi/__test__.jsonc index 1794fa13e2e03f..ad8b13ecf3737a 100644 --- a/tests/specs/compile/ffi/__test__.jsonc +++ b/tests/specs/compile/ffi/__test__.jsonc @@ -9,6 +9,6 @@ }, { "commandName": "./out", "args": [], - "output": "5\n" + "output": "something\n" }] } diff --git a/tests/specs/compile/ffi/main.ts b/tests/specs/compile/ffi/main.ts index 4ebdf4113ca375..0cdfcb18fdcd27 100644 --- a/tests/specs/compile/ffi/main.ts +++ b/tests/specs/compile/ffi/main.ts @@ -8,36 +8,11 @@ const libPath = `${import.meta.dirname}/${libPrefix}test_ffi.${libSuffix}`; const dylib = Deno.dlopen( libPath, { - store_function_2: { - parameters: ["function"], - result: "void", - }, - call_stored_function_2: { - parameters: ["u8"], - result: "void", - }, - call_stored_function_2_from_other_thread: { - name: "call_stored_function_2", - parameters: ["u8"], - result: "void", - nonblocking: true, - }, - call_stored_function_2_thread_safe: { - parameters: ["u8"], + print_something: { + parameters: [], result: "void", }, } as const, ); -const callback = (): number => { - return 5; -}; - -const CB_DEFINITION = { - parameters: [], - result: "u8", -} as const; - -const cb = new Deno.UnsafeCallback(CB_DEFINITION, callback); -const fnPointer = new Deno.UnsafeFnPointer(cb.pointer, CB_DEFINITION); -console.log(fnPointer.call()); +dylib.symbols.print_something();