Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions cli/cdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,15 @@ pub struct ScriptCoverage {
/// <https://chromedevtools.github.io/devtools-protocol/tot/Profiler/#method-startPreciseCoverage>
#[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)]
/// <https://chromedevtools.github.io/devtools-protocol/tot/Profiler/#method-startPreciseCoverage>
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand All @@ -371,6 +374,7 @@ pub struct StartPreciseCoverageResponse {
/// <https://chromedevtools.github.io/devtools-protocol/tot/Profiler/#method-takePreciseCoverage>
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(dead_code)]
pub struct TakePreciseCoverageResponse {
pub result: Vec<ScriptCoverage>,
pub timestamp: f64,
Expand Down
2 changes: 2 additions & 0 deletions cli/lsp/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
6 changes: 6 additions & 0 deletions cli/tools/bundle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -831,6 +833,8 @@ impl From<protocol::ImportKind> 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 {
Expand All @@ -842,6 +846,8 @@ struct PluginOnResolveArgs {
with: IndexMap<String, String>,
}

// 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 {
Expand Down
2 changes: 2 additions & 0 deletions cli/tools/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion cli/tools/test/reporters/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ext/crypto/generate_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn generate_key_ec(
}

fn generate_key_aes(length: usize) -> Result<Vec<u8>, GenerateKeyError> {
if length % 8 != 0 || length > 256 {
if !length.is_multiple_of(8) || length > 256 {
return Err(GenerateKeyError::InvalidAESKeyLength);
}

Expand Down
21 changes: 0 additions & 21 deletions ext/crypto/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -98,19 +90,6 @@ impl hkdf::KeyType for HkdfOutput<usize> {
}
}

#[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")]
Expand Down
6 changes: 3 additions & 3 deletions ext/crypto/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!


let algorithm = match args.hash.ok_or_else(JsErrorBox::not_supported)? {
CryptoHash::Sha1 => pbkdf2::PBKDF2_HMAC_SHA1,
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions ext/net/tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ impl Resource for TunnelStreamResource {
}
}

#[allow(dead_code)]
#[derive(Debug, serde::Serialize, serde::Deserialize)]
enum StreamHeader {
Control {
Expand All @@ -183,6 +184,7 @@ enum StreamHeader {
Agent {},
}

#[allow(dead_code)]
#[derive(Debug, serde::Serialize, serde::Deserialize)]
enum ControlMessage {
Authenticated {
Expand Down
20 changes: 10 additions & 10 deletions ext/node/ops/crypto/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand Down Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand Down
19 changes: 11 additions & 8 deletions ext/node/ops/zlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ unsafe impl deno_core::GarbageCollected for BrotliDecoder {

fn decoder_param(
i: u32,
) -> ffi::decompressor::ffi::interface::BrotliDecoderParameter {
) -> Option<ffi::decompressor::ffi::interface::BrotliDecoderParameter> {
const _: () = {
assert!(
std::mem::size_of::<
Expand All @@ -752,8 +752,11 @@ fn decoder_param(
== std::mem::size_of::<u32>(),
);
};
// 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]
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.89.0"
channel = "1.90.0"
components = ["rustfmt", "clippy"]
2 changes: 1 addition & 1 deletion tests/specs/compile/ffi/__test__.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
}, {
"commandName": "./out",
"args": [],
"output": "5\n"
"output": "something\n"
}]
}
31 changes: 3 additions & 28 deletions tests/specs/compile/ffi/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Loading