Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a9cf738
chore(quest): claim quest/m1/ffi-refusals/stale-excludes.md
kixelated Nov 13, 2026
0c3e41c
fix(ffi): exclude only what moq's export refuses, checked by the census
kixelated Nov 13, 2026
929c8dc
fix(ffi): match stale excludes by the exporter's own keys, in the census
kixelated Nov 13, 2026
77e0b40
fix(ffi): audit no module, and match field@ and every left-out list
kixelated Nov 13, 2026
aa23d03
style(ffi): format the census test
kixelated Nov 13, 2026
f92a5a1
style(ffi): format with the repo's formatter
kixelated Nov 13, 2026
53bfde4
fix(ffi): census flags an exclude by what the export holds, not by in…
kixelated Nov 13, 2026
a3d3cca
test(ffi): a refused method beside an exporting field of its name
kixelated Nov 13, 2026
7f378b0
style(ffi): drop a needless mut, format
kixelated Nov 13, 2026
d5deba2
fix(ffi): the census itself fails on an exclude that leaves out what …
kixelated Nov 13, 2026
017ee20
fix(ffi): record an audited path under every exclude that names it
kixelated Nov 13, 2026
e1464ab
style(ffi): format the census test
kixelated Nov 13, 2026
899ea0f
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Nov 13, 2026
d90f223
Merge remote-tracking branch 'origin/main' into quest/m1/ffi-refusals…
kixelated Nov 13, 2026
970efca
fix(ffi): census takes an exclude Swift's refusal requires
kixelated Nov 13, 2026
3b25162
style(ffi): format
kixelated Nov 13, 2026
f42d566
fix(ffi): match Swift refusals by shown path, not span
kixelated Nov 13, 2026
999f51c
fix(ffi): drop the unused Span import
kixelated Nov 13, 2026
72b2d33
style(ffi): format
kixelated Nov 13, 2026
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
6 changes: 4 additions & 2 deletions ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -921,8 +921,10 @@ runtime package and each crate's include [`runtime/rt.go`](runtime/rt.go) and
`--census dir` exports nothing. It writes `<package>.md` for the facade, which counts what exports and ranks every refusal by construct and by the type it names,
lists each refused item at its span, then the `exclude` list that exports the rest, and
what else it left out, such as what C can never hold and the traits C cannot implement, and why.
It ignores the config's `exclude`. It still fails on an `instance not inferred`
refusal, which is a bug in the exporter's inference rather than in the crate.
It ignores the config's `exclude`, but lists each exclude that leaves out an item that
would export, and fails on it, so the list holds only what the export refuses. It also
fails on an `instance not inferred` refusal, which is a bug in the exporter's inference
rather than in the crate.

## Tests

Expand Down
9 changes: 7 additions & 2 deletions ffi/fixtures/api/ffi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
# `Rooted`, `Copied`, `Stored`, and `Layer` only convert, so their parameters take what
# converts into them, and
# `field@` leaves out a field alone where a method takes its path, as `Retry`'s and
# `Slot<u8>`'s do. `Slot<u32>` has no such method, so its path alone names its field. A
# function instance is left out by its path, as `depth_past` at `polar::Point` is.
# `Slot<u8>`'s do, and `Retry::jitter` and `field@Retry::jitter` leave out a refused method
# and its field. `Slot<u32>` has no such method, so its path alone names its field. A
# function instance is left out by its path, as `depth_past` at `polar::Point` is. Swift
# refuses `among`, so the census takes its exclude.
exclude = [
"among",
"Copied",
"Layer",
"Node::next",
Expand All @@ -15,7 +18,9 @@ exclude = [
"Sample",
"Scoped",
"Slot<u32>::value",
"Retry::jitter",
"field@Retry::delay",
"field@Retry::jitter",
"field@Slot<u8>::value",
"Stack::depth_past<api::polar::Point>",
"Stored",
Expand Down
19 changes: 18 additions & 1 deletion ffi/fixtures/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,11 +1296,18 @@ pub fn next_packet(packet: Packet) -> Packet {
pub struct Retry {
pub limit: Option<u32>,
pub delay: Option<u32>,
/// Its field exports, but the method of its name is refused, so the config excludes
/// both, and the census lists only `field@Retry::jitter` as excluding what exports.
pub jitter: u32,
}

impl Retry {
pub fn new(limit: Option<u32>) -> Self {
Self { limit, delay: None }
Self {
limit,
delay: None,
jitter: 0,
}
}

pub fn limit(&self) -> u32 {
Expand All @@ -1314,6 +1321,11 @@ impl Retry {
pub fn set_limit(&mut self, limit: u32) {
self.limit = Some(limit);
}

/// The jitter capped by `cap`, if any: a nested `Option`, which the export refuses.
pub fn jitter(&self, cap: Option<Box<Option<u32>>>) -> u32 {
cap.and_then(|cap| *cap).map_or(self.jitter, |cap| self.jitter.min(cap))
}
}

/// A digest, as moq's FLAC config holds its MD5: an object, whose array field C reads and
Expand Down Expand Up @@ -2740,3 +2752,8 @@ pub fn next_hop(hop: Option<NonZero<u64>>) -> Option<NonZero<u64>> {
pub fn farther_hop(hops: Pair<NonZero<u16>>) -> Box<NonZero<u16>> {
Box::new(hops.left.max(hops.right))
}

/// Three optional borrowed counters, past what Swift takes, so the config leaves it out.
pub fn among(first: Option<&Counter>, second: Option<&Counter>, third: Option<&Counter>) -> u64 {
[first, second, third].into_iter().flatten().map(|c| c.value).sum()
}
2 changes: 1 addition & 1 deletion ffi/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fix:
run *args:
cargo run --locked --quiet -- {{ args }}

# Census the stand-in facade moq/ffi.toml exports into target/census/moq-ffi.md, from the pinned moq revision or a checkout.
# Census the stand-in facade moq/ffi.toml exports into target/census/moq-ffi.md, from the pinned moq revision or a checkout, failing when moq/ffi.toml excludes an item that exports.
census checkout="": (standin checkout)
cargo run --locked --quiet -- --config moq/ffi.toml --manifest-path target/moq-ffi/Cargo.toml --census target/census

Expand Down
52 changes: 12 additions & 40 deletions ffi/moq/ffi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,52 @@
# still has to cover. `kio` is moq-net's re-export of all of kio, of which moq-ffi ships
# only what the facade re-exports.
exclude = [
"bytes",
"Client::connect<moq::transport::memory::Session>",
"bytes",
"clock::Deadlines::enter",
"clock::Entered",
"clock::rng",
"clock::Rng",
"clock::rng",
"frame::Buffer::drain",
"frame::Producer::group",
"group::Consumer::poll_read_frames",
"hang::container::Frame::encode",
"hang::moq_net",
"kio",
"mux::catalog::Guard",
"mux::catalog::Producer::modify",
"mux::catalog::Producer<moq::mux::catalog::hang::Extra>::modify",
"mux::catalog::Producer<moq::mux::container::ts::Ext>::modify",
"mux::codec::aac::Config::parse",
"mux::codec::annexb::from_length_prefixed",
"mux::codec::annexb::length_prefixed_to_annexb",
"mux::codec::opus::Config::parse",
"mux::container::fmp4::mp4_atom",
"mux::container::fmp4::Wire::new",
"mux::container::fmp4::Wire::trak",
"mux::container::Producer<moq::mux::catalog::hang::Container>::modify",
"mux::container::Producer<moq::mux::catalog::hang::Container, moq::hang::catalog::AudioConfig>::modify",
"mux::container::Producer<moq::mux::catalog::hang::Container, moq::hang::catalog::BinaryConfig>::modify",
"mux::container::Producer<moq::mux::catalog::hang::Container, moq::hang::catalog::JsonConfig>::modify",
"mux::container::Producer<moq::mux::catalog::hang::Container, moq::hang::catalog::TextConfig>::modify",
"mux::container::Producer<moq::mux::catalog::hang::Container, moq::hang::catalog::VideoConfig>::modify",
"mux::container::Producer<moq::mux::catalog::hang::Container>::set",
"mux::container::Producer<moq::mux::container::fmp4::Wire>::modify",
"mux::container::Producer<moq::mux::catalog::hang::Container>::modify",
"mux::container::Producer<moq::mux::container::fmp4::Wire, moq::hang::catalog::AudioConfig>::modify",
"mux::container::Producer<moq::mux::container::fmp4::Wire, moq::hang::catalog::BinaryConfig>::modify",
"mux::container::Producer<moq::mux::container::fmp4::Wire, moq::hang::catalog::JsonConfig>::modify",
"mux::container::Producer<moq::mux::container::fmp4::Wire, moq::hang::catalog::TextConfig>::modify",
"mux::container::Producer<moq::mux::container::fmp4::Wire, moq::hang::catalog::VideoConfig>::modify",
"mux::container::Producer<moq::mux::container::fmp4::Wire>::set",
"mux::container::Producer<moq::mux::container::legacy::Wire>::modify",
"mux::container::Producer<moq::mux::container::fmp4::Wire>::modify",
"mux::container::Producer<moq::mux::container::legacy::Wire, moq::hang::catalog::AudioConfig>::modify",
"mux::container::Producer<moq::mux::container::legacy::Wire, moq::hang::catalog::BinaryConfig>::modify",
"mux::container::Producer<moq::mux::container::legacy::Wire, moq::hang::catalog::JsonConfig>::modify",
"mux::container::Producer<moq::mux::container::legacy::Wire, moq::hang::catalog::TextConfig>::modify",
"mux::container::Producer<moq::mux::container::legacy::Wire, moq::hang::catalog::VideoConfig>::modify",
"mux::container::Producer<moq::mux::container::legacy::Wire>::set",
"mux::container::Producer<moq::mux::container::loc::Wire>::modify",
"mux::container::Producer<moq::mux::container::legacy::Wire>::modify",
"mux::container::Producer<moq::mux::container::loc::Wire, moq::hang::catalog::AudioConfig>::modify",
"mux::container::Producer<moq::mux::container::loc::Wire, moq::hang::catalog::BinaryConfig>::modify",
"mux::container::Producer<moq::mux::container::loc::Wire, moq::hang::catalog::JsonConfig>::modify",
"mux::container::Producer<moq::mux::container::loc::Wire, moq::hang::catalog::TextConfig>::modify",
"mux::container::Producer<moq::mux::container::loc::Wire, moq::hang::catalog::VideoConfig>::modify",
"mux::container::Producer<moq::mux::container::loc::Wire>::set",
"mux::container::ts::Follower::export",
"mux::container::ts::Follower<moq::mux::catalog::hang::Extra>::export",
"mux::container::ts::Follower<moq::mux::container::ts::Ext>::export",
"mux::Source::bind",
"mux::Source::resolve",
"mux::Source::resolve_reference",
"mux::Source::subscribe_track",
"Path::from_static",
"Timestamp::as_micros",
"Timestamp::as_millis",
"Timestamp::as_nanos",
"Timestamp::as_scale",
"mux::container::Producer<moq::mux::container::loc::Wire>::modify",
"mux::container::fmp4::Wire::new",
"mux::container::fmp4::Wire::trak",
"mux::container::fmp4::mp4_atom",
"tokio::Server::accept_health",
"tokio::Server::tls_acceptor",
"tokio::connect::Config::deprecated",
"tokio::connect::Config::goaway",
"tokio::connect::Config::resolve",
"tokio::connect::Config::websocket",
"tokio::connection::Monitor::poll_presence",
"tokio::connection::Monitor::snapshot",
"tokio::connection::Monitor::state",
"tokio::connection::Monitor::state_changed",
Expand All @@ -84,23 +62,17 @@ exclude = [
"tokio::quic::Config::controller",
"tokio::quic::Config::deprecated",
"tokio::quic::Config::resolve",
"tokio::Server::accept_health",
"tokio::server::Config::demux",
"tokio::server::Config::websocket",
"tokio::server::Listener::accept_health",
"tokio::server::Request::quic",
"tokio::server::Request::within",
"tokio::server::Request::with_quic_limits",
"tokio::Server::tls_acceptor",
"tokio::server::Request::within",
"tokio::tls::Connect::build",
"tokio::tls::Connect::deprecated",
"tokio::tls::Listen::deprecated",
"tokio::tls::Listen::load_roots",
"tokio::tls::Listen::server_config",
"tokio::tls::PeerIdentity::chain",
"tokio::tls::PeerIdentity::from_chain",
"tokio::tls::Serve::config",
"tokio::tls::Serve::resolver",
"transport::poll::Ungrouped",
"varint::encode_quic",
]
2 changes: 1 addition & 1 deletion ffi/moq/moq.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ final class Queue: TaskExecutor, @unchecked Sendable {
}

func launch(_ body: @escaping @Sendable () async throws -> Void) {
Task(executorPreference: self, operation: body)
_ = Task(executorPreference: self, operation: body)
}
}

Expand Down
17 changes: 15 additions & 2 deletions ffi/src/census.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ use crate::abi::Clash;
use crate::collect::{Refusal, Report};
use crate::ir::{Access, Api, Function};

/// The census of the facade as Markdown; `at` locates a span.
pub fn render(api: &Api, collected: &Report, clashes: &[Clash], at: &dyn Fn(Span) -> String) -> String {
/// The census of the facade as Markdown, listing `exporting`, each exclude whose item
/// would export and its paths; `at` locates a span.
pub fn render(
api: &Api,
collected: &Report,
exporting: &[(String, Vec<String>)],
clashes: &[Clash],
at: &dyn Fn(Span) -> String,
) -> String {
let records = &api.records;
let enums = &api.enums;
let objects: Vec<_> = api.objects.iter().filter(|o| !o.foreign).collect();
Expand Down Expand Up @@ -184,6 +191,12 @@ pub fn render(api: &Api, collected: &Report, clashes: &[Clash], at: &dyn Fn(Span
let _ = writeln!(out, "- `{path}`: {count} items");
}
}
if !exporting.is_empty() {
let _ = writeln!(out, "\n## Excluded by the config, though it exports\n");
for (exclude, exported) in exporting {
let _ = writeln!(out, "- `{exclude}`: `{}`", exported.join("`, `"));
}
}
if !collected.hidden.is_empty() {
let _ = writeln!(out, "\n## `#[doc(hidden)]`, left out\n");
for path in &collected.hidden {
Expand Down
17 changes: 15 additions & 2 deletions ffi/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ pub struct Facade<'a> {
pub package: &'a str,
/// Paths from its root the config leaves out.
pub exclude: &'a [String],
/// Paths from its root a census checks, without leaving out what they name: each
/// path one names is recorded in [`Report::audited`], as the exclude would have checked it.
pub audit: &'a [String],
}

/// What collection found in the facade, by paths from its root.
Expand All @@ -165,6 +168,8 @@ pub struct Report {
pub unheld: Vec<(String, Why)>,
/// Excluded paths, and how many items each left out.
pub excluded: Vec<(String, usize)>,
/// A census's audited paths, and each path one names, whether or not that item exports.
pub audited: Vec<(String, Vec<String>)>,
/// Type aliases, which export nothing of their own.
pub aliases: Vec<String>,
}
Expand Down Expand Up @@ -352,6 +357,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected {
hidden: Vec::new(),
unheld: Vec::new(),
excluded: facade.exclude.iter().map(|path| (path.clone(), 0)).collect(),
audited: facade.audit.iter().map(|path| (path.clone(), Vec::new())).collect(),
aliases: Vec::new(),
},
instances: Vec::new(),
Expand Down Expand Up @@ -578,8 +584,9 @@ impl<'tcx> Collector<'tcx> {
self.crates.contains(&krate)
}

/// Whether the config excludes `path`, counting the exclusion. A member of an instance
/// is left out by its instance's path or its type's, which leaves it out of each.
/// Whether the config excludes `path`, counting the exclusion, or else recording it under
/// each audited path that names it. A member of an instance is left out by its instance's
/// path or its type's, which leaves it out of each.
fn exclude(&mut self, path: &[String]) -> bool {
let report = &mut self.report;
for (_, key) in config::keys(&path[1..]) {
Expand All @@ -588,6 +595,12 @@ impl<'tcx> Collector<'tcx> {
return true;
}
}
// Under every key that names it, so one census lists a broad exclude beside a narrow one.
for (_, key) in config::keys(&path[1..]) {
if let Some((_, named)) = report.audited.iter_mut().find(|(audited, _)| *audited == key) {
named.push(path[1..].join("::"));
}
}
false
}

Expand Down
Loading