Skip to content

Commit bec250b

Browse files
committed
Merge remote-tracking branch 'origin/master' into maizatskyi/2025-06-09-async-io-stream
2 parents 57b060f + 76940e9 commit bec250b

File tree

16 files changed

+67
-46
lines changed

16 files changed

+67
-46
lines changed

.bazelrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ build:windows --copt='/Zc:dllexportInlines-' --host_copt='/Zc:dllexportInlines-'
2929

3030
build:clippy --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
3131
build:clippy --output_groups=+clippy_checks
32-
build:clippy --@rules_rust//:clippy_flags=-Dclippy::all,-Dclippy::pedantic,-Dwarnings
32+
build:clippy --@rules_rust//:clippy_flags=-Dclippy::all,-Dclippy::pedantic,-Dwarnings
33+
build:clippy --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect
34+
build:clippy --output_groups=+rustfmt_checks
35+
build:clippy --@rules_rust//:extra_rustc_flag=-Dwarnings
3336

3437
## Sanitizers
3538

gen/src/write.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,6 @@ fn write_kj_own(out: &mut OutFile, key: NamedImplKey) {
16481648
let ident = key.rust;
16491649
let resolve = out.types.resolve(ident);
16501650
let inner = resolve.name.to_fully_qualified();
1651-
let instance = resolve.name.to_symbol();
16521651

16531652
out.include.utility = true;
16541653
out.include.kj_rs = true;

kj-rs/awaiter.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<Data: std::marker::Unpin> PromiseAwaiter<Data> {
4747
let node = this.node.take();
4848

4949
// Safety: `awaiter` stores `rust_waker_ptr` and uses it to call `wake()`. Note that
50-
// `awaiter` is `this.awaiter`, which lives before `this.option_waker`.
50+
// `awaiter` is `this.awaiter`, which lives before `this.option_waker`.
5151
// Since we drop awaiter manually, the `rust_waker_ptr` that `awaiter` stores will always
5252
// be valid during its lifetime.
5353
//
@@ -59,7 +59,9 @@ impl<Data: std::marker::Unpin> PromiseAwaiter<Data> {
5959
// Safety: The memory slot is valid and this type ensures that it will stay pinned.
6060
unsafe {
6161
crate::ffi::guarded_rust_promise_awaiter_new_in_place(
62-
this.awaiter.as_mut_ptr().cast::<GuardedRustPromiseAwaiter>(),
62+
this.awaiter
63+
.as_mut_ptr()
64+
.cast::<GuardedRustPromiseAwaiter>(),
6365
rust_waker_ptr,
6466
node.expect("node should be Some in call to init()"),
6567
);
@@ -88,7 +90,9 @@ impl<Data: std::marker::Unpin> Drop for PromiseAwaiter<Data> {
8890
if self.awaiter_initialized {
8991
unsafe {
9092
crate::ffi::guarded_rust_promise_awaiter_drop_in_place(
91-
self.awaiter.as_mut_ptr().cast::<GuardedRustPromiseAwaiter>()
93+
self.awaiter
94+
.as_mut_ptr()
95+
.cast::<GuardedRustPromiseAwaiter>(),
9296
);
9397
}
9498
}

kj-rs/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ pub use promise::new_callbacks_promise_future;
1212

1313
mod awaiter;
1414
mod future;
15+
mod own;
1516
mod promise;
1617
mod waker;
17-
mod own;
1818

1919
pub mod repr {
2020
pub use crate::future::repr::*;

kj-rs/own.c++

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern "C" {
55
// This works because disposers work by virtual call, and the disposer is created during creation of
66
// the Own, so the type of the Own at destruction doesn't actually matter for Owns that do not use a
77
// static disposer, which are not currently supported by workerd-cxx.
8-
void cxxbridge$kjrs$own$drop(void *own) {
9-
reinterpret_cast<kj::Own<void> *>(own)->~Own();
8+
void cxxbridge$kjrs$own$drop(void* own) {
9+
reinterpret_cast<kj::Own<void>*>(own)->~Own();
1010
}
1111
}

kj-rs/own.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
#include <kj/memory.h>
44

55
extern "C" {
6-
void cxxbridge$kjrs$own$drop(void* own);
6+
void cxxbridge$kjrs$own$drop(void* own);
77
}

kj-rs/tests/BUILD.bazel

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ platform(
1313
)
1414

1515
rust_library(
16-
name = "awaitables-rust",
16+
name = "tests",
1717
srcs = glob(["*.rs"]),
1818
edition = "2024",
1919
deps = [
@@ -29,13 +29,13 @@ rust_unpretty(
2929
name = "expand-rust_test",
3030
testonly = True,
3131
deps = [
32-
":awaitables-rust_test"
32+
":rust_tests"
3333
]
3434
)
3535

3636
rust_test(
37-
name = "awaitables-rust_test",
38-
crate = "awaitables-rust",
37+
name = "rust_tests",
38+
crate = "tests",
3939
deps = [
4040
":test-promises",
4141
],
@@ -81,7 +81,7 @@ cc_test(
8181
"//conditions:default": False,
8282
}),
8383
deps = [
84-
":awaitables-rust",
84+
":tests",
8585
":bridge",
8686
":test-promises",
8787
"//third-party:runtime",

kj-rs/tests/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,26 @@ mod ffi {
5353
#[cxx_name = "setData"]
5454
fn set_data(self: Pin<&mut OpaqueCxxClass>, val: u64);
5555

56+
#[allow(dead_code)]
5657
fn cxx_kj_own() -> Own<OpaqueCxxClass>;
5758
fn null_kj_own() -> Own<OpaqueCxxClass>;
59+
#[allow(dead_code)]
5860
fn give_own_back(own: Own<OpaqueCxxClass>);
61+
#[allow(dead_code)]
5962
fn modify_own_return_test();
63+
#[allow(dead_code)]
6064
fn breaking_things() -> Own<OpaqueCxxClass>;
6165

66+
#[allow(dead_code)]
6267
fn own_integer() -> Own<i64>;
68+
#[allow(dead_code)]
6369
fn own_integer_attached() -> Own<i64>;
6470

71+
#[allow(dead_code)]
6572
fn null_exception_test_driver_1() -> String;
73+
#[allow(dead_code)]
6674
fn null_exception_test_driver_2() -> String;
75+
#[allow(dead_code)]
6776
fn rust_take_own_driver();
6877
}
6978

kj-rs/tests/test-own.c++

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#include "test-own.h"
2+
23
#include "kj/string.h"
4+
35
#include <exception>
46

57
namespace kj_rs_demo {
68

7-
kj::Own<OpaqueCxxClass> cxx_kj_own() {
8-
return kj::heap<OpaqueCxxClass>(42);
9+
kj::Own<OpaqueCxxClass> cxx_kj_own() {
10+
return kj::heap<OpaqueCxxClass>(42);
911
}
1012

11-
kj::Own<OpaqueCxxClass> null_kj_own() {
12-
return kj::Own<OpaqueCxxClass>();
13+
kj::Own<OpaqueCxxClass> null_kj_own() {
14+
return kj::Own<OpaqueCxxClass>();
1315
}
1416

1517
void give_own_back(kj::Own<OpaqueCxxClass> own) {
@@ -42,19 +44,19 @@ kj::Own<int64_t> own_integer_attached() {
4244

4345
rust::string null_exception_test_driver_1() {
4446
try {
45-
auto _ = modify_own_return(null_kj_own());
46-
return rust::string("");
47-
} catch (const std::exception &e) {
48-
return rust::string(e.what());
47+
auto _ = modify_own_return(null_kj_own());
48+
return rust::string("");
49+
} catch (const std::exception& e) {
50+
return rust::string(e.what());
4951
}
5052
}
5153

5254
rust::string null_exception_test_driver_2() {
5355
try {
54-
auto _ = get_null();
55-
return rust::string("");
56-
} catch (const std::exception &e) {
57-
return rust::string(e.what());
56+
auto _ = get_null();
57+
return rust::string("");
58+
} catch (const std::exception& e) {
59+
return rust::string(e.what());
5860
}
5961
}
6062

@@ -63,4 +65,4 @@ void rust_take_own_driver() {
6365
take_own(kj::mv(own));
6466
}
6567

66-
} // namespace kj_rs_demo
68+
} // namespace kj_rs_demo

kj-rs/tests/test-own.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
#pragma once
22

33
#include "kj/memory.h"
4-
#include <cstdint>
5-
#include <kj/debug.h>
4+
65
#include <rust/cxx.h>
6+
7+
#include <kj/debug.h>
8+
79
#include <cstdint>
810

911
namespace kj_rs_demo {
1012

1113
class OpaqueCxxClass {
12-
public:
13-
OpaqueCxxClass(uint64_t data) : data(data) {}
14+
public:
15+
OpaqueCxxClass(uint64_t data): data(data) {}
1416
~OpaqueCxxClass() {}
15-
uint64_t getData() const { return this->data; }
16-
void setData(uint64_t val) { this->data = val; }
17-
18-
private:
17+
uint64_t getData() const {
18+
return this->data;
19+
}
20+
void setData(uint64_t val) {
21+
this->data = val;
22+
}
23+
24+
private:
1925
uint64_t data;
2026
};
2127

@@ -41,4 +47,4 @@ kj::Own<OpaqueCxxClass> breaking_things();
4147
kj::Own<int64_t> own_integer();
4248
kj::Own<int64_t> own_integer_attached();
4349

44-
} // namespace kj_rs_demo
50+
} // namespace kj_rs_demo

0 commit comments

Comments
 (0)