diff --git a/ffi/moq/ffi.toml b/ffi/moq/ffi.toml index 81c88ac0e..3ad8a54b0 100644 --- a/ffi/moq/ffi.toml +++ b/ffi/moq/ffi.toml @@ -36,7 +36,6 @@ exclude = [ "group::Consumer::read_frames", "group::Producer::write_frames", "origin::Requesting", - "origin::Routing", "server::Handshake", "stats::Snapshot::control", "stats::Snapshot::sessions", @@ -123,6 +122,7 @@ exclude = [ "cli::Answer::exit", "cli::Deprecated::changed", "cli::Deprecated::flag", + "cli::Deprecated::removed", "cli::Deprecated::toml", "cli::FileSource", "cli::Merge", @@ -140,69 +140,69 @@ exclude = [ "panic::isolate", "panic::message", "quic::Error", - "quic::Limits", - "quic::LimitsError", - "quic::driver::AckFrequencyConfig", "quic::driver::ApplicationClose", - "quic::driver::AsyncUdpSocket", "quic::driver::Chunk", - "quic::driver::ClientConfig", "quic::driver::ClosedStream", "quic::driver::ConfigError", - "quic::driver::ConnectError", - "quic::driver::Connecting", - "quic::driver::Connection::accept_bi", - "quic::driver::Connection::accept_uni", - "quic::driver::Connection::close", - "quic::driver::Connection::close_reason", - "quic::driver::Connection::closed", - "quic::driver::Connection::congestion_state", - "quic::driver::Connection::handshake_data", - "quic::driver::Connection::open_bi", - "quic::driver::Connection::open_uni", - "quic::driver::Connection::peer_identity", - "quic::driver::Connection::read_datagram", - "quic::driver::Connection::send_datagram", - "quic::driver::Connection::set_limits", - "quic::driver::Connection::stats", "quic::driver::ConnectionClose", - "quic::driver::ConnectionError", "quic::driver::ConnectionId", "quic::driver::ConnectionIdGenerator", - "quic::driver::ConnectionStats", + "quic::driver::CreditStats", "quic::driver::Dir", "quic::driver::EcnCodepoint", - "quic::driver::Endpoint", - "quic::driver::EndpointConfig", "quic::driver::FrameStats", "quic::driver::FrameType", - "quic::driver::IdleTimeout", - "quic::driver::Incoming", "quic::driver::InvalidCid", "quic::driver::Lease", - "quic::driver::MtuDiscoveryConfig", + "quic::driver::Limits", + "quic::driver::LimitsError", "quic::driver::PathStats", "quic::driver::ReadError", "quic::driver::ReadExactError", "quic::driver::ReadToEndError", "quic::driver::RecvStream", "quic::driver::ResetError", - "quic::driver::SendDatagramError", "quic::driver::SendStream", - "quic::driver::ServerConfig", "quic::driver::StoppedError", "quic::driver::StreamId", "quic::driver::Transmit", - "quic::driver::TransportConfig", "quic::driver::TransportErrorCode", - "quic::driver::UdpSender", "quic::driver::UdpStats", - "quic::driver::ValidationTokenConfig", "quic::driver::VarInt", "quic::driver::VarIntBoundsExceeded", + "quic::driver::Version", "quic::driver::WriteError", "quic::driver::Written", + "quic::driver::client", + "quic::driver::connection::Connecting", + "quic::driver::connection::Connection::accept_bi", + "quic::driver::connection::Connection::accept_uni", + "quic::driver::connection::Connection::close", + "quic::driver::connection::Connection::close_reason", + "quic::driver::connection::Connection::closed", + "quic::driver::connection::Connection::congestion_state", + "quic::driver::connection::Connection::handshake_data", + "quic::driver::connection::Connection::open_bi", + "quic::driver::connection::Connection::open_uni", + "quic::driver::connection::Connection::peer_identity", + "quic::driver::connection::Connection::read_datagram", + "quic::driver::connection::Connection::send_datagram", + "quic::driver::connection::Connection::set_limits", + "quic::driver::connection::Connection::stats", + "quic::driver::connection::Error", + "quic::driver::connection::SendDatagramError", + "quic::driver::connection::Stats", "quic::driver::crypto", + "quic::driver::endpoint::AsyncUdpSocket", + "quic::driver::endpoint::CidGenerator", + "quic::driver::endpoint::Config", + "quic::driver::endpoint::ConnectError", + "quic::driver::endpoint::Endpoint", + "quic::driver::endpoint::Error", + "quic::driver::endpoint::Incoming", + "quic::driver::endpoint::Socket", + "quic::driver::server", + "quic::driver::transport", "rustls", "secret::Secret::as_bytes", "server::Config::websocket", @@ -222,8 +222,7 @@ exclude = [ "transport::RecvStream", "transport::SendStream", "transport::Session", - "unix::Listener::accept", - "unix::Listener::with_protocols", + "unix::Error", "watch::Files", "websocket::Error", "websocket::Listener", @@ -253,7 +252,7 @@ exclude = [ [crates.hang] exclude = [ "Catalog::from_reader", - "catalog::Archive::timelines", + "Catalog::subscribe", "catalog::Audio::enabled", "catalog::Audio::ranked", "catalog::Audio::renditions", @@ -285,8 +284,6 @@ exclude = [ "health::publisher", "health::viewer", "stats::Snapshot", - "timeline::Record", - "timeline::RecordExt", ] [crates.hang.rename] @@ -309,10 +306,6 @@ exclude = [ "Source::resolve_reference", "Source::stats", "Source::subscribe_track", - "binary::Consumer::latest", - "binary::Consumer::next", - "binary::Consumer::poll_latest", - "binary::Consumer::poll_next", "catalog::Entry", "catalog::Guard", "catalog::IntoRendition", @@ -379,8 +372,6 @@ exclude = [ "json::Consumer", "json::Snapshot", "json::Stream", - "timeline::Entry", - "timeline::Producer::push", ] [crates.moq-mux.rename] @@ -404,6 +395,7 @@ exclude = [ # The waiter a driver's poll registers, which C makes from its waker and holds across polls. [crates.kio] exclude = [ + "Bridge", "Closed", "Consumer", "ConsumerWeak", diff --git a/ffi/moq/moq.c b/ffi/moq/moq.c index 5a050409d..8824e86d5 100644 --- a/ffi/moq/moq.c +++ b/ffi/moq/moq.c @@ -36,21 +36,6 @@ static int is(moq_buf buf, const char *s) { return same; } -/* The catalog `mutate` lends for its call, which lists the binary track: counts it in - * data. */ -static void lists_state(void *data, moq_hang_catalog_extra *catalog) { - moq_buf json; - moq_hang_error *hang_err = NULL; - CHECK(moq_hang_catalog_extra_to_json(catalog, &json, &hang_err)); - for (size_t i = 0; i + 5 <= json.len; i++) { - if (memcmp(json.ptr + i, "state", 5) == 0) { - (*(int *)data)++; - break; - } - } - moq_buf_free(json); -} - /* Moves the stats track in data into the lent catalog, in place. */ static void sets_stats(void *data, moq_hang_catalog_extra *catalog) { moq_hang_catalog_extra_set_stats(catalog, data); @@ -212,20 +197,21 @@ int main(void) { /* Paths own their segments, so C builds them, and relative ones, from a string. */ moq_path *cam = NULL; - moq_path_too_long *too_long = NULL; - CHECK(moq_path_new(str("/cam/"), &cam, &too_long)); + moq_path_invalid path_invalid; + CHECK(!moq_path_new(str("/cam/"), &cam, &path_invalid) && path_invalid == MOQ_PATH_INVALID_EMPTY_SEGMENT); + CHECK(moq_path_new(str("cam"), &cam, &path_invalid)); CHECK(is(moq_path_as_str(cam), "cam")); moq_path *joined = NULL; - CHECK(moq_path_join(path, cam, &joined, &too_long)); + CHECK(moq_path_join(path, cam, &joined, &path_invalid)); CHECK(is(moq_path_as_str(joined), "room/alice/cam")); moq_path *stripped = moq_path_strip_prefix(joined, path); CHECK(stripped != NULL && moq_path_eq(stripped, cam)); moq_path_free(stripped); CHECK(moq_path_strip_prefix(path, joined) == NULL); moq_relative *up = NULL; - CHECK(moq_relative_new(str("../bob"), &up, &too_long)); + CHECK(moq_relative_new(str("../bob"), &up, &path_invalid)); moq_path *resolved = NULL; - CHECK(moq_path_resolve(joined, up, &resolved, &too_long)); + CHECK(moq_path_resolve(joined, up, &resolved, &path_invalid)); CHECK(is(moq_path_as_str(resolved), "room/bob")); moq_path_free(resolved); moq_relative_free(up); @@ -290,9 +276,9 @@ int main(void) { moq_mux_error_free(mux_err); mux_err = NULL; - /* A binary track the catalog lists, published through moq-mux's generic - * `binary_snapshot` at the config C builds, by a catalog at moq-mux's untyped - * extension, each instance named by the last segment of each argument. */ + /* A catalog at moq-mux's untyped extension, from the config C builds, whose generic + * `is_claimed` is named by the last segment of its argument, and whose `mutate` lends + * the catalog to C, which sets its fields in place. */ moq_broadcast_info *listed = moq_broadcast_info_new(); moq_broadcast_producer *publisher = moq_broadcast_info_produce(listed); moq_broadcast_info_free(listed); @@ -304,18 +290,7 @@ int main(void) { moq_catalog_producer_extra *catalog = NULL; CHECK(moq_catalog_producer_extra_new(publisher, extra, &catalog, &mux_err)); moq_catalog_config_extra_free(extra); - moq_track_producer *state = NULL; - CHECK(moq_broadcast_producer_create_track(publisher, str("state"), NULL, &state, &err)); - moq_binary_config *binary = moq_binary_config_default(); - moq_binary_snapshot *snapshot = NULL; - CHECK(moq_catalog_producer_extra_binary_snapshot_config(catalog, state, binary, &snapshot, &mux_err)); - moq_binary_config_free(binary); - moq_track_producer_free(state); - CHECK(is(moq_binary_snapshot_name(snapshot), "state")); - CHECK(moq_binary_snapshot_update(snapshot, str("latest"), &mux_err)); - int listed_state = 0; - CHECK(moq_catalog_producer_extra_mutate(catalog, lists_state, &listed_state, &mux_err)); - CHECK(listed_state == 1); + CHECK(!moq_catalog_producer_extra_is_claimed_binary_config(catalog, str("state"))); /* A field of the lent catalog, set in place: the next call reads it. */ moq_catalog_stats *stats = moq_catalog_stats_new(str("stats")); CHECK(moq_catalog_producer_extra_mutate(catalog, sets_stats, stats, &mux_err)); @@ -323,10 +298,21 @@ int main(void) { int listed_stats = 0; CHECK(moq_catalog_producer_extra_mutate(catalog, lists_stats, &listed_stats, &mux_err)); CHECK(listed_stats == 1); - moq_binary_snapshot_free(snapshot); moq_catalog_producer_extra_free(catalog); moq_broadcast_producer_free(publisher); + /* Outside any tokio runtime, as C is, moq-tokio runs on the fallback it starts. */ + moq_origin_producer *spawned = moq_origin_spawn(); + moq_origin_producer_free(spawned); + moq_connect_config *client_config = moq_connect_config_default(); + moq_quic_config *quic = moq_quic_config_default(); + moq_tokio_client *tokio_client = NULL; + moq_tokio_error *tokio_err = NULL; + CHECK(moq_connect_config_init(client_config, quic, &tokio_client, &tokio_err)); + moq_connect_config_free(client_config); + moq_quic_config_free(quic); + moq_tokio_client_free(tokio_client); + /* moq-tokio's terminal connect errors, which moq-net's `Error` shares no names with. */ moq_connect_error unauthorized = MOQ_CONNECT_ERROR_UNAUTHORIZED; CHECK(moq_connect_error_is_auth(&unauthorized)); diff --git a/ffi/moq/moq.cpp b/ffi/moq/moq.cpp index 5b34f1336..f72ca8df6 100644 --- a/ffi/moq/moq.cpp +++ b/ffi/moq/moq.cpp @@ -125,7 +125,9 @@ int main() { CHECK(is(path.as_str(), "room/alice")); // Paths own their segments, so C++ builds them, and relative ones, from a string. - auto cam = moq::path::new_("/cam/"); + auto empty = moq::path::new_("/cam/"); + CHECK(!empty && empty.error() == moq::path_invalid::empty_segment); + auto cam = moq::path::new_("cam"); CHECK(cam && is(cam->as_str(), "cam")); auto joined = path.join(*cam); CHECK(joined && is(joined->as_str(), "room/alice/cam")); @@ -172,29 +174,25 @@ int main() { auto truncated = moq::codec_opus_audio_config(moq::view(head, 8)); CHECK(!truncated && !truncated.error().to_string().empty()); - // A binary track the catalog lists, published through moq-mux's generic - // `binary_snapshot` at the config C++ builds, by a catalog at moq-mux's untyped - // extension, each instance named by the last segment of each argument. + // A catalog at moq-mux's untyped extension, from the config C++ builds, whose generic + // `is_claimed` is named by the last segment of its argument, and whose `mutate` lends + // the catalog to C++. { moq::broadcast_producer publisher = moq::broadcast_info::new_().produce(); moq::catalog_config_extra extra = moq::catalog_config::default_().with_catalog_extra(moq::hang_catalog_extra::default_()); auto catalog = moq::catalog_producer_extra::new_(publisher, std::move(extra)); CHECK(catalog); - auto state = publisher.create_track("state", std::nullopt); - CHECK(state); - auto snapshot = catalog->binary_snapshot_config(std::move(*state), moq::binary_config::default_()); - CHECK(snapshot && is(snapshot->name(), "state")); - CHECK(snapshot->update("latest")); - int listed_state = 0; + CHECK(!catalog->is_claimed_binary_config("state")); + int read_catalog = 0; CHECK(catalog->mutate([&](moq::hang_catalog_extra &lent) { auto json = lent.to_json(); CHECK(json); - if (json && json.value().str().find("state") != std::string_view::npos) { - listed_state++; + if (json && json.value().str().substr(0, 1) == "{") { + read_catalog++; } })); - CHECK(listed_state == 1); + CHECK(read_catalog == 1); } // A session's config, filled in as Rust assigns it, and a nested field by getting a copy, diff --git a/ffi/moq/moq.kt b/ffi/moq/moq.kt index d89677c22..1481bc709 100644 --- a/ffi/moq/moq.kt +++ b/ffi/moq/moq.kt @@ -131,8 +131,14 @@ fun main() { expect(path.asStr() == "room/alice", "a broadcast has its path") // Paths own their segments, so Kotlin builds them, and relative ones, from a string. - val cam = Path.new("/cam/") - expect(cam.asStr() == "cam", "a path trims its slashes") + try { + Path.new("/cam/") + expect(false, "a path with an empty segment is an error") + } catch (e: PathInvalidException) { + expect(e.error == PathInvalid.EMPTY_SEGMENT, "an empty segment is its own error") + } + val cam = Path.new("cam") + expect(cam.asStr() == "cam", "a path builds from its segments") val joined = path.join(cam) expect(joined.asStr() == "room/alice/cam", "paths join") expect(joined.stripPrefix(path) == cam, "a path strips its prefix") @@ -176,20 +182,18 @@ fun main() { expect(e.message.isNotEmpty(), "a truncated head's error has a message") } - // A binary track the catalog lists, published through moq-mux's generic - // `binary_snapshot` at the config Kotlin builds, by a catalog at moq-mux's untyped - // extension, each instance named by the last segment of each argument. + // A catalog at moq-mux's untyped extension, from the config Kotlin builds, whose generic + // `is_claimed` is named by the last segment of its argument, and whose `mutate` lends + // the catalog to Kotlin. val publisher = BroadcastInfo.new().produce() val extra = CatalogConfig.default().withCatalogExtra(HangCatalogExtra.default()) val catalog = CatalogProducerExtra.new(publisher, extra) - val snapshot = catalog.binarySnapshotConfig(publisher.createTrack("state", null), BinaryConfig.default()) - expect(snapshot.name() == "state", "a snapshot has its track's name") - snapshot.update("latest") - var listed = 0 + expect(!catalog.isClaimedBinaryConfig("state"), "an unclaimed name is not claimed") + var read = 0 catalog.mutate { lent -> - if (lent.toJson().contains("state")) listed++ + if (lent.toJson().startsWith("{")) read++ } - expect(listed == 1, "the catalog lists the snapshot's track") + expect(read == 1, "mutate lends the catalog once") // moq-tokio's terminal connect errors, which moq-net's `Error` shares no names with. expect(ConnectError.UNAUTHORIZED.isAuth(), "unauthorized is an auth error") diff --git a/quest/m1/README.md b/quest/m1/README.md index 46d63dd19..f442f6c3a 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -16,7 +16,6 @@ are folded into the [exporter's](/quest/m1/ffi-export/README.md). The ## Required -- [Bump the moq pin past the fallback runtime](/quest/m1/moq-pin.md) - `ts` and `ffi` build against moq with moq-tokio's fallback runtime - [Waiting: publish the UniFFI fork](/quest/m1/uniffi-release.md) - the fork publishes to crates.io under `rust2-*` names, once the maintainer decides it should - [Exporter](/quest/m1/ffi-export/README.md) - moq's bindings exported from its crates' `pub` API, replacing the fork - [Land main through quest land](/quest/m1/land.md) - every queued PR lands as one tested batch through the shared gate diff --git a/quest/m1/ffi-export/README.md b/quest/m1/ffi-export/README.md index 03078d369..620d9fd33 100644 --- a/quest/m1/ffi-export/README.md +++ b/quest/m1/ffi-export/README.md @@ -52,6 +52,7 @@ Every generator on the C ABI: - [moq-clock's C names once it moves into kio](/quest/m1/ffi-export/crates.md) - `moq_now` and `moq_origin` become the clock's, after moq moves it into `kio::clock` - [Sessions on moq-tokio](/quest/m1/ffi-export/session-tokio.md) - bindings connect and accept with one call, the library running moq-tokio inside - [Sessions on sans-IO QUIC](/quest/m1/ffi-export/session-quic.md) - bindings move UDP datagrams and drive the session's poll themselves +- [Glue that builds without warnings](/quest/m1/ffi-export/warnings.md) - the exporter's Rust glue builds with `-D warnings` - [The recursion depth lint on moq's export](/quest/m1/ffi-export/recursion-lint.md) - `just ffi moq` builds clean before the lint becomes an error - [C++ bindings on MSVC and Clang](/quest/m1/ffi-export/cpp.md) - the C++ header built and tested beyond GCC on Linux - [Kotlin bindings: zero-copy payloads and the read path](/quest/m1/ffi-export/kotlin.md) - the Kotlin lends bytes without a copy, and reads at JNI's cost diff --git a/quest/m1/ffi-export/session-tokio.md b/quest/m1/ffi-export/session-tokio.md index aaf51276a..753cb4b22 100644 --- a/quest/m1/ffi-export/session-tokio.md +++ b/quest/m1/ffi-export/session-tokio.md @@ -30,11 +30,6 @@ use unless the caller supplies one. Each entry point and future that needs tokio the caller's `Handle::try_current()`, else in that process-wide runtime. C gets no new names, a Rust caller inside tokio sees no change, and one outside gets a runtime instead of `NoRuntime`. It landed in [moq-dev/moq#7123](https://github.com/moq-dev/moq/pull/7123); -the pin bump brings it here. +rust2's moq pin includes it. Public API: the C names moq's bindings get. - -## Required - -- [Bump the moq pin past the fallback runtime](/quest/m1/moq-pin.md) - C reaches moq-tokio's fallback runtime - diff --git a/quest/m1/ffi-export/warnings.md b/quest/m1/ffi-export/warnings.md new file mode 100644 index 000000000..1009e7cda --- /dev/null +++ b/quest/m1/ffi-export/warnings.md @@ -0,0 +1,14 @@ +# [S] Glue that builds without warnings + +## Goal + +The Rust glue the exporter writes builds without warnings, and `just ffi test` builds the +api fixture's glue with `-D warnings` so a new one fails. + +## Plan + +Found on 2026-10-28 bumping the moq pin: a callback that returns `()`, as +`moq_mux::catalog::Producer::mutate` takes, emits `let result = ...; ()`, which warns +`unused variable: result` three times in moq's glue. `lift` of `Type::Unit` in +`ffi/src/glue.rs` drops its expression; passing it through as `e` fixes the closure and the +callback vtable alike. The api fixture has no unit-returning closure yet; add one. diff --git a/quest/m1/moq-pin.md b/quest/m1/moq-pin.md deleted file mode 100644 index 60c089cc6..000000000 --- a/quest/m1/moq-pin.md +++ /dev/null @@ -1,20 +0,0 @@ -# [M] Bump the moq pin past the fallback runtime - -## Goal - -`moq_rev`, the moq revision `ts` and `ffi` both build against, moves to moq's `main` at -[moq-dev/moq#7123](https://github.com/moq-dev/moq/pull/7123)'s merge, so moq-tokio's fallback -runtime reaches the C ABI. `just ffi moq`, `just ts moq`, `just ts census`, `just check`, -and `just test` pass at the new pin. - -## Plan - -Found on 2026-10-28 against moq's `main`, about 85 commits past the pin: `ffi/moq/ffi.toml` -fails with 17 errors, excludes that name nothing anymore and new items the exporter refuses, -and `just ts census` ICEs on a trait object of an associated type over a type parameter. - -- The excludes are config the translators take, so keep them to what the export refuses; - a refusal that needs a translator change rather than an exclude is a decision to report. -- Report the census before and after for `ts` and `ffi`. -- From C, `moq_origin_spawn` and `moq_connect_config_init` succeed at the new pin; at the - old one the first aborts. Add that to `moq/moq.c`. diff --git a/ts/fixtures/reject/census.md b/ts/fixtures/reject/census.md index cf9a2c6fc..07afe5b58 100644 --- a/ts/fixtures/reject/census.md +++ b/ts/fixtures/reject/census.md @@ -1,8 +1,8 @@ # Census of `reject-fixture` - Refusals: 82 -- Function instances: 92 -- Generic functions no instance reached, lowered over their type parameters: 6 +- Function instances: 93 +- Generic functions no instance reached, lowered over their type parameters: 7 ## By construct diff --git a/ts/fixtures/reject/src/lib.rs b/ts/fixtures/reject/src/lib.rs index 5fe8352ce..e77c5c397 100644 --- a/ts/fixtures/reject/src/lib.rs +++ b/ts/fixtures/reject/src/lib.rs @@ -559,3 +559,15 @@ pub fn any_upcast(k: &dyn Keyed) -> bool { pub fn any_type_id(a: &dyn std::any::Any) -> bool { a.type_id() == std::any::TypeId::of::() } + +pub trait Source { + type Item: Reading; + fn item(&self) -> &Self::Item; +} + +/// A trait object of a type only an instance decides, which a census lowering this over +/// its type parameter can't make. +pub fn source_reading(s: &S) -> u8 { + let r: &dyn Reading = s.item(); + r.read() +} diff --git a/ts/justfile b/ts/justfile index b0a714a30..76b087b14 100644 --- a/ts/justfile +++ b/ts/justfile @@ -9,7 +9,7 @@ set shell := ["bash", "-euo", "pipefail", "-c"] export PATH := if env("RUST2_TS_TOOLCHAIN", "") == "" { env("PATH") } else { env("RUST2_TS_TOOLCHAIN") / "bin:" + env("PATH") } # The moq revision `moq` translates by default. -moq_rev := "c764acebb90b5c102a8ea90207dd125ae4fd326b" +moq_rev := "30f25c04e6d0288d87893dc609ba582518be2cf6" default: @just --list diff --git a/ts/src/lower/dynamic.rs b/ts/src/lower/dynamic.rs index 6b1e0d8e1..d89808ade 100644 --- a/ts/src/lower/dynamic.rs +++ b/ts/src/lower/dynamic.rs @@ -8,7 +8,7 @@ //! methods, and a downcast checks for the class of the type it names. use rustc_hir::def_id::DefId; -use rustc_middle::ty::{self, GenericArgsRef, Instance, Interner as _, Ty, TyCtxt}; +use rustc_middle::ty::{self, GenericArgsRef, Instance, Interner as _, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::Span; use super::Translator; @@ -379,6 +379,11 @@ impl<'tcx> Body<'_, '_, 'tcx> { } return value; } + // A census over type parameters can't make the class: only an instance decides + // what the pointee is. + if self.t.polymorphic() && pointee.has_param() { + return Expr::undefined(); + } let held = match from.kind() { ty::Ref(_, _, ty::Mutability::Mut) if self.t.needs_place(pointee) => Held::Place, ty::Ref(..) => Held::Value,