From bcae45f9b7bb25bbec77d88e3a0e87a9ff8dadd8 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 17:26:49 -0800 Subject: [PATCH 01/10] chore(quest): claim quest/m1/ffi-refusals/no-config.md Quest-Claim: 09fc390c694aaee6 From ab7a2efcfdc46abb0b3285ebb89a32853859ebc5 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 17:46:19 -0800 Subject: [PATCH 02/10] ffi!: export moq's last refusals, and delete the config Co-Authored-By: Claude Opus 5.5 --- ffi/moq/ffi.toml | 3 - ffi/src/census.rs | 44 +++--- ffi/src/cli.rs | 17 +-- ffi/src/collect.rs | 280 ++++++++++++----------------------- ffi/src/config.rs | 39 +---- ffi/src/driver.rs | 353 ++------------------------------------------- ffi/src/glue.rs | 5 +- ffi/src/ir.rs | 6 +- ffi/src/lock.rs | 7 +- ffi/src/merge.rs | 2 - ffi/src/wasm.rs | 2 +- 11 files changed, 145 insertions(+), 613 deletions(-) diff --git a/ffi/moq/ffi.toml b/ffi/moq/ffi.toml index 8d88dd223..c80131259 100644 --- a/ffi/moq/ffi.toml +++ b/ffi/moq/ffi.toml @@ -5,10 +5,7 @@ exclude = [ "escape", "moq_tokio::accept::Failure::classify", "moq_tokio::accept::Health::failed", - "moq_tokio::server::Streams::tcp", - "moq_tokio::server::Streams::unix", "moq_tokio::tcp::TlsAcceptor::accept", - "mux::container::ts::Mpegts::deserialize", "rustls::client::Resumption::store", "rustls::client::danger::DangerousClientConfig::cfg", "tokio::tls::Serve::resolver", diff --git a/ffi/src/census.rs b/ffi/src/census.rs index a8ca436cf..da5d6bf49 100644 --- a/ffi/src/census.rs +++ b/ffi/src/census.rs @@ -10,14 +10,12 @@ use crate::abi::Clash; use crate::collect::{Refusal, Report}; use crate::ir::{Access, Api, Function}; -/// The census of the facade as Markdown, with `config`, the `exclude` that exports what -/// maps, and listing `exporting`, each exclude whose item would export and its paths; `at` -/// locates a span. +/// The census of the facade as Markdown, with `swift`, each function Swift alone refuses +/// and why; `at` locates a span. pub(crate) fn render( api: &Api, collected: &Report, - config: &[String], - exporting: &[(String, Vec)], + swift: &[(&Function, String)], clashes: &[Clash], at: &dyn Fn(Span) -> String, ) -> String { @@ -28,6 +26,9 @@ pub(crate) fn render( let callbacks = api.callbacks.len(); let constants = api.constants.len(); let refused = |kinds: &[&str]| collected.refusals.iter().filter(|r| kinds.contains(&r.kind)).count(); + let swift_functions = (swift.iter()) + .filter(|(f, _)| api.functions.iter().any(|g| std::ptr::eq(*f, g))) + .count(); // A field counts once, by its getter, though it exports a setter too. let items = |methods: &[Function]| { (methods.iter()) @@ -54,11 +55,16 @@ pub(crate) fn render( let _ = writeln!(out, "| {name} | {exported} | {refused} | {share} |"); }; row("Types", types, refused(&["struct", "enum", "union", "instance"])); - row("Functions", functions, refused(&["fn"])); + // Swift's refusals are in the API, so they leave its counts. + row( + "Functions", + functions.saturating_sub(swift_functions), + refused(&["fn"]) + swift_functions, + ); row( "Methods and fields of exported types", - methods, - refused(&["method", "field"]), + methods.saturating_sub(swift.len() - swift_functions), + refused(&["method", "field"]) + swift.len() - swift_functions, ); row("Traits", callbacks, 0); row("Constants", constants, refused(&["const"])); @@ -146,13 +152,11 @@ pub(crate) fn render( ); } - if !config.is_empty() { - let _ = writeln!(out, "\n## The config that exports what maps\n"); - let _ = writeln!(out, "```toml\nexclude = ["); - for path in config { - let _ = writeln!(out, " \"{path}\","); + if !swift.is_empty() { + let _ = writeln!(out, "\n## Refused by Swift\n"); + for (function, why) in swift { + let _ = writeln!(out, "- {why}, at {}", at(function.span)); } - let _ = writeln!(out, "]\n```"); } if !clashes.is_empty() { let _ = writeln!(out, "\n## C names claimed twice\n"); @@ -184,18 +188,6 @@ pub(crate) fn render( let _ = writeln!(out, "- `{path}`"); } } - if !collected.excluded.is_empty() { - let _ = writeln!(out, "\n## Excluded by the config\n"); - for (path, count) in &collected.excluded { - 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 { diff --git a/ffi/src/cli.rs b/ffi/src/cli.rs index 816b721f9..b4177cd91 100644 --- a/ffi/src/cli.rs +++ b/ffi/src/cli.rs @@ -1,4 +1,4 @@ -//! The command line: run cargo on the configured package with this binary as rustc. +//! The command line: run cargo on the package with this binary as rustc. use std::collections::{BTreeMap, BTreeSet}; use std::path::{Path, PathBuf}; @@ -6,15 +6,15 @@ use std::process::{Command, ExitCode}; use rust2_driver::cargo::{Args, Check, Output}; -use crate::config::{self, Config}; +use crate::config; -const USAGE: &str = "usage: rust2-ffi --config (--out | --census | --api ) [--manifest-path ] [--target ]... [--with ]... [--baseline ] [-- ] +const USAGE: &str = "usage: rust2-ffi (--out | --census | --api ) [--manifest-path ] [--target ]... [--with ]... [--baseline ] [-- ] Exports the pub API of the package's library, following its `pub use` re-exports into other crates, as one library: a crate in that builds the C ABI, with its C header -in /include, every C name prefixed by the library's crate name. ffi.toml says what -to leave out. The package's Cargo.toml is beside ffi.toml unless --manifest-path says -where. Cargo args, such as --features, are passed to `cargo check`. +in /include, every C name prefixed by the library's crate name. An item that cannot +export fails the export. The package's Cargo.toml is in the current directory unless +--manifest-path says where. Cargo args, such as --features, are passed to `cargo check`. --target exports the API the package has on that target, the host by default, whatever cargo's config names: its `cfg`s and its layouts. Given several times, it exports each @@ -46,11 +46,9 @@ pub(crate) fn run(args: &[String]) -> ExitCode { fn try_run(args: &[String]) -> Result { let (own, args) = Own::parse(args)?; - let Some(args) = Args::parse(&args, USAGE)? else { + let Some(args) = Args::parse_configless(&args, USAGE)? else { return Ok(ExitCode::SUCCESS); }; - // Read now, so a malformed config fails before the check. - Config::load(&args.config)?; let mut targets = own.targets; if targets.is_empty() { targets.push(rustc_session::config::host_tuple().to_string()); @@ -116,7 +114,6 @@ fn try_run(args: &[String]) -> Result { // The wrapper's answer to cargo's query names the sysroot, which cargo would // otherwise cache by the executables alone. ("CARGO_CACHE_RUSTC_INFO", "0".as_ref()), - (config::env::CONFIG, args.config.as_os_str()), (config::env::PACKAGE, line.as_ref()), (config::env::PATCH, patch.as_ref()), (config::env::CRATES, crates.as_ref()), diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 15505d2d0..bfed7b2b7 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -2,10 +2,10 @@ //! //! Every `pub` item reachable from the facade's root, through its re-exports into other //! crates too, is exported by fixed rules, or refused with its span. A type it does not -//! reach is refused. Nothing is opted in by attribute and nothing is skipped silently: the -//! config's `exclude` is the only way to leave an item out, and `#[doc(hidden)]` items, -//! which are no part of the documented API, what C can never hold, and traits C cannot -//! implement, which C never passes, are listed in the census. A generic type +//! reach is refused. Nothing is opted in by attribute or config and nothing is skipped silently: +//! `#[doc(hidden)]` items, which are no part of the documented API, what C can never hold, +//! and traits C cannot implement, which C never passes, are left out and listed in the +//! census. A generic type //! exports at the instances it infers, before any type is mapped: its defaults, each //! instance an inherent impl is of, its exports' implementations of the traits bounding it, //! and each instance a signature names at any choice its bounds allow; and only there. @@ -28,7 +28,6 @@ use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::traits::ObligationCtxt; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; -use crate::config; use crate::ir::{ Access, Api, Callback, Closure, Collection, Constant, Dyn, Enum, Family, Field, Function, Held, Home, Int, Jni, Literal, Mutability, Object, On, Param, Path, Receiver, Record, Task, TaskKind, Traits, Type, Variant, @@ -154,13 +153,8 @@ pub(crate) struct Facade<'a> { /// The first segment of its items' paths in the IR. pub(crate) root: String, pub(crate) package: &'a str, - /// Paths from its root the config leaves out. - pub(crate) exclude: &'a [String], /// The dependency the glue names each crate it builds with by, by its crate name. pub(crate) crates: &'a std::collections::BTreeMap, - /// 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(crate) audit: &'a [String], } /// What collection found in the facade, by paths from its root. @@ -179,10 +173,6 @@ pub(crate) struct Report { pub(crate) hidden: Vec, /// Items C can never hold or call, by path, and why. pub(crate) unheld: Vec<(String, Why)>, - /// Excluded paths, and how many items each left out. - pub(crate) excluded: Vec<(String, usize)>, - /// A census's audited paths, and each path one names, whether or not that item exports. - pub(crate) audited: Vec<(String, Vec)>, /// Type aliases, which export nothing of their own. pub(crate) aliases: Vec, } @@ -256,7 +246,7 @@ struct Collector<'tcx> { /// How many of `crates` the walk from the root reached, before any reached type's. walked: usize, report: Report, - /// Items the walk left out, and why: `excluded` or `doc(hidden)`. + /// Items the walk left out as `doc(hidden)`. left_out: rustc_data_structures::fx::FxHashMap, /// The type parameters of the function being mapped that take a foreign /// implementation or a lent closure, with the type each takes. @@ -290,6 +280,9 @@ struct Collector<'tcx> { range_bounds: Option, /// Objects no export returns, left out. orphans: rustc_data_structures::fx::FxHashSet>, + /// Another crate's types an opaque handle would hold that [`Self::prune`] dropped, as no + /// export names them, so none returns them either. + pruned: Vec, /// Types a signature names that the root does not reach, each exported by its public /// path in its own crate. reach: Vec, @@ -335,7 +328,7 @@ fn order(tcx: TyCtxt<'_>) -> Vec { order } -/// Collect the facade's API, leaving out what its `exclude` names. +/// Collect the facade's API. pub(crate) fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected { // A type at a crate's root, by the crate's name and its own. let root = |krate: &str, name: &str| { @@ -434,8 +427,6 @@ pub(crate) fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected twins: Vec::new(), 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(), @@ -456,6 +447,7 @@ pub(crate) fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected bound, range_bounds, orphans: orphans.clone(), + pruned: Vec::new(), reach: reach.to_vec(), dependencies: facade.crates.clone(), unreached: Default::default(), @@ -705,26 +697,6 @@ impl<'tcx> Collector<'tcx> { self.crates[..self.walked].contains(&krate) } - /// 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..]) { - if let Some((_, count)) = report.excluded.iter_mut().find(|(excluded, _)| *excluded == key) { - *count += 1; - 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 - } - /// Whether a type or trait takes type or const parameters: a type that does exports /// only at the instances it infers. fn typed(&self, def_id: DefId) -> bool { @@ -1119,13 +1091,12 @@ impl<'tcx> Collector<'tcx> { let mut sites = Vec::new(); for (def_id, path) in self.items.clone() { match tcx.def_kind(def_id) { - DefKind::Fn => named.extend(self.instantiated(def_id, &path, None)), + DefKind::Fn => named.extend(self.instantiated(def_id, None)), DefKind::Const => named.push(tcx.type_of(def_id).instantiate_identity().skip_norm_wip()), DefKind::Trait => { for item in tcx.associated_items(def_id).in_definition_order() { - if let ty::AssocKind::Fn { name, .. } = item.kind { - let method = [&path[..], &[name.to_string()]].concat(); - named.extend(self.instantiated(item.def_id, &method, None)); + if let ty::AssocKind::Fn { .. } = item.kind { + named.extend(self.instantiated(item.def_id, None)); } } } @@ -1142,21 +1113,17 @@ impl<'tcx> Collector<'tcx> { ); for site in sites { let adt = tcx.adt_def(site.key.def_id); - // An object's private fields are no part of its API, nor are those the config - // leaves out. + // An object's private fields are no part of its API. for field in adt.all_fields().filter(|field| field.vis.is_public()) { - let shown = [&site.shown[..], &[field.name.to_string()]].concat(); - if self.field_key(&site, field.name, &shown).is_some() { - named.push(field.ty(tcx, site.args).skip_norm_wip()); - } + named.push(field.ty(tcx, site.args).skip_norm_wip()); } - for (item, parent, shown, hidden) in self.members(&site) { + for (item, parent, _, hidden) in self.members(&site) { match item.kind { _ if hidden => {} ty::AssocKind::Const { .. } => { named.push(tcx.type_of(item.def_id).instantiate(tcx, parent).skip_norm_wip()) } - _ => named.extend(self.instantiated(item.def_id, &shown, Some(parent))), + _ => named.extend(self.instantiated(item.def_id, Some(parent))), } } } @@ -1198,15 +1165,11 @@ impl<'tcx> Collector<'tcx> { }) } - /// The types a function's signature names, bounds included, at each instantiation it - /// is not excluded at. - fn instantiated(&mut self, def_id: DefId, shown: &Path, parent: Option>) -> Vec> { + /// The types a function's signature names, bounds included, at each instantiation. + fn instantiated(&mut self, def_id: DefId, parent: Option>) -> Vec> { let tcx = self.tcx; let mut named = Vec::new(); for instance in self.instantiate(def_id, parent).unwrap_or_default() { - if self.shown(shown, &instance).is_none() { - continue; - } named.extend(self.spelled(def_id, instance.args)); let clauses = tcx.clauses_of(def_id).instantiate(tcx, instance.args).clauses; let mut types = Types(Vec::new()); @@ -1218,9 +1181,8 @@ impl<'tcx> Collector<'tcx> { named } - /// The path reports show an instance of a function by, from its function's `shown`, - /// unless the config excludes it. - fn shown(&mut self, shown: &Path, instance: &Instantiation<'tcx>) -> Option { + /// The path reports show an instance of a function by, from its function's `shown`. + fn shown(&self, shown: &Path, instance: &Instantiation<'tcx>) -> Path { let mut shown = shown.clone(); if !instance.named.is_empty() { let spelled: Vec = (instance.named.iter()) @@ -1230,11 +1192,8 @@ impl<'tcx> Collector<'tcx> { }) .collect(); *shown.last_mut().expect("a path has a segment") += &format!("<{}>", spelled.join(", ")); - if self.exclude(&shown) { - return None; - } } - Some(shown) + shown } /// Each type a function's signature names at `args`, normalized, a returned future's @@ -1316,8 +1275,7 @@ impl<'tcx> Collector<'tcx> { /// The instance `ty` is, if it is an exported generic type at arguments without type /// parameters, or why it does not export: an argument holds an instance of a type - /// inside it, which could otherwise name ever deeper instances, a bound is unmet, or - /// the config excludes it. + /// inside it, which could otherwise name ever deeper instances, or a bound is unmet. fn admit(&mut self, ty: Ty<'tcx>) -> Option<(Key<'tcx>, Result, Why>)> { let tcx = self.tcx; let ty::Adt(adt, args) = *ty.kind() else { @@ -1367,9 +1325,6 @@ impl<'tcx> Collector<'tcx> { let last = shown.last_mut().expect("a path has a segment"); *last = format!("{last}<{}>", spelled.join(", ")); } - if self.exclude(&shown) { - return Some((key, Err(why("excluded type", spelled)))); - } let site = Site { key, args, @@ -1420,9 +1375,6 @@ impl<'tcx> Collector<'tcx> { // A glob of its root re-exports its items instead, which export. The span is // the `pub use` naming the crate, past any glob of the module holding it. if kind == DefKind::Mod && def_id.is_crate_root() && !def_id.is_local() { - if self.exclude(&path) { - continue; - } let span = child.reexport_chain.last().and_then(|reexport| reexport.id()); let span = span.map_or_else(|| tcx.def_span(def_id), |id| tcx.def_span(id)); let krate = tcx.crate_name(def_id.krate).to_string(); @@ -1434,10 +1386,6 @@ impl<'tcx> Collector<'tcx> { } let mut modules = modules.clone(); modules.push(def_id); - if self.exclude(&path) { - self.left_out.insert(def_id, "excluded type"); - continue; - } if tcx.is_doc_hidden(def_id) { let (report, rest) = self.report(&path); report.hidden.push(rest); @@ -1504,10 +1452,6 @@ impl<'tcx> Collector<'tcx> { let own = self.crate_path(def_id).expect("a reached type has a path in its crate"); let outside = path.len(); path.extend(own); - if self.exclude(&path) { - self.left_out.insert(def_id, "excluded type"); - continue; - } if tcx.is_doc_hidden(def_id) { let (report, rest) = self.report(&path); report.hidden.push(rest); @@ -2192,6 +2136,11 @@ impl<'tcx> Collector<'tcx> { !self.foreign_value(did) && api.objects[i].opaque.is_some() && !held.contains(&Type::Object(i)) }) .map(|&(def_id, _)| Key { def_id, args: None }); + // One only refused items name, such as a field whose getter is refused for not being + // `Clone`, is no less unheld, which leaves those items out. + let pruned = (self.pruned.iter()) + .map(|&def_id| Key { def_id, args: None }) + .filter(|key| !self.orphans.contains(key)); (self.decls.iter()) .filter_map(|(&key, decl)| match decl { Decl::Object(i) if !held.contains(&Type::Object(*i)) => Some(key), @@ -2199,6 +2148,7 @@ impl<'tcx> Collector<'tcx> { _ => None, }) .chain(opaque) + .chain(pruned) .collect() } @@ -2426,7 +2376,7 @@ impl<'tcx> Collector<'tcx> { let self_ty = self.site_ty(&site); let chain = self.derefs(self_ty); if !chain.is_empty() { - chains.push((index, self.member_names(self_ty), self.path_names(self_ty), chain)); + chains.push((index, self.member_names(self_ty), chain)); } let shared = traits.clone && self.clone_shares(self.site_ty(&site), def_id); let object = &mut self.api.objects[index]; @@ -2439,8 +2389,8 @@ impl<'tcx> Collector<'tcx> { } } } - for (object, names, paths, chain) in chains { - self.forward(object, names, paths, chain, &records); + for (object, names, chain) in chains { + self.forward(object, names, chain, &records); } } @@ -2488,29 +2438,6 @@ impl<'tcx> Collector<'tcx> { chain } - /// The names of `ty`'s `pub` inherent functions, with `self` or not, and constants, which - /// share its path with a field of the same name, as `field_key` counts them. - fn path_names(&self, ty: Ty<'tcx>) -> Vec { - let tcx = self.tcx; - let ty::Adt(adt, _) = ty.kind() else { - return Vec::new(); - }; - (tcx.inherent_impls(adt.did()).iter()) - .filter_map(|&imp| Some((imp, self.impl_args(imp, ty)?))) - .flat_map(|(imp, parent)| { - tcx.associated_items(imp) - .in_definition_order() - .map(move |item| (item, parent)) - }) - .filter(|(item, parent)| { - matches!(item.kind, ty::AssocKind::Fn { .. } | ty::AssocKind::Const { .. }) - && tcx.visibility(item.def_id).is_public() - && self.applies(item.def_id, *parent) - }) - .map(|(item, _)| item.name().to_string()) - .collect() - } - /// The names of `ty`'s `pub` inherent methods, then of its `pub` fields, exported or not, /// which hide any method or field of the same name a type it derefs to has, as they do in /// Rust: a method of each inherent impl that applies to `ty`, whose own bounds Rust checks @@ -2539,12 +2466,11 @@ impl<'tcx> Collector<'tcx> { /// Give object `object` the methods and field accessors of each type it derefs to, as /// Rust's auto-deref reaches them: each one through `&self`, and through `&mut self` while /// every `Deref` on the way is a `DerefMut`, unless a nearer type's member takes its name. - /// A target forwards what it exports itself, so its config and refusals hold here too. + /// A target forwards what it exports itself, so its refusals hold here too. fn forward( &mut self, object: usize, mut names: (Vec, Vec), - paths: Vec, chain: Vec<(Option>, Ty<'tcx>, usize, bool)>, records: &rustc_data_structures::fx::FxHashMap>, ) { @@ -2596,26 +2522,7 @@ impl<'tcx> Collector<'tcx> { names.0.extend(methods); names.1.extend(fields); } - // The config names a forwarded member by the object's path, as it does the object's - // own: a field by `field@` where the object's function or constant, or a method of a - // type on its chain, shares its path, which then names that item alone. - let mut kept = Vec::new(); - for mut m in all { - let keep = match &mut m.access { - Access::Field { shared, .. } => { - let field = m.path.last().expect("a field has a name"); - *shared = names.0.iter().chain(&paths).any(|name| name == field); - let mut key = m.shown.clone(); - key[1].insert_str(0, "field@"); - !self.exclude(&key) && (*shared || !self.exclude(&m.shown)) - } - _ => !self.exclude(&m.shown), - }; - if keep { - kept.push(m); - } - } - self.api.objects[object].methods.extend(kept); + self.api.objects[object].methods.extend(all); } /// Drop each foreign type's object that no export names, so a crate that only builds @@ -2682,7 +2589,10 @@ impl<'tcx> Collector<'tcx> { true => drop(self.api.records.remove(gone)), false => drop(self.api.objects.remove(gone)), } - self.foreign.remove(n); + let (did, _) = self.foreign.remove(n); + if !value { + self.pruned.push(did); + } let values: Vec = (self.foreign[n..].iter()) .map(|&(did, _)| self.foreign_value(did)) .collect(); @@ -2725,33 +2635,6 @@ impl<'tcx> Collector<'tcx> { } } - /// The `field@` key of the field `name` of `site`, shown as `shown`, and whether a method - /// or constant shares its name, or `None` if the config excludes it. As in rustdoc, - /// `field@` and the path name the field, and the path alone does unless a method or - /// constant of this instance takes the name, which it then names. - fn field_key( - &mut self, - site: &Site<'tcx>, - name: rustc_span::Symbol, - shown: &[String], - ) -> Option<(Vec, bool)> { - let tcx = self.tcx; - let self_ty = self.site_ty(site); - let shared = (tcx.inherent_impls(site.key.def_id).iter()) - .filter_map(|&imp| Some((imp, self.impl_args(imp, self_ty)?))) - .flat_map(|(imp, parent)| { - (tcx.associated_items(imp).filter_by_name_unhygienic(name)).map(move |item| (item, parent)) - }) - .any(|(item, parent)| { - matches!(item.kind, ty::AssocKind::Fn { .. } | ty::AssocKind::Const { .. }) - && tcx.visibility(item.def_id).is_public() - && self.applies(item.def_id, parent) - }); - let mut key = shown.to_vec(); - key[1].insert_str(0, "field@"); - (!self.exclude(&key) && (shared || !self.exclude(shown))).then_some((key, shared)) - } - /// A getter and a setter for each `pub` field of a struct exported as an object or an /// opaque value: the getter returns a copy, and the setter assigns in place, as /// `x.field = value` does. @@ -2764,26 +2647,30 @@ impl<'tcx> Collector<'tcx> { } let name = field.name.to_string(); let shown = [&site.shown[..], std::slice::from_ref(&name)].concat(); - let Some((key, shared)) = self.field_key(site, field.name, &shown) else { - continue; - }; let span = tcx.def_span(field.did); let ty = field.ty(tcx, site.args).skip_norm_wip(); // An instance's field of `()`, such as a default extension, holds nothing to read. if ty.is_unit() { continue; } + // A field holding a reference is read through it, and has no setter: a handle + // outlives every call, so the reference would be `'static`, which no borrow C + // holds for a call is. + let (held, assigned) = match ty.kind() { + ty::Ref(_, inner, _) => (*inner, false), + _ => (ty, true), + }; // Read through `&self`, so returned as a copy, as a borrowed return is, and // written with a value C gives up, as an owned parameter is. - let read = Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, ty); + let read = Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, held); // A field that is an object but not `Clone` is lent from the receiver's handle, // as a method's borrowed return of one is. // So is an `Option` of one, as `Some` of the borrow. - let object = match ty.kind() { + let object = match held.kind() { ty::Adt(adt, args) if tcx.is_diagnostic_item(sym::Option, adt.did()) => args.type_at(0), - _ => ty, + _ => held, }; - let lends = !self.is_clone(ty) + let lends = !self.is_clone(held) && matches!(object.kind(), ty::Adt(adt, args) if matches!(self.decl(adt.did(), *args), Some(Decl::Object(_)))); let mapped = { self.lending.set(lends); @@ -2791,11 +2678,10 @@ impl<'tcx> Collector<'tcx> { self.lending.set(false); // A handle outlives every call, so a reference it holds is `'static`, which // C's borrow for the call is not. - let set = match self.ty(ty, Pos::Param) { - Ok(set) if matches!(set, Type::Ref(..)) || lends_inside(&set) => { - Err(why("'static borrow", ty.to_string())) - } - set => set, + let set = match assigned.then(|| self.ty(ty, Pos::Param)) { + Some(Ok(set)) if lends_inside(&set) => Err(why("'static borrow", ty.to_string())), + Some(set) => set.map(Some), + None => Ok(None), }; match (get, set) { (Ok(get), Ok(set)) => Ok((get, set)), @@ -2845,7 +2731,7 @@ impl<'tcx> Collector<'tcx> { lends_mut: false, derefs: 0, ties, - access: Access::Field { shared, set }, + access: Access::Field { set }, instance: None, home: Home::default(), }; @@ -2853,14 +2739,16 @@ impl<'tcx> Collector<'tcx> { let mut getter = accessor(Receiver::Ref, Vec::new(), get, false); getter.lends = lent; accessors.push(getter); - let value = Param { - name: "value".to_string(), - ty: set, - interned: false, - }; - accessors.push(accessor(Receiver::Mut, vec![value], Type::Unit, true)); + if let Some(set) = set { + let value = Param { + name: "value".to_string(), + ty: set, + interned: false, + }; + accessors.push(accessor(Receiver::Mut, vec![value], Type::Unit, true)); + } } - Err(why) => self.refuse(if shared { &key } else { &shown }, "field", span, why), + Err(why) => self.refuse(&shown, "field", span, why), } } accessors @@ -3094,7 +2982,7 @@ impl<'tcx> Collector<'tcx> { }) } - /// A type's inherent `pub` methods and constants the config does not exclude, each with + /// A type's inherent `pub` methods and constants, each with /// the arguments of its impl, the path reports show it by, and whether it is /// `doc(hidden)`. One whose own bounds fail at the instance is none of its methods, as /// is each of an impl whose bounds fail. @@ -3113,9 +3001,6 @@ impl<'tcx> Collector<'tcx> { continue; } let shown = [&site.shown[..], &[item.name().to_string()]].concat(); - if self.exclude(&shown) { - continue; - } let hidden = tcx.is_doc_hidden(item.def_id); if hidden || self.applies(item.def_id, parent) { members.push((item, parent, shown, hidden)); @@ -3193,7 +3078,10 @@ impl<'tcx> Collector<'tcx> { } _ => Err(vec![why("generic parameter", name.to_string())]), }); + // C hands Rust its return, which the glue builds owned. + let output = tcx.fn_sig(item.def_id).skip_binder().skip_binder().output(); match function { + Ok(_) if names_cow(tcx, output) => errs.push(why("callback signature", name.to_string())), Ok(function) if function.future => errs.push(why("async trait method", name.to_string())), Ok(function) if !function.params.iter().all(|p| foreign_arg(&p.ty)) @@ -3246,16 +3134,14 @@ impl<'tcx> Collector<'tcx> { }; let mut functions = Vec::new(); for instance in &instances { - let Some(shown) = self.shown(shown, instance) else { - continue; - }; + let shown = self.shown(shown, instance); let function = self.function(def_id, path.clone(), shown.clone(), self_ty, instance); functions.push((function, shown, !instance.named.is_empty())); } functions } - /// A function or method's signature at one of its instances, which the config names by + /// A function or method's signature at one of its instances, which reports name by /// `shown`: a method's receiver is `self_ty`. fn function( &self, @@ -4714,6 +4600,10 @@ impl<'tcx> Collector<'tcx> { let Some(ret) = ret else { return Some(Err(why("closure signature", param.to_string()))); }; + // C hands Rust its return, which the glue builds owned. + if names_cow(tcx, ret) { + return Some(Err(why("closure signature", ret.to_string()))); + } // A `Result` is its value and its error, as a function's is. let (ok, err) = match ret.kind() { ty::Adt(adt, args) if tcx.is_diagnostic_item(sym::Result, adt.did()) => { @@ -6016,6 +5906,14 @@ impl<'tcx> Collector<'tcx> { Type::List(Collection::Iter, Box::new(inner)) } } + } else if cow(tcx, did) { + // A returned `Cow` crosses as what it owns, a copy C would take of a borrow + // anyway. Only Rust returns one: what C hands Rust would need its form. + match (pos, args.type_at(1).kind()) { + (Pos::Return | Pos::Returned, ty::Str) => Type::String, + (Pos::Return | Pos::Returned, ty::Slice(byte)) if *byte == tcx.types.u8 => Type::Vec, + _ => return Err(why("Cow other than a returned string or bytes", ty.to_string())), + } } else if tcx.is_diagnostic_item(rustc_span::Symbol::intern("Duration"), did) { Type::Duration } else if tcx.is_diagnostic_item(rustc_span::Symbol::intern("NonZero"), did) { @@ -6364,13 +6262,23 @@ fn returns(api: &Api, ty: &Type, objects: &mut Vec) { } } -/// Whether `tr` is serde's `Serialize`, `Deserialize`, or `DeserializeOwned`, which -/// `serde_json::Value` meets as a document of any shape. +/// Whether `did` is `std::borrow::Cow`. +fn cow(tcx: TyCtxt<'_>, did: DefId) -> bool { + tcx.is_diagnostic_item(rustc_span::Symbol::intern("Cow"), did) +} + +/// Whether `ty` holds a `Cow` anywhere. +fn names_cow<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { + (ty.walk().filter_map(|arg| arg.as_type())).any(|ty| matches!(ty.kind(), ty::Adt(adt, _) if cow(tcx, adt.did()))) +} + +/// Whether `tr` is serde's `Serialize`, `Deserialize`, `DeserializeOwned`, or +/// `Deserializer`, which `serde_json::Value` meets as a document of any shape. fn serde(tcx: TyCtxt<'_>, tr: DefId) -> bool { matches!(tcx.crate_name(tr.krate).as_str(), "serde" | "serde_core") && matches!( tcx.item_name(tr).as_str(), - "Serialize" | "Deserialize" | "DeserializeOwned" + "Serialize" | "Deserialize" | "DeserializeOwned" | "Deserializer" ) } diff --git a/ffi/src/config.rs b/ffi/src/config.rs index 1b9961a90..45587d41e 100644 --- a/ffi/src/config.rs +++ b/ffi/src/config.rs @@ -1,39 +1,6 @@ -//! The `ffi.toml` that says what to leave out, and the facade package the CLI resolves. +//! The facade package the CLI resolves, and the environment it hands the wrapper. -use std::path::{Path, PathBuf}; - -use serde::Deserialize; - -/// What the export leaves out of the facade's API. -#[derive(Debug, Deserialize)] -#[serde(deny_unknown_fields, rename_all = "kebab-case")] -pub(crate) struct Config { - /// Paths from the facade's root left out of the export: a module, an item, or one - /// method or field (`track::Producer::poll_closed`). Each must name something - /// exported, or what a `cfg` leaves out of this build. As in rustdoc, a path a method or constant shares with a field names the method, and - /// `field@` before it names the field. - #[serde(default)] - pub(crate) exclude: Vec, -} - -/// The keys `exclude` names the item at `shown` by, its path with its instances' -/// arguments, longest first: each prefix of it as is, then without the arguments, which -/// names the generic item's every instance. Each comes with its length. -pub(crate) fn keys(shown: &[String]) -> impl Iterator + '_ { - (1..=shown.len()).rev().flat_map(move |len| { - let exact = shown[..len].join("::"); - let generic: Vec<&str> = shown[..len].iter().map(|s| s.split('<').next().unwrap_or(s)).collect(); - let generic = Some(generic.join("::")).filter(|generic| *generic != exact); - std::iter::once(exact).chain(generic).map(move |key| (len, key)) - }) -} - -impl Config { - pub(crate) fn load(path: &Path) -> Result { - let text = std::fs::read_to_string(path).map_err(|err| format!("reading {}: {err}", path.display()))?; - toml::from_str(&text).map_err(|err| format!("parsing {}: {err}", path.display())) - } -} +use std::path::PathBuf; /// The facade: the package whose library's `pub` API is exported, as the CLI resolves it /// for the wrapper. @@ -77,8 +44,6 @@ impl Package { /// Environment variables the CLI hands the wrapper. pub(crate) mod env { - /// The `ffi.toml` path, absolute. - pub(crate) const CONFIG: &str = "RUST2_FFI_CONFIG"; /// The output directory, absolute. pub(crate) const OUT: &str = "RUST2_FFI_OUT"; /// The directory to write the census into instead of exporting, absolute. diff --git a/ffi/src/driver.rs b/ffi/src/driver.rs index fa284181f..1bf8dfe81 100644 --- a/ffi/src/driver.rs +++ b/ffi/src/driver.rs @@ -5,21 +5,15 @@ use std::path::{Path, PathBuf}; use std::process::{Command, ExitCode}; use rustc_ast as ast; -use rustc_data_structures::fx::FxHashSet; use rustc_driver::{Callbacks, Compilation}; -use rustc_hir::def::{DefKind, Res}; -use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_interface::interface::Compiler; -use rustc_lexer::{FrontmatterAllowed, TokenKind}; -use rustc_middle::middle::resolve::Reexport; use rustc_middle::ty::TyCtxt; use rustc_parse::lexer::StripTokens; use rustc_parse::parser::{AllowConstBlockItems, ForceCollect}; -use rustc_span::{FileName, Span, sym}; +use rustc_span::{FileName, Span}; use crate::abi::Abi; -use crate::config::{self, Config}; -use crate::ir::{self, Api}; +use crate::config; use crate::{census, collect, glue, merge}; /// Run as rustc, with `args` as cargo passed them: the wrapped rustc's path first. @@ -53,7 +47,6 @@ pub(crate) const API_FILE: &str = "api.json"; struct Export { /// Each crate the facade builds with, as [`config::env::CRATES`] has them. crates: std::collections::BTreeMap, - config: Config, output: Output, /// The facade's package, with the features rustc compiles it with. facade: config::Package, @@ -81,15 +74,14 @@ enum Output { impl Export { /// The job for this rustc invocation, if it compiles the facade's library. fn for_args(args: &[String]) -> Result, String> { - let Some(path) = std::env::var_os(config::env::CONFIG) else { + let Some(line) = std::env::var_os(config::env::PACKAGE) else { return Ok(None); }; - let line = std::env::var(config::env::PACKAGE).map_err(|_| format!("{} is unset", config::env::PACKAGE))?; - let mut facade = config::Package::parse(&line)?; + let line = (line.to_str()).ok_or_else(|| format!("{} is not UTF-8", config::env::PACKAGE))?; + let mut facade = config::Package::parse(line)?; if !rust2_driver::rustc::compiles_lib(args, &facade.name) { return Ok(None); } - let config = Config::load(path.as_ref())?; let output = match ( std::env::var_os(config::env::OUT), std::env::var_os(config::env::CENSUS), @@ -138,7 +130,6 @@ impl Export { .map(PathBuf::from); Ok(Some(Self { crates, - config, output, facade, patch, @@ -179,61 +170,30 @@ impl Callbacks for Export { let facade = collect::Facade { root: self.facade.root(), package: &self.facade.name, - // A census counts the whole API, whatever the config leaves out. crates: &self.crates, - exclude: match self.output { - Output::Census(_) => &[], - Output::Dir(_) | Output::Api(_) => &self.config.exclude, - }, - // It lists instead each item one names that exports. - audit: match self.output { - Output::Census(_) => &self.config.exclude, - Output::Dir(_) | Output::Api(_) => &[], - }, }; let collected = collect::collect(tcx, &facade); let report = &collected.report; if let Output::Census(dir) = &self.output { let abi = Abi::new(&collected.api, &self.facade.lib); - // What Swift refuses needs its exclude, as the export says, so it is not exporting. + // What Swift refuses fails the export too, so the census lists it with the rest. // Swift exports the API without what takes a JNI value, as the export does. let rest = collected.api.without_jni(); - let swift: FxHashSet<_> = crate::swift::refusals(&abi.without_jni(&rest)) - .into_iter() - .map(|(f, _)| f.shown.clone()) - .collect(); - let exporting = exporting(&collected.api, &report.audited, &swift); - let config = census_config(tcx, &facade, &self.facade.lib, report, &swift); - let text = census::render(&collected.api, report, &config, &exporting, &abi.clashes, &|span| { - at(tcx, span) - }); + let swift = crate::swift::refusals(&abi.without_jni(&rest)); + let text = census::render(&collected.api, report, &swift, &abi.clashes, &|span| at(tcx, span)); // A census reports what a crate uses, but a missed instance is the exporter's bug. for refusal in &report.refusals { if refusal.why.iter().any(|why| why.construct == collect::NOT_INFERRED) { - refuse(tcx, refusal, "inference missed an instance, a bug in rust2-ffi"); + refuse(tcx, refusal, Some("inference missed an instance, a bug in rust2-ffi")); } } if let Err(err) = write(&dir.join(format!("{}.md", report.package)), &text) { tcx.dcx().err(format!("rust2-ffi: {err}")); } - // An exclude that leaves out what would export hides that much of the API. - for (exclude, exported) in &exporting { - tcx.dcx().err(format!( - "rust2-ffi: exclude `{exclude}` in the config leaves out `{}`, which exports", - exported.join("`, `") - )); - } return stop_on_errors(tcx); } for refusal in &report.refusals { - refuse(tcx, refusal, "exclude it in the config to leave it out"); - } - for (path, count) in &report.excluded { - if *count == 0 && !configured_out(tcx, path) { - tcx.dcx().err(format!( - "rust2-ffi: exclude `{path}` in the config names nothing exported" - )); - } + refuse(tcx, refusal, None); } // Refusals still let the export go on to report each clash, but write nothing. Those // of the CLI's later steps, the lockfile's and the web target's walk, come once the @@ -242,7 +202,6 @@ impl Callbacks for Export { names: None, package: self.facade.name.clone(), features: self.facade.features.clone(), - exclude: self.config.exclude.clone(), api: collected.api, }; let written = match &self.output { @@ -261,132 +220,6 @@ impl Callbacks for Export { } } -/// The `exclude` that exports what maps: each item collection or Swift refuses, checked by -/// collecting again with it. One naming only an instance a refused item alone named names -/// nothing once that item is left out, and the export would fail on it, so it is dropped; -/// what that collection refuses besides is added, until the config holds. -fn census_config( - tcx: TyCtxt<'_>, - facade: &collect::Facade, - lib: &str, - report: &collect::Report, - swift: &FxHashSet, -) -> Vec { - let refused = |report: &collect::Report, swift: &FxHashSet| -> Vec { - (report.refusals.iter().map(|r| r.path.clone())) - .chain(swift.iter().map(|path| path[1..].join("::"))) - .collect() - }; - let mut config = refused(report, swift); - let mut seen = Vec::new(); - loop { - config.sort(); - config.dedup(); - // A config the last round checked and left as it was holds. - if config.is_empty() || seen.last() == Some(&config) { - return config; - } - // A round drops a dead exclude as well as adding a refusal, so rounds may cycle, - // which no config ends: a bug of the collector's, as a refusal must not come and go. - if let Some(earlier) = seen.iter().find(|earlier| **earlier == config) { - let last = seen.last().expect("a repeat follows a round"); - let moving: Vec<&String> = (earlier.iter().filter(|p| !last.contains(p))) - .chain(last.iter().filter(|p| !earlier.contains(p))) - .collect(); - tcx.dcx().err(format!( - "rust2-ffi: the census's exclude never settles, as rounds of it cycle on {}", - moving.iter().map(|p| format!("`{p}`")).collect::>().join(", ") - )); - return config; - } - seen.push(config.clone()); - let checked = collect::collect( - tcx, - &collect::Facade { - root: facade.root.clone(), - package: facade.package, - exclude: &config, - crates: facade.crates, - audit: &[], - }, - ); - let abi = Abi::new(&checked.api, lib); - let rest = checked.api.without_jni(); - let swift: FxHashSet<_> = crate::swift::refusals(&abi.without_jni(&rest)) - .into_iter() - .map(|(f, _)| f.shown.clone()) - .collect(); - let more = refused(&checked.report, &swift); - let dead: Vec<&String> = (checked.report.excluded.iter()) - .filter(|(path, count)| *count == 0 && !configured_out(tcx, path)) - .map(|(path, _)| path) - .collect(); - config.retain(|path| !dead.contains(&path)); - config.extend(more); - } -} - -/// Each exclude whose item would export without it, and that item's paths: what an -/// exclude checked, from [`collect::Report::audited`], that the census's API holds by the -/// same path, except a function `refused` names by its shown path, since a generic's -/// instances share a span but Swift may refuse only some. -fn exporting( - api: &Api, - audited: &[(String, Vec)], - refused: &FxHashSet, -) -> Vec<(String, Vec)> { - // Every path an exported item is checked by, from the facade's root, as the walk checks it. - let mut paths = FxHashSet::default(); - let mut add = |path: &[String]| { - paths.insert(path[1..].join("::")); - }; - let methods = |methods: &[ir::Function], add: &mut dyn FnMut(&[String])| { - for f in methods.iter().filter(|f| !refused.contains(&f.shown)) { - match f.access { - // A field is checked by `field@` and, unless a method or constant takes its - // name, by its path, which then names that method or constant instead. - ir::Access::Field { shared, .. } => { - let mut key = f.shown.clone(); - key[1].insert_str(0, "field@"); - add(&key); - if !shared { - add(&f.shown); - } - } - _ => add(&f.shown), - } - } - }; - for r in &api.records { - add(&r.shown); - methods(&r.methods, &mut add); - } - for e in &api.enums { - add(&e.shown); - methods(&e.methods, &mut add); - } - for o in &api.objects { - add(&o.shown); - methods(&o.methods, &mut add); - } - for c in &api.callbacks { - add(&c.path); - methods(&c.methods, &mut add); - } - methods(&api.functions, &mut add); - for c in &api.constants { - add(&c.path); - } - (audited.iter()) - .filter_map(|(exclude, named)| { - let mut exported: Vec = named.iter().filter(|path| paths.contains(*path)).cloned().collect(); - exported.sort(); - exported.dedup(); - (!exported.is_empty()).then(|| (exclude.clone(), exported)) - }) - .collect() -} - impl Export { /// This target's API merged with the other targets', or none once a difference /// between two of them is an error. @@ -418,7 +251,6 @@ impl Export { let differs = [ ("package", theirs.package != ours.package), ("features", theirs.features != ours.features), - ("config's exclude", theirs.exclude != ours.exclude), ]; for (what, _) in differs.iter().filter(|(_, differs)| *differs) { unmergeable = true; @@ -553,10 +385,7 @@ impl Export { // Swift exports the API without what takes a JNI value, which only Kotlin passes. let rest = api.without_jni(); for (function, why) in crate::swift::refusals(&abi.without_jni(&rest)) { - tcx.dcx().span_err( - function.span, - format!("rust2-ffi: {why}; exclude it in the config to leave it out"), - ); + tcx.dcx().span_err(function.span, format!("rust2-ffi: {why}")); } let can_generate = tcx.dcx().has_errors().is_none(); let baseline = match self.baseline(tcx, &target) { @@ -600,8 +429,8 @@ fn stop_on_errors(tcx: TyCtxt<'_>) -> Compilation { } } -/// Emits `refusal` as an error at its span, with every reason and its notes, then `advice`. -fn refuse(tcx: TyCtxt<'_>, refusal: &collect::Refusal, advice: &str) { +/// Emits `refusal` as an error at its span, with every reason, any `advice`, and its notes. +fn refuse(tcx: TyCtxt<'_>, refusal: &collect::Refusal, advice: Option<&str>) { let reasons: Vec = refusal .why .iter() @@ -613,10 +442,11 @@ fn refuse(tcx: TyCtxt<'_>, refusal: &collect::Refusal, advice: &str) { let mut err = tcx.dcx().struct_span_err( refusal.span, format!( - "rust2-ffi: cannot export {} `{}`: {}; {advice}", + "rust2-ffi: cannot export {} `{}`: {}{}", refusal.kind, refusal.path, - reasons.join("; ") + reasons.join("; "), + advice.map_or_else(String::new, |advice| format!("; {advice}")) ), ); for (span, note) in refusal.why.iter().filter_map(|why| why.note.as_ref()) { @@ -678,154 +508,3 @@ pub(crate) fn write(path: &Path, text: &str) -> Result<(), String> { format!("writing {}: {err}", path.display()) }) } - -/// Whether the struct, enum, or union `adt` declares a field or variant `name` under a -/// `cfg` this build left it out by. rustc records only the items a `cfg` strips, not their -/// members, so this reads the declaration from its source. -fn stripped_member(tcx: TyCtxt<'_>, adt: DefId, name: &str) -> bool { - if tcx.adt_def(adt).all_fields().any(|f| f.name.as_str() == name) - || tcx.adt_def(adt).variants().iter().any(|v| v.name.as_str() == name) - { - return false; - } - // The item from its name on, up to the `;` or closing brace that ends it: past it the - // file may close a module the item is in, which the parser would refuse unmatched. Each - // place nesting returns to the item's own level may end it, such as a const generic's - // block before its fields, so the first that parses as an item does. - let source_map = tcx.sess.source_map(); - let head = tcx.def_span(adt); - let source_file = source_map.lookup_source_file(head.lo()); - let Ok(source) = source_map.span_to_snippet(head.with_hi(source_file.end_position())) else { - return false; - }; - let (mut depth, mut at) = (0usize, 0usize); - let mut item = None; - for token in rustc_lexer::tokenize(&source, FrontmatterAllowed::No) { - at += token.len as usize; - let end = match token.kind { - TokenKind::OpenParen | TokenKind::OpenBrace | TokenKind::OpenBracket => { - depth += 1; - false - } - TokenKind::CloseParen | TokenKind::CloseBrace | TokenKind::CloseBracket => { - // A delimiter the item never opened closes the module it is in. - let Some(inner) = depth.checked_sub(1) else { break }; - depth = inner; - depth == 0 && token.kind == TokenKind::CloseBrace - } - TokenKind::Semi => depth == 0, - _ => false, - }; - if end && let Some(parsed) = parse_item(tcx, &source[..at]) { - item = Some(parsed); - break; - } - } - let Some(item) = item else { return false }; - // A `cfg`, or one a `cfg_attr` adds, at any depth: the attributes past its predicate. - fn adds_cfg(items: &[ast::MetaItemInner]) -> bool { - items.iter().skip(1).any(|item| { - item.has_name(sym::cfg) || (item.has_name(sym::cfg_attr) && item.meta_item_list().is_some_and(adds_cfg)) - }) - } - let configured = |attrs: &[ast::Attribute]| { - attrs.iter().any(|attr| { - attr.has_name(sym::cfg) - || (attr.has_name(sym::cfg_attr) && attr.meta_item_list().is_some_and(|items| adds_cfg(&items))) - }) - }; - match &item.kind { - ast::ItemKind::Struct(_, _, data) | ast::ItemKind::Union(_, _, data) => { - (data.fields().iter()).any(|f| f.ident.is_some_and(|ident| ident.as_str() == name) && configured(&f.attrs)) - } - ast::ItemKind::Enum(_, _, def) => { - (def.variants.iter()).any(|v| v.ident.as_str() == name && configured(&v.attrs)) - } - _ => false, - } -} - -/// `source` parsed as one item, or none if it is not one. -fn parse_item(tcx: TyCtxt<'_>, source: &str) -> Option> { - let file = FileName::anon_source_code(source); - let mut parser = match rustc_parse::new_parser_from_source_str( - &tcx.sess.psess, - file, - source.to_string(), - StripTokens::Nothing, - ) { - Ok(parser) => parser, - Err(errors) => { - errors.into_iter().for_each(|e| e.cancel()); - return None; - } - }; - match parser.parse_item(ForceCollect::No, AllowConstBlockItems::DoesNotMatter) { - Ok(item) => item, - Err(e) => { - e.cancel(); - None - } - } -} - -/// Whether `path` names an item a `cfg` leaves out of this build, or a field or variant of -/// one: the config names it for the builds that have it. The path runs from the facade's -/// root, or from a crate's by its name, as the walk names a type no facade module -/// re-exports. -fn configured_out(tcx: TyCtxt<'_>, path: &str) -> bool { - let path = path.strip_prefix("field@").unwrap_or(path); - let segments: Vec<&str> = path.split("::").collect(); - // Any crate of the name, since a build may link several of its versions. - let mut krates = (tcx.crates(()).iter()).filter(|&&k| tcx.crate_name(k).as_str() == segments[0]); - stripped_under(tcx, LOCAL_CRATE.as_def_id(), &segments) - || krates.any(|&k| stripped_under(tcx, k.as_def_id(), &segments[1..])) -} - -/// Whether `segments`, from `module`, name an item a `cfg` strips, or a field or variant of -/// one. Its first segment no module has is stripped from that module or from one the module -/// glob-re-exports. -fn stripped_under(tcx: TyCtxt<'_>, mut module: DefId, segments: &[&str]) -> bool { - for (i, segment) in segments.iter().enumerate() { - let name = segment.split('<').next().unwrap_or(segment); - let children = match module.as_local() { - Some(local) => tcx.module_children_local(local), - None => tcx.module_children(module), - }; - if let Some(child) = children.iter().find(|child| child.ident.as_str() == name) { - match child.res { - Res::Def(DefKind::Mod, def_id) => { - module = def_id; - continue; - } - Res::Def(DefKind::Struct | DefKind::Enum | DefKind::Union, def_id) if i + 2 == segments.len() => { - return stripped_member(tcx, def_id, segments[i + 1]); - } - // A method, or a member past one, which no `cfg` this checks strips. - _ => return false, - } - } - // Each source of a glob the item came through, while its imports are globs: the - // module of the next import, or else the item's own. A single re-export brings in no - // other name of its module. - let sources = children - .iter() - .flat_map(|child| { - let chain = &child.reexport_chain; - let globs = chain - .iter() - .take_while(|reexport| matches!(reexport, Reexport::Glob(_))); - (globs.enumerate()).filter_map(move |(i, _)| match chain.get(i + 1).and_then(|next| next.id()) { - Some(import) => tcx.opt_parent(import), - None => child.res.opt_def_id().and_then(|def_id| tcx.opt_parent(def_id)), - }) - }) - .chain([module]); - let stripped = |source: DefId| { - (tcx.stripped_cfg_items(source.krate).iter()) - .any(|item| item.parent_scope == source && item.ident.as_str() == name) - }; - return sources.collect::>().into_iter().any(stripped); - } - false -} diff --git a/ffi/src/glue.rs b/ffi/src/glue.rs index 67a2cd16a..012d3a8c5 100644 --- a/ffi/src/glue.rs +++ b/ffi/src/glue.rs @@ -1191,9 +1191,10 @@ impl Gen<'_> { Type::NonZero(_) => format!("({e}).get()"), Type::Char => format!("{e} as u32"), Type::Str => format!("rt::Buf::string({e}.to_owned())"), - Type::String => format!("rt::Buf::string({e})"), + // From a `Cow` too, which a return of either may be. + Type::String => format!("rt::Buf::string(::std::string::String::from({e}))"), Type::Slice => format!("rt::Buf::vec({e}.to_vec())"), - Type::Vec => format!("rt::Buf::vec({e})"), + Type::Vec => format!("rt::Buf::vec(::std::vec::Vec::from({e}))"), Type::Bytes => format!("rt::Buf::owned({e})"), Type::Path => format!("rt::Buf::path_buf({e}.to_path_buf())"), Type::PathBuf => format!("rt::Buf::path_buf({e})"), diff --git a/ffi/src/ir.rs b/ffi/src/ir.rs index b72257f27..24a1bf52f 100644 --- a/ffi/src/ir.rs +++ b/ffi/src/ir.rs @@ -515,10 +515,8 @@ pub(crate) struct Instance { pub(crate) enum Access { /// It calls the function. Call, - /// It reads a `pub` field of its receiver, or with `set` assigns it. `shared` when a - /// method or constant of its type takes its name, which its path then names, so the - /// config names the field `field@`, as rustdoc does. - Field { shared: bool, set: bool }, + /// It reads a `pub` field of its receiver, or with `set` assigns it. + Field { set: bool }, /// It reads a constant that is not a `bool` or integer. Const, /// It parses its receiver's type from text, with `FromStr`, failing with the parse diff --git a/ffi/src/lock.rs b/ffi/src/lock.rs index 5c4dca59b..fa58478a9 100644 --- a/ffi/src/lock.rs +++ b/ffi/src/lock.rs @@ -783,12 +783,9 @@ fn fields(what: &str, ours: &[crate::ir::Field], theirs: &[crate::ir::Field]) -> /// What of the function `ours` changed in `theirs`, both bare and of one key. fn signature(ours: &Function, theirs: &Function) -> Vec { let (mut ours, mut theirs) = (ours.clone(), theirs.clone()); - // Which name the config gives a field: no binding names it otherwise. Nor whether a held - // handle fails it, which only a newer export lends and a baseline written before it lacks. + // Not whether a held handle fails it, which only a newer export lends and a baseline + // written before it lacks. for f in [&mut ours, &mut theirs] { - if let Access::Field { shared, .. } = &mut f.access { - *shared = false; - } f.ties = false; } let mut changes = Vec::new(); diff --git a/ffi/src/merge.rs b/ffi/src/merge.rs index 469a1a152..b2db3d7e8 100644 --- a/ffi/src/merge.rs +++ b/ffi/src/merge.rs @@ -27,8 +27,6 @@ pub(crate) struct Target { /// The features the facade compiled with, which every target's must share, since the /// crate enables one set. pub(crate) features: Vec, - /// The config's `exclude`, which every target's must share. - pub(crate) exclude: Vec, pub(crate) api: Api, } diff --git a/ffi/src/wasm.rs b/ffi/src/wasm.rs index 7371de529..24f89c67d 100644 --- a/ffi/src/wasm.rs +++ b/ffi/src/wasm.rs @@ -1053,7 +1053,7 @@ fn report<'tcx>(tcx: TyCtxt<'tcx>, graph: &Graph<'tcx>, lacks: &Lacks, own: &dyn let mut err = tcx.dcx().struct_span_err( span, format!( - "rust2-ffi: {what} {said}; leave it out of {}'s build with a `cfg`, or exclude its export in the config", + "rust2-ffi: {what} {said}; leave it out of {}'s build with a `cfg`", host.target ), ); From eaf49ed4bf66f2e9025902d8fe4b34ec69f4b457 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 18:00:51 -0800 Subject: [PATCH 03/10] ffi: fixtures, tests, and docs without the config; api cases for the new rules Co-Authored-By: Claude Opus 5.5 --- bench/ffi/README.md | 2 +- ffi/README.md | 50 ++-- ffi/fixtures/api/examples/transcript.rs | 13 +- ffi/fixtures/api/ffi.toml | 37 --- ffi/fixtures/api/src/lib.rs | 70 +++-- ffi/fixtures/lacks/expected.txt | 50 ++-- ffi/fixtures/lacks/ffi.toml | 1 - ffi/fixtures/lock/ffi.toml | 2 - ffi/fixtures/reject/expected.txt | 374 ++++++++++++------------ ffi/fixtures/reject/ffi.toml | 2 - ffi/fixtures/reject/src/lib.rs | 42 +-- ffi/justfile | 18 +- ffi/moq/ffi.toml | 13 - ffi/moq/web.toml | 4 - ffi/release/package.py | 9 +- ffi/src/collect.rs | 59 ++-- ffi/tests/api.c | 1 - ffi/tests/api.cpp | 1 - ffi/tests/api.dart | 1 - ffi/tests/api.go | 1 - ffi/tests/api.kt | 1 - ffi/tests/api.py | 1 - ffi/tests/api.swift | 1 - ffi/tests/api.ts | 1 - ffi/tests/fixtures.rs | 254 +++++----------- ffi/tests/fixtures/corpus.rs | 48 ++- ffi/tests/fixtures/shapes.rs | 52 ++-- go/bench/ffi.toml | 3 - go/justfile | 2 +- 29 files changed, 480 insertions(+), 633 deletions(-) delete mode 100644 ffi/fixtures/api/ffi.toml delete mode 100644 ffi/fixtures/lacks/ffi.toml delete mode 100644 ffi/fixtures/lock/ffi.toml delete mode 100644 ffi/fixtures/reject/ffi.toml delete mode 100644 ffi/moq/ffi.toml delete mode 100644 ffi/moq/web.toml delete mode 100644 go/bench/ffi.toml diff --git a/bench/ffi/README.md b/bench/ffi/README.md index 88531c952..363d1f0dc 100644 --- a/bench/ffi/README.md +++ b/bench/ffi/README.md @@ -693,7 +693,7 @@ and Kotlin's calls trail it by 1.2 to 4 times, behind JNI's per-call cost and th The web binding runs over its own export of the stand-in, `target/moq-ffi-web`: the same crates less moq-tokio, which pulls in rustls-native-certs, with no wasm32-wasip1 platform -module, and so less the items that name it ([`moq/web.toml`](../../ffi/moq/web.toml)). +module. Nothing builds for wasm32-unknown-unknown, where getrandom 0.4 has no backend without a config flag. `export.ts` imports the generated modules as a caller would, and disposes each handle and payload it gets. A browser gives no process CPU clock, so its columns are wall diff --git a/ffi/README.md b/ffi/README.md index 4667e2510..4e8b760fd 100644 --- a/ffi/README.md +++ b/ffi/README.md @@ -9,7 +9,7 @@ whole public API is not generally exportable: generic and borrow signatures can be refused, and the census also lists API items left out by those rules. ```bash -rust2-ffi --config ffi.toml (--out dir | --census dir | --api file) [--manifest-path Cargo.toml] [--target triple]... [--with file]... [--baseline api.json] [-- cargo args] +rust2-ffi (--out dir | --census dir | --api file) [--manifest-path Cargo.toml] [--target triple]... [--with file]... [--baseline api.json] [-- cargo args] ``` It runs `cargo check` on the package with itself as `RUSTC_WRAPPER`, for each `--target` @@ -56,18 +56,9 @@ An export again rewrites only the files whose content changed, and removes from export stays fresh. The crate's version, `0.0.0+`, hashes its Rust sources and manifest, so exports that differ build apart in a target directory they share. -```toml -# ffi.toml, beside the package's Cargo.toml unless --manifest-path says otherwise. -# Paths from the facade's root left out: a module, an item, or one method or field. A type -# no facade module re-exports goes by its crate's name and its public path there. Each -# must name something exported, or what a `cfg` leaves out of this build, as moq-tokio's -# `unix` is on Windows. Nothing else leaves an item out. As in rustdoc, a path a -# method or constant shares with a field names the method, and `field@` the field. -# A `cfg`-stripped item is found through a glob re-export only while its source module -# keeps an exported item; under a glob of a module a `cfg` empties, the exclude fails as -# naming nothing exported. -exclude = ["track::Producer::poll_closed"] -``` +It reads no config: the package is in the current directory unless `--manifest-path` says +where, and an item the rules cannot export fails the export at its span. Nothing leaves an +item out but the source itself: `#[doc(hidden)]`, or a `cfg` that leaves it out of a build. ## Rules @@ -149,7 +140,7 @@ public path names, or an error taken by value, is held by value as an opaque han | `impl IntoIterator`, where `X` is no type parameter | `Vec`, or `&[Y]` where `X` is `&Y` | | `impl io::Read`, not bounded by `Seek` | `&[u8]` | | `impl Iterator` taken | `Vec`, whose items Rust iterates; for `X` of `&str` or `&[u8]`, an array of buffers C lends for the call; an iterator of other references, or one a future or a callback takes, is refused | -| another type parameter | `serde_json::Value` for a serde `Serialize` or `Deserialize` bound, else the first of `String`, `Bytes`, and `Vec` meeting its bounds, or a foreign implementation of its one exported trait; else an instance of the function at each type the exports implement a trait bounding it for, through a blanket impl at each type implementing what the impl requires, as `&X` where that meets its bounds too and no bound, its own or one a supertrait implies, makes it outlive the call, so C keeps its handle, and, as an argument of a generic type, at each argument of an instance that meets its bounds and makes each generic type the signature names an instance | +| another type parameter | `serde_json::Value` for a serde `Serialize`, `Deserialize`, or `Deserializer` bound, as a derived `deserialize` takes, else the first of `String`, `Bytes`, and `Vec` meeting its bounds, or a foreign implementation of its one exported trait; else an instance of the function at each type the exports implement a trait bounding it for, through a blanket impl at each type implementing what the impl requires, as `&X` where that meets its bounds too and no bound, its own or one a supertrait implies, makes it outlive the call, so C keeps its handle, and, as an argument of a generic type, at each argument of an instance that meets its bounds and makes each generic type the signature names an instance | | a const parameter of a function | an instance of the function at each value an instance of a generic type the signature passes it to has there, where each generic type the signature then names is an instance | | a const argument | a `bool` or an integer below 128 bits; any other is refused | @@ -164,11 +155,19 @@ maps, which may name more. Inference finishes before any type is mapped, so mapp never adds an instance. An instance that holds an instance of a type inside it, such as `Cell>`, is refused, as it could name ever deeper ones. +A field holding a reference, as `&'a mut ClientConfig` in rustls's +`DangerousClientConfig` is, is read through it, lent where it is not `Clone`, and has no +setter, since no borrow C holds outlives a call. A returned `Cow<'_, str>` or +`Cow<'_, [u8]>` crosses as the string or bytes it owns, a copy C would make of a borrow +anyway; a `Cow` anywhere else is refused, as C would hand Rust its form. Another crate's +type that only refused items name, as `std::net::TcpListener` in moq-tokio's +`server::Streams` is, is one no export returns, so those items are left out with it. + A record or enum holds only values and `Copy` handles: one with a field that does not map, or that holds itself, is an object instead, and the census lists it. A borrowed return is returned as a clone, so it must be `Clone`, and a handle in it is a new handle to the clone, but for an object a `&self` method of an object returns borrowed from its receiver -alone, or an object's `pub` field holds, bare or as an `Option`'s `Some`: that one, if not `Clone`, is a lent handle, which holds its receiver and checks it +alone, or an object's `pub` field holds, bare or as an `Option`'s `Some`, through a `Box` too: that one, if not `Clone`, is a lent handle, which holds its receiver and checks it on each use, on one thread at a time where the receiver is not `Sync`. A handle outlives every call, so every lifetime an object takes is `'static`, as is every lifetime that must outlive one; any other lifetime is the call's. A signature may not lend C's borrow for one that is `'static`, but for a @@ -229,7 +228,7 @@ A target's check may need its own C toolchain, as moq's `aws-lc-sys` and `ring` for a check, which only its own host may have. `--api file` writes one target's API, with the spans of its items, instead of exporting; an export elsewhere adds it with `--with file`, as though it had checked that target too. Both must check the same -package, features, and `exclude`, from the same sources: a staged span's file is relative +package and features, from the same sources: a staged span's file is relative to the workspace's root or cargo's home, so a checkout at another path keeps it, and is dropped for the other target's span where the file differs. @@ -258,7 +257,7 @@ API breaks the one in `file`, with an error at each item that names how: A tuple's struct, known by its Rust spelling, is renamed the same way when another tuple's elements run together into its name. -An item is known by its kind and Rust path, as `exclude` names it. An addition passes: a new +An item is known by its kind and Rust path. An addition passes: a new item, method, trait impl, or a variant of a `#[non_exhaustive]` enum. A constant's value and an item's docs may change. The check runs once, on the API every language is generated from; it compares C's names and the C++, Kotlin, Python, Swift, Go, and Dart generators' own @@ -461,10 +460,7 @@ Linux's exports, as the merge queue runs on, since a header names its targets. every instance the item exports at, so one an upstream change adds can lengthen another's name. A type instance's methods are named through it, and a function instance appends its arguments' names, a reference's by what it borrows and a const's by its value: the - api fixture's `drain` is `api_drain_4` at `Batch` and `api_drain_2` at `Batch<2>`. An - `exclude` of a type or method by the generic type's path leaves it out of every - instance, and by the instance's path - (`"mux::catalog::Producer::stats"`) out of that one. + api fixture's `drain` is `api_drain_4` at `Batch` and `api_drain_2` at `Batch<2>`. ## C++ @@ -1342,13 +1338,9 @@ runtime package and each crate's include [`runtime/rt.go`](runtime/rt.go) and ## Census `--census dir` exports nothing. It writes `.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. -That list is checked by collecting again with it: it holds what Swift alone refuses, and -not an instance only refused items named, which nothing names once they are left out. -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 +lists each refused item at its span, with what Swift alone refuses, each of which fails the +export, and what else it left out, such as what C can never hold and the traits C cannot +implement, and why. It fails on an `instance not inferred` refusal, which is a bug in the exporter's inference rather than in the crate. ## TypeScript (web) @@ -1562,7 +1554,7 @@ until the sampler covers it. The corpus (`tests/fixtures/corpus.rs`) exports stock crates as a consumer would: each crate of `corpus/crates.txt`, the top crates on crates.io by downloads that are libraries building as they are, pinned by `corpus/Cargo.lock`, through a facade of its own, `pub use -::*;`. Each is censused, then exported with the `exclude` its census writes, and +::*;`. Each is censused, then, where the census refuses nothing, exported, and its glue, C and C++ programs including its headers (compiled, not linked, since a crate may call a platform library the host lacks), its Kotlin, Python, Swift, Go, and Dart built; a panic, an error, or a binding that does not build fails it, a refusal not. diff --git a/ffi/fixtures/api/examples/transcript.rs b/ffi/fixtures/api/examples/transcript.rs index f273b57c1..3cd4be955 100644 --- a/ffi/fixtures/api/examples/transcript.rs +++ b/ffi/fixtures/api/examples/transcript.rs @@ -487,6 +487,7 @@ fn main() { next: Some(Box::new(Node { value: 2, next: None })), }; println!("node {}", list.sum()); + println!("node next {}", list.next.as_deref().map_or(0, |next| next.value)); let tally = Tally::new(); tally.bump(); @@ -759,6 +760,7 @@ fn main() { drop(draft); println!("dropped {}", ledger.published()); println!("receipt {}", ledger.receipt().count()); + println!("tab {}", ledger.tab().ledger.published()); // Members a `Deref` reaches: past an unexported target, beside a method of the same // name, and a field a method's path shares. let mut marker = api::Marker::new("m", 3, 5); @@ -861,7 +863,16 @@ fn main() { ); let doc: serde_json::Value = r#"{"b": [1, 2.5, null], "a": "\u00e9"}"#.parse().expect("a JSON document"); println!("json {}", api::encode(&doc)); - println!("timed text {}", api::timed_text(&doc)); + println!( + "cow {} {} {} {}", + api::unescaped(r"a\b"), + api::unescaped("plain"), + api::unzeroed(&[1, 0, 2]).len(), + api::unzeroed(&[3]).len() + ); + let spot = api::Spot::deserialize(serde_json::json!([1, 2])).unwrap(); + println!("spot {} {}", spot.x, spot.y); + println!("spot err {}", api::Spot::deserialize(serde_json::json!("x")).unwrap_err()); println!("tagged {}", api::tagged(doc, "t")); let entries = api::entries( [("b", "[1]"), ("a", "2")] diff --git a/ffi/fixtures/api/ffi.toml b/ffi/fixtures/api/ffi.toml deleted file mode 100644 index 27026dcd6..000000000 --- a/ffi/fixtures/api/ffi.toml +++ /dev/null @@ -1,37 +0,0 @@ -# The list's tail is not `Clone`, so its getter has no copy to return, one instance leaves -# out a method the others keep, `Timed`, `Sample`, `Queued`, `Tick`, `Tock`, `Scoped`, -# `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`'s do, and `Retry::jitter` and `field@Retry::jitter` leave out a refused method -# and its field. `Slot` 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, and a -# method a `Deref` forwards by the object's, as `Pad::lines` is. A forwarded field -# sharing its path with a method is `field@`, as `Pad`'s `title` is, so `Marker::x` -# leaves out its method alone, as `Marker::y` does its function without `self`. Swift -# refuses `among`, so the census takes its exclude. -exclude = [ - "among", - "Copied", - "Layer", - "Node::next", - "Marker::x", - "Marker::y", - "Pad::lines", - "Pair::swap", - "Queued", - "Rooted", - "Sample", - "Scoped", - "Slot::value", - "Retry::jitter", - "field@Pad::title", - "field@Retry::delay", - "field@Retry::jitter", - "field@Slot::value", - "Stack::depth_past", - "Stored", - "Tick", - "Timed", - "Tock", -] diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index b9f325e25..5278fdc08 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -810,6 +810,12 @@ impl Ledger { } } + /// A tab on this ledger, holding its exclusive borrow in a field, as rustls's + /// `ClientConfig::dangerous` does. + pub fn tab(&mut self) -> Tab<'_> { + Tab { ledger: self } + } + pub fn slip(&mut self) -> Slip<'_> { Slip { receipt: Receipt(&self.published), @@ -819,6 +825,13 @@ impl Ledger { } } +/// What [`Ledger::tab`] lends: a field holding a mutable borrow, which C reads through and +/// never assigns. +#[non_exhaustive] +pub struct Tab<'a> { + pub ledger: &'a mut Ledger, +} + mod noted { /// Implemented for a borrow of a ledger of any lifetime. pub trait Noted<'a> {} @@ -2840,9 +2853,6 @@ pub fn next_packet(packet: Packet) -> Packet { pub struct Retry { pub limit: Option, pub delay: Option, - /// 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 { @@ -2850,7 +2860,6 @@ impl Retry { Self { limit, delay: None, - jitter: 0, } } @@ -2865,11 +2874,6 @@ 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>>) -> 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 @@ -3048,18 +3052,6 @@ pub fn timed_hex(payload: impl Into> + 'static) -> String { hex(payload.into().value) } -/// A reference stamped with no time, as moq's `Timed` converts one. -impl<'a, V> From<&'a V> for Timed<&'a V> { - fn from(value: &'a V) -> Self { - Self { value, at: None } - } -} - -/// A timed value's compact JSON text, taken as moq's JSON tracks take theirs. -pub fn timed_text<'a, T: serde::Serialize + 'a>(value: impl Into>) -> String { - serde_json::to_string(value.into().value).expect("a JSON document serializes") -} - /// A timed payload on a track, which what converts into one converts into. pub struct Sample(Timed); @@ -4870,11 +4862,6 @@ pub fn farther_hop(hops: Pair>) -> Box> { 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() -} - /// A record named as C++'s `==` names its first argument, which must not hide it. #[allow(non_camel_case_types)] #[derive(Clone, Debug, PartialEq)] @@ -5026,3 +5013,34 @@ impl Key { ) } } + +/// `text` without its backslashes, borrowed where it has none, as moq-pattern's `unescape` is. +pub fn unescaped(text: &str) -> Cow<'_, str> { + match text.contains('\\') { + true => Cow::Owned(text.replace('\\', "")), + false => Cow::Borrowed(text), + } +} + +/// `bytes` without their zeros, borrowed where they have none. +pub fn unzeroed(bytes: &[u8]) -> Cow<'_, [u8]> { + match bytes.contains(&0) { + true => Cow::Owned(bytes.iter().copied().filter(|b| *b != 0).collect()), + false => Cow::Borrowed(bytes), + } +} + +/// A spot that reads itself from any serde deserializer, as `#[serde(remote = "Self")]` +/// derives an inherent `deserialize`, which moq-mux's `Mpegts` has. +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct Spot { + pub x: u32, + pub y: u32, +} + +impl Spot { + pub fn deserialize<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result { + let (x, y) = <(u32, u32) as serde::Deserialize>::deserialize(deserializer)?; + Ok(Self { x, y }) + } +} diff --git a/ffi/fixtures/lacks/expected.txt b/ffi/fixtures/lacks/expected.txt index 8b2265fc1..35743175b 100644 --- a/ffi/fixtures/lacks/expected.txt +++ b/ffi/fixtures/lacks/expected.txt @@ -1,25 +1,25 @@ -fixtures/lacks/src/lib.rs:104:11: rust2-ffi: this calls `undefined`, which no library wasm32-wasip1's module links defines; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:130:10: rust2-ffi: `std::fs::metadata` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:137:10: rust2-ffi: `std::fs::metadata` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:14:2: rust2-ffi: `std::thread::sleep` reaches `wasi_snapshot_preview1.poll_oneoff`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:151:11: rust2-ffi: the C function `needs_missing` reaches `missing`, which no library wasm32-wasip1's module links defines; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:158:11: rust2-ffi: the C function `needs_data` reaches `missing_data`, which no library wasm32-wasip1's module links defines; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:174:10: rust2-ffi: `std::fs::metadata` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:186:11: rust2-ffi: the module imports `rust2.rust2_spoof`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:18:1: rust2-ffi: the drop of `std::net::TcpListener` reaches `wasi_snapshot_preview1.fd_close`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:198:11: rust2-ffi: the module imports `page.alert`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:203:27: rust2-ffi: `>::into` reaches `__wbindgen_describe`, `__wbindgen_describe_generic_import`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:203:2: rust2-ffi: `web_sys::features::gen_console::console::log_1` reaches `__wbg_log_ff86bbb34c295e21`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:203:39: rust2-ffi: the drop of `wasm_bindgen::JsValue` reaches `__wbindgen_object_drop_ref`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:225:10: rust2-ffi: `std::fs::metadata` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:257:27: rust2-ffi: `>::into` reaches `__wbindgen_describe`, `__wbindgen_describe_generic_import`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:257:2: rust2-ffi: `web_sys::features::gen_console::console::log_1` reaches `__wbg_log_ff86bbb34c295e21`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:257:48: rust2-ffi: the drop of `wasm_bindgen::JsValue` reaches `__wbindgen_object_drop_ref`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:29:25: rust2-ffi: the drop of `std::result::Result<(std::net::TcpStream, std::net::SocketAddr), std::io::Error>` reaches `wasi_snapshot_preview1.fd_close`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:29:3: rust2-ffi: `std::net::TcpListener::accept` reaches `wasi_snapshot_preview1.sock_accept`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:41:3: rust2-ffi: `std::fs::read_to_string` reaches `wasi_snapshot_preview1.fd_close`, `wasi_snapshot_preview1.fd_fdstat_get`, `wasi_snapshot_preview1.fd_filestat_get`, `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.fd_read`, `wasi_snapshot_preview1.path_open`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:52:2: rust2-ffi: `std::fs::metadata` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:62:2: rust2-ffi: `std::fs::exists` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:85:11: rust2-ffi: `std::fs::remove_file` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_unlink_file`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:91:2: rust2-ffi: `std::fs::read_to_string` reaches `wasi_snapshot_preview1.fd_close`, `wasi_snapshot_preview1.fd_fdstat_get`, `wasi_snapshot_preview1.fd_filestat_get`, `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.fd_read`, `wasi_snapshot_preview1.path_open`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config -fixtures/lacks/src/lib.rs:9:2: rust2-ffi: `std::fs::read_to_string` reaches `wasi_snapshot_preview1.fd_close`, `wasi_snapshot_preview1.fd_fdstat_get`, `wasi_snapshot_preview1.fd_filestat_get`, `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.fd_read`, `wasi_snapshot_preview1.path_open`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg`, or exclude its export in the config +fixtures/lacks/src/lib.rs:104:11: rust2-ffi: this calls `undefined`, which no library wasm32-wasip1's module links defines; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:130:10: rust2-ffi: `std::fs::metadata` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:137:10: rust2-ffi: `std::fs::metadata` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:14:2: rust2-ffi: `std::thread::sleep` reaches `wasi_snapshot_preview1.poll_oneoff`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:151:11: rust2-ffi: the C function `needs_missing` reaches `missing`, which no library wasm32-wasip1's module links defines; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:158:11: rust2-ffi: the C function `needs_data` reaches `missing_data`, which no library wasm32-wasip1's module links defines; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:174:10: rust2-ffi: `std::fs::metadata` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:186:11: rust2-ffi: the module imports `rust2.rust2_spoof`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:18:1: rust2-ffi: the drop of `std::net::TcpListener` reaches `wasi_snapshot_preview1.fd_close`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:198:11: rust2-ffi: the module imports `page.alert`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:203:27: rust2-ffi: `>::into` reaches `__wbindgen_describe`, `__wbindgen_describe_generic_import`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:203:2: rust2-ffi: `web_sys::features::gen_console::console::log_1` reaches `__wbg_log_ff86bbb34c295e21`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:203:39: rust2-ffi: the drop of `wasm_bindgen::JsValue` reaches `__wbindgen_object_drop_ref`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:225:10: rust2-ffi: `std::fs::metadata` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:257:27: rust2-ffi: `>::into` reaches `__wbindgen_describe`, `__wbindgen_describe_generic_import`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:257:2: rust2-ffi: `web_sys::features::gen_console::console::log_1` reaches `__wbg_log_ff86bbb34c295e21`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:257:48: rust2-ffi: the drop of `wasm_bindgen::JsValue` reaches `__wbindgen_object_drop_ref`, which wasm-bindgen panics on in wasm32-wasip1 rather than import from JavaScript; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:29:25: rust2-ffi: the drop of `std::result::Result<(std::net::TcpStream, std::net::SocketAddr), std::io::Error>` reaches `wasi_snapshot_preview1.fd_close`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:29:3: rust2-ffi: `std::net::TcpListener::accept` reaches `wasi_snapshot_preview1.sock_accept`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:41:3: rust2-ffi: `std::fs::read_to_string` reaches `wasi_snapshot_preview1.fd_close`, `wasi_snapshot_preview1.fd_fdstat_get`, `wasi_snapshot_preview1.fd_filestat_get`, `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.fd_read`, `wasi_snapshot_preview1.path_open`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:52:2: rust2-ffi: `std::fs::metadata` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:62:2: rust2-ffi: `std::fs::exists` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_filestat_get`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:85:11: rust2-ffi: `std::fs::remove_file` reaches `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.path_unlink_file`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:91:2: rust2-ffi: `std::fs::read_to_string` reaches `wasi_snapshot_preview1.fd_close`, `wasi_snapshot_preview1.fd_fdstat_get`, `wasi_snapshot_preview1.fd_filestat_get`, `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.fd_read`, `wasi_snapshot_preview1.path_open`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` +fixtures/lacks/src/lib.rs:9:2: rust2-ffi: `std::fs::read_to_string` reaches `wasi_snapshot_preview1.fd_close`, `wasi_snapshot_preview1.fd_fdstat_get`, `wasi_snapshot_preview1.fd_filestat_get`, `wasi_snapshot_preview1.fd_prestat_dir_name`, `wasi_snapshot_preview1.fd_prestat_get`, `wasi_snapshot_preview1.fd_read`, `wasi_snapshot_preview1.path_open`, which the web target's host lacks; leave it out of wasm32-wasip1's build with a `cfg` diff --git a/ffi/fixtures/lacks/ffi.toml b/ffi/fixtures/lacks/ffi.toml deleted file mode 100644 index 7720948f9..000000000 --- a/ffi/fixtures/lacks/ffi.toml +++ /dev/null @@ -1 +0,0 @@ -exclude = [] diff --git a/ffi/fixtures/lock/ffi.toml b/ffi/fixtures/lock/ffi.toml deleted file mode 100644 index fd1aea94b..000000000 --- a/ffi/fixtures/lock/ffi.toml +++ /dev/null @@ -1,2 +0,0 @@ -# Nothing left out. -exclude = [] diff --git a/ffi/fixtures/reject/expected.txt b/ffi/fixtures/reject/expected.txt index 300096844..62040f3c7 100644 --- a/ffi/fixtures/reject/expected.txt +++ b/ffi/fixtures/reject/expected.txt @@ -1,188 +1,186 @@ -fixtures/reject/src/lib.rs:1017:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1023:1: rust2-ffi: cannot export fn `poll_risky`: Poll with no Context or waiter parameter `std::task::Poll<()>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1039:1: rust2-ffi: cannot export fn `poll_loose`: Poll with no Context or waiter parameter `std::task::Poll<()>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1046:1: rust2-ffi: cannot export fn `among`: 3 optional borrowed objects, past the 2 Swift takes, which overloads each with and without it since its optional holds an object only by consuming it; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1052:1: rust2-ffi: cannot export fn `wrapped`: error holding an object Swift cannot copy, as `Swift.Error` requires; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1057:1: rust2-ffi: cannot export fn `sum_pair`: array of an element other than u8 `[u16; 2]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1062:1: rust2-ffi: cannot export fn `empty`: empty array `[u8; 0]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1068:1: rust2-ffi: cannot export enum `Wide`: discriminant outside `i32` `Large = 1099511627776`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:1070:2: note: has this discriminant -fixtures/reject/src/lib.rs:106:1: rust2-ffi: cannot export fn `forever_mut`: 'static borrow `&'static mut [u8]`; &mut of a slice `[u8]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1075:1: rust2-ffi: cannot export enum `Huge`: discriminant outside `i32` `Large = 18446744073709551616`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:1077:2: note: has this discriminant -fixtures/reject/src/lib.rs:1082:1: rust2-ffi: cannot export enum `Top`: discriminant outside `i32` `Large = 340282366920938463463374607431768211455`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:1084:2: note: has this discriminant -fixtures/reject/src/lib.rs:1088:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1093:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1099:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1113:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1119:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1124:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1129:1: rust2-ffi: cannot export fn `trust`: trait object `dyn Trusted`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:1119:1: note: C cannot implement `Trusted`: unsafe trait -fixtures/reject/src/lib.rs:112:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1134:1: rust2-ffi: cannot export fn `hazard`: trait object `dyn Hazard`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:1124:1: note: C cannot implement `Hazard`: unsafe fn `risk` -fixtures/reject/src/lib.rs:1139:1: rust2-ffi: cannot export fn `wide_non_zero`: NonZero `u128`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1161:1: rust2-ffi: cannot export fn `wrap`: returned object that borrows `View<'_>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1166:1: rust2-ffi: cannot export fn `hidden_wrap`: returned object that borrows `impl std::clone::Clone + '_`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1182:1: rust2-ffi: cannot export fn `picked`: closure signature `&'static Mark`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1187:1: rust2-ffi: cannot export fn `maybe_picked`: closure signature `std::option::Option<&'static Mark>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1192:1: rust2-ffi: cannot export fn `hidden_answer`: opaque type `impl std::marker::Copy`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1197:1: rust2-ffi: cannot export fn `hidden_items`: opaque type `impl std::marker::Copy`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:11:1: rust2-ffi: cannot export fn `map`: foreign type `std::collections::HashMap`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1202:1: rust2-ffi: cannot export fn `hidden_option`: opaque type `impl std::clone::Clone`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1207:1: rust2-ffi: cannot export fn `boxed_bytes`: boxed slice of bytes `std::boxed::Box<[u8]>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1212:1: rust2-ffi: cannot export fn `count_later`: iterator of borrows in a future or callback; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1217:1: rust2-ffi: cannot export fn `count_opaques`: generic parameter `std::iter::Iterator`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1222:1: rust2-ffi: cannot export fn `unpin_resolver`: trait object `dyn tls::held::Resolver + std::marker::Unpin`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1227:1: rust2-ffi: cannot export fn `borrowed_resolver`: returned object that borrows `std::sync::Arc<(dyn tls::held::Resolver + 'a)>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1232:1: rust2-ffi: cannot export fn `peek_resolver`: reference to a handle inside a value `std::option::Option>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1237:1: rust2-ffi: cannot export fn `peek_codec`: trait object `dyn tls::held::Codec`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1252:1: rust2-ffi: cannot export fn `pump_pipe`: generic parameter `tls::held::Stream`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1257:1: rust2-ffi: cannot export fn `pump_sink`: generic parameter `tls::held::Sink`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1262:1: rust2-ffi: cannot export fn `widen`: generic parameter `tls::held::Width`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1278:2: rust2-ffi: cannot export method `Counter::try_bump`: `&mut self` of a value returning a Result; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1283:2: rust2-ffi: cannot export method `Counter::bump_later`: `&mut self` of a value in a future; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1288:2: rust2-ffi: cannot export method `Counter::bump_ref`: returned borrow of a value written back `&u8`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:128:1: rust2-ffi: cannot export fn `poll_ready`: Poll with no Context or waiter parameter `std::task::Poll`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1295:1: rust2-ffi: cannot export fn `object_alone`: JObject with no &mut jni::Env; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1300:1: rust2-ffi: cannot export fn `two_envs`: several JNI envs; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1305:1: rust2-ffi: cannot export fn `env_later`: JNI value lent to a future; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1310:1: rust2-ffi: cannot export fn `env_counted`: &mut of a value beside a JNI value; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1316:1: rust2-ffi: cannot export fn `shared_env`: JNI type other than a parameter's &mut Env or JObject `jni::Env<'_>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1321:1: rust2-ffi: cannot export fn `java_string`: JNI type other than a parameter's &mut Env or JObject `jni::objects::JString<'_>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1330:1: rust2-ffi: cannot export fn `visit`: trait object `dyn Visit`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:1326:1: note: C cannot implement `Visit`: JNI value in a callback `&mut jni::Env<'_>` -fixtures/reject/src/lib.rs:1336:1: rust2-ffi: cannot export fn `keep_object`: 'static borrow `jni::objects::JObject<'static>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1341:1: rust2-ffi: cannot export fn `bound_object`: 'static borrow `&mut jni::Env<'a>`; 'static borrow `jni::objects::JObject<'a>`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:1341:21: note: `'a` is `'static`, as a handle outlives every call - fixtures/reject/src/lib.rs:1341:21: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:1365:2: rust2-ffi: cannot export method `Slot::view`: returned object that borrows `SlotView<'_, u8>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1371:2: rust2-ffi: cannot export method `Slot::peek`: returned object that borrows `SlotView<'_, u8>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1423:2: rust2-ffi: cannot export method `Slot::hold`: returned object that borrows `SlotHold<'a>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1431:2: rust2-ffi: cannot export method `Slot::tag`: returned object that borrows `SlotTag<'_>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1436:2: rust2-ffi: cannot export method `Slot::lens`: returned object that borrows `SlotLens<'_>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1441:2: rust2-ffi: cannot export method `Slot::peer`: returned object that borrows `SlotPeer<'_>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:145:2: rust2-ffi: cannot export method `Link::session`: borrowed return that is not Clone `tls::held::Handoff`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1477:1: rust2-ffi: cannot export fn `unit_error`: unit error `std::result::Result<(), ()>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1482:1: rust2-ffi: cannot export fn `unit_error_later`: unit error `std::result::Result`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1513:1: rust2-ffi: cannot export fn `race`: instance holding a foreign future `reject::Either<((), std::pin::Pin + std::marker::Send>>), ((), std::pin::Pin + std::marker::Send>>)>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1521:1: rust2-ffi: cannot export fn `park`: instance holding a foreign future `reject::Parked + std::marker::Send>>>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1527:1: rust2-ffi: cannot export instance `Bits`: union; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1533:1: rust2-ffi: cannot export fn `bits`: refused type `reject::Bits`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1539:1: rust2-ffi: cannot export instance `Tail`: unsized type; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1542:1: rust2-ffi: cannot export fn `tail`: 'static borrow `&'static Tail`; refused type `reject::Tail`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:162:1: rust2-ffi: cannot export fn `measure`: foreign type `tls::held::Local`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:167:1: rust2-ffi: cannot export instance `Cell>`: type argument `std::vec::Vec`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:167:1: rust2-ffi: cannot export instance `Cell`: type argument `tls::held::Cert`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:16:1: rust2-ffi: cannot export fn `generic`: generic parameter `std::marker::Copy`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:170:1: rust2-ffi: cannot export fn `sealed`: refused type `reject::Cell`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:199:1: rust2-ffi: cannot export fn `echo`: borrowing output of a future from a function that is not async `&str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:204:1: rust2-ffi: cannot export fn `blame`: borrowing output of a future from a function that is not async `std::result::Result>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:209:1: rust2-ffi: cannot export fn `relay`: borrowing output of a future from a function that is not async `&str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:214:1: rust2-ffi: cannot export fn `resolve`: borrowing output of a future from a function that is not async `&str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:219:1: rust2-ffi: cannot export fn `spend`: closure signature `tls::held::Token`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:21:1: rust2-ffi: cannot export fn `nested`: nested Option `std::option::Option>>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:224:1: rust2-ffi: cannot export fn `mint`: closure signature `tls::held::Token`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:234:1: rust2-ffi: cannot export fn `spent`: reference to a handle inside a value `[tls::held::Token]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:244:1: rust2-ffi: cannot export fn `adopt`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:256:2: rust2-ffi: cannot export method `Cell::nest`: instance holding an instance of a type inside it `reject::Cell>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:275:2: rust2-ffi: cannot export method `Pong>::ping`: instance holding an instance of a type inside it `reject::Ping>>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:286:1: rust2-ffi: cannot export instance `Grow<(u32,)>`: type argument `(u32,)`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:289:2: rust2-ffi: cannot export method `Grow::grow`: refused type `reject::Grow<(u32,)>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:300:1: rust2-ffi: cannot export instance `Shell<(u32,)>`: type argument `(u32,)`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:309:1: rust2-ffi: cannot export fn `shell`: refused type `reject::Shell<(u32,)>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:30:1: rust2-ffi: cannot export fn `peek`: reference to a handle inside a value `std::boxed::Box`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:320:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:325:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:330:1: rust2-ffi: cannot export fn `listed`: refused type `reject::Cell>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:335:1: rust2-ffi: cannot export instance `Fixed<'a'>`: const argument `'a'`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:338:1: rust2-ffi: cannot export fn `fixed`: refused type `reject::Fixed<'a'>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:343:9: rust2-ffi: cannot export use `HashSet`: re-export of the standard library's item `std`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:346:1: rust2-ffi: cannot export fn `lend`: Waker outside a parameter or a return; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:354:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:35:1: rust2-ffi: cannot export static `COUNT`: static; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:364:1: rust2-ffi: cannot export fn `gather`: closure signature `std::vec::Vec`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:369:1: rust2-ffi: cannot export fn `attempt`: closure signature `std::result::Result`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:374:1: rust2-ffi: cannot export fn `consume`: reader not lent as &mut `impl std::io::Read + std::io::Seek`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:379:1: rust2-ffi: cannot export fn `retain`: reader kept past the call `R`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:384:1: rust2-ffi: cannot export fn `rewrite`: reader bound `std::io::Write`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:389:1: rust2-ffi: cannot export fn `read_later`: reader kept past the call `impl std::io::Read + std::io::Seek`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:394:1: rust2-ffi: cannot export fn `twice`: closure bound `std::clone::Clone`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:39:1: rust2-ffi: cannot export macro `noop`: macro; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:400:1: rust2-ffi: cannot export fn `both`: closure type taken twice `F`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:406:1: rust2-ffi: cannot export fn `read`: lent object that borrows `&Text<'_>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:411:1: rust2-ffi: cannot export fn `count_words`: Vec of references `&str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:416:1: rust2-ffi: cannot export fn `count_some`: Vec of references `std::option::Option<&str>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:421:1: rust2-ffi: cannot export fn `count_slice`: slice of references `&str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:426:1: rust2-ffi: cannot export fn `peek_all`: reference to a handle inside a value `[Opaque]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:431:1: rust2-ffi: cannot export fn `none_opaque`: borrowed return that is not Clone `[Opaque]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:443:1: rust2-ffi: cannot export fn `stash`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:458:1: rust2-ffi: cannot export fn `hold`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:463:1: rust2-ffi: cannot export fn `bound`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:468:1: rust2-ffi: cannot export fn `kept`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:47:1: rust2-ffi: cannot export fn `excluded`: excluded type `Excluded`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:482:1: rust2-ffi: cannot export fn `holder`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:496:1: rust2-ffi: cannot export fn `lender`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:511:1: rust2-ffi: cannot export fn `outlived`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:526:1: rust2-ffi: cannot export fn `paired`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:52:1: rust2-ffi: cannot export fn `letters`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:549:1: rust2-ffi: cannot export fn `pinner`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:564:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:556:1: note: applies past the recursion limit -fixtures/reject/src/lib.rs:594:1: rust2-ffi: cannot export fn `call`: ambiguous conversion `std::vec::Vec`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:571:1: note: `std::string::String` converts too, which C passes alike -fixtures/reject/src/lib.rs:599:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:604:1: rust2-ffi: cannot export fn `naturals`: foreign type `std::ops::RangeFrom`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:609:1: rust2-ffi: cannot export fn `opaques`: borrowed return that is not Clone `Opaque`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:614:1: rust2-ffi: cannot export fn `tried`: foreign type `std::vec::IntoIter`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:619:1: rust2-ffi: cannot export fn `eventually`: foreign type `std::vec::IntoIter`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:645:1: rust2-ffi: cannot export fn `tallied`: unmet bound `u32: std::convert::From`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:650:1: rust2-ffi: cannot export fn `drain`: trait object `dyn Source`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:624:1: note: C cannot implement `Source`: callback signature `items` -fixtures/reject/src/lib.rs:655:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:660:1: rust2-ffi: cannot export fn `retext_last`: 'static borrow `&'a [std::string::String]`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:660:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:667:1: rust2-ffi: cannot export fn `outlast`: 'static borrow `&'b [std::string::String]`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:667:20: note: `'b` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:66:2: rust2-ffi: cannot export method `Text::view`: returned object that borrows `Text<'_>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:674:1: rust2-ffi: cannot export fn `retext_into`: 'static borrow `&'a [std::string::String]`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:674:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:683:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:689:1: rust2-ffi: cannot export fn `long_words`: foreign type `std::iter::Filter`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:695:1: rust2-ffi: cannot export fn `kept_in`: foreign type `std::iter::Filter`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:6:1: rust2-ffi: cannot export fn `pair`: tuple of references `(&str, u8)`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:712:1: rust2-ffi: cannot export fn `launched`: foreign type `std::iter::Chain`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:729:1: rust2-ffi: cannot export fn `launches`: foreign type `std::iter::Flatten`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:752:1: rust2-ffi: cannot export fn `pumped`: foreign type `std::iter::Flatten`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:766:1: rust2-ffi: cannot export fn `skipped`: foreign type `std::iter::Skip`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:771:1: rust2-ffi: cannot export fn `merged`: foreign type `std::iter::Copied`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:778:1: rust2-ffi: cannot export fn `values`: foreign type `std::collections::btree_map::IntoValues`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:77:1: rust2-ffi: cannot export fn `first`: borrowed return that is not Clone `Opaque`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:784:1: rust2-ffi: cannot export fn `floats`: collection not built from its items `std::collections::BTreeSet`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:789:1: rust2-ffi: cannot export fn `zeros`: foreign type `std::iter::RepeatN`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:794:1: rust2-ffi: cannot export fn `successes`: foreign type `std::iter::Flatten`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:814:1: rust2-ffi: cannot export fn `allocated`: foreign type `std::vec::IntoIter`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:821:1: rust2-ffi: cannot export fn `flattened`: foreign type `std::iter::Flatten`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:845:1: rust2-ffi: cannot export fn `lent`: foreign type `std::vec::IntoIter`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:863:1: rust2-ffi: cannot export fn `halves`: foreign type `std::str::Split`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:868:1: rust2-ffi: cannot export fn `settled`: Poll with no Context or waiter parameter `std::task::Poll`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:873:1: rust2-ffi: cannot export fn `poll_named`: poll's parameter taken by value that is not Copy `std::string::String`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:879:1: rust2-ffi: cannot export fn `poll_first`: borrowed Poll `&u8`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:885:1: rust2-ffi: cannot export fn `poll_until`: poll's parameter taken by value that is not Copy `impl Fn(u8) -> bool`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:896:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:915:1: rust2-ffi: cannot export fn `poll_ticket`: Poll with no Context or waiter parameter `std::task::Poll`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:920:1: rust2-ffi: cannot export fn `poll_both`: several task parameters; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:927:1: rust2-ffi: cannot export fn `poll_bump`: &mut of a value in a future; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:934:1: rust2-ffi: cannot export fn `peek_some`: reference to a handle inside a value `std::boxed::Box`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:939:1: rust2-ffi: cannot export fn `bump_some`: &mut of a value inside an Option `std::option::Option<&mut u32>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:946:1: rust2-ffi: cannot export fn `rest`: returned borrow of a value written back `&[u8]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:951:1: rust2-ffi: cannot export fn `fill`: returned borrow of a value written back `impl std::future::Future`; &mut of a value in a future; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:956:1: rust2-ffi: cannot export fn `zero`: &mut of a slice `[u8]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:961:1: rust2-ffi: cannot export fn `reseat`: &mut of another crate's Arc `std::sync::Arc`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:974:2: rust2-ffi: cannot export method `Keeper::check`: borrowed return that is not Clone `Opaque`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:985:9: rust2-ffi: cannot export use `dep`: re-export of a whole crate `dep`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:988:9: rust2-ffi: cannot export use `renamed`: re-export of a whole crate `dep`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:999:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:99:2: rust2-ffi: cannot export method `Text::later`: returned object that borrows `impl std::future::Future>`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1001:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value +fixtures/reject/src/lib.rs:1019:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn +fixtures/reject/src/lib.rs:1025:1: rust2-ffi: cannot export fn `poll_risky`: Poll with no Context or waiter parameter `std::task::Poll<()>` +fixtures/reject/src/lib.rs:1041:1: rust2-ffi: cannot export fn `poll_loose`: Poll with no Context or waiter parameter `std::task::Poll<()>` +fixtures/reject/src/lib.rs:1048:1: rust2-ffi: cannot export fn `among`: 3 optional borrowed objects, past the 2 Swift takes, which overloads each with and without it since its optional holds an object only by consuming it +fixtures/reject/src/lib.rs:1054:1: rust2-ffi: cannot export fn `wrapped`: error holding an object Swift cannot copy, as `Swift.Error` requires +fixtures/reject/src/lib.rs:1059:1: rust2-ffi: cannot export fn `sum_pair`: array of an element other than u8 `[u16; 2]` +fixtures/reject/src/lib.rs:1064:1: rust2-ffi: cannot export fn `empty`: empty array `[u8; 0]` +fixtures/reject/src/lib.rs:106:1: rust2-ffi: cannot export fn `forever_mut`: 'static borrow `&'static mut [u8]`; &mut of a slice `[u8]` +fixtures/reject/src/lib.rs:1070:1: rust2-ffi: cannot export enum `Wide`: discriminant outside `i32` `Large = 1099511627776` + fixtures/reject/src/lib.rs:1072:2: note: has this discriminant +fixtures/reject/src/lib.rs:1077:1: rust2-ffi: cannot export enum `Huge`: discriminant outside `i32` `Large = 18446744073709551616` + fixtures/reject/src/lib.rs:1079:2: note: has this discriminant +fixtures/reject/src/lib.rs:1084:1: rust2-ffi: cannot export enum `Top`: discriminant outside `i32` `Large = 340282366920938463463374607431768211455` + fixtures/reject/src/lib.rs:1086:2: note: has this discriminant +fixtures/reject/src/lib.rs:1090:1: rust2-ffi: cannot export fn `raw`: unsafe fn +fixtures/reject/src/lib.rs:1095:1: rust2-ffi: cannot export fn `sum`: C-variadic function +fixtures/reject/src/lib.rs:1101:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"` +fixtures/reject/src/lib.rs:1115:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn +fixtures/reject/src/lib.rs:1121:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait +fixtures/reject/src/lib.rs:1126:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk` +fixtures/reject/src/lib.rs:112:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>` +fixtures/reject/src/lib.rs:1131:1: rust2-ffi: cannot export fn `trust`: trait object `dyn Trusted` + fixtures/reject/src/lib.rs:1121:1: note: C cannot implement `Trusted`: unsafe trait +fixtures/reject/src/lib.rs:1136:1: rust2-ffi: cannot export fn `hazard`: trait object `dyn Hazard` + fixtures/reject/src/lib.rs:1126:1: note: C cannot implement `Hazard`: unsafe fn `risk` +fixtures/reject/src/lib.rs:1141:1: rust2-ffi: cannot export fn `wide_non_zero`: NonZero `u128` +fixtures/reject/src/lib.rs:1163:1: rust2-ffi: cannot export fn `wrap`: returned object that borrows `View<'_>` +fixtures/reject/src/lib.rs:1168:1: rust2-ffi: cannot export fn `hidden_wrap`: returned object that borrows `impl std::clone::Clone + '_` +fixtures/reject/src/lib.rs:1184:1: rust2-ffi: cannot export fn `picked`: closure signature `&'static Mark` +fixtures/reject/src/lib.rs:1189:1: rust2-ffi: cannot export fn `maybe_picked`: closure signature `std::option::Option<&'static Mark>` +fixtures/reject/src/lib.rs:1194:1: rust2-ffi: cannot export fn `hidden_answer`: opaque type `impl std::marker::Copy` +fixtures/reject/src/lib.rs:1199:1: rust2-ffi: cannot export fn `hidden_items`: opaque type `impl std::marker::Copy` +fixtures/reject/src/lib.rs:11:1: rust2-ffi: cannot export fn `map`: foreign type `std::collections::HashMap` +fixtures/reject/src/lib.rs:1204:1: rust2-ffi: cannot export fn `hidden_option`: opaque type `impl std::clone::Clone` +fixtures/reject/src/lib.rs:1209:1: rust2-ffi: cannot export fn `boxed_bytes`: boxed slice of bytes `std::boxed::Box<[u8]>` +fixtures/reject/src/lib.rs:1214:1: rust2-ffi: cannot export fn `count_later`: iterator of borrows in a future or callback +fixtures/reject/src/lib.rs:1219:1: rust2-ffi: cannot export fn `count_opaques`: generic parameter `std::iter::Iterator` +fixtures/reject/src/lib.rs:1224:1: rust2-ffi: cannot export fn `unpin_resolver`: trait object `dyn tls::held::Resolver + std::marker::Unpin` +fixtures/reject/src/lib.rs:1229:1: rust2-ffi: cannot export fn `borrowed_resolver`: returned object that borrows `std::sync::Arc<(dyn tls::held::Resolver + 'a)>` +fixtures/reject/src/lib.rs:1234:1: rust2-ffi: cannot export fn `peek_resolver`: reference to a handle inside a value `std::option::Option>` +fixtures/reject/src/lib.rs:1239:1: rust2-ffi: cannot export fn `peek_codec`: trait object `dyn tls::held::Codec` +fixtures/reject/src/lib.rs:1254:1: rust2-ffi: cannot export fn `pump_pipe`: generic parameter `tls::held::Stream` +fixtures/reject/src/lib.rs:1259:1: rust2-ffi: cannot export fn `pump_sink`: generic parameter `tls::held::Sink` +fixtures/reject/src/lib.rs:1264:1: rust2-ffi: cannot export fn `widen`: generic parameter `tls::held::Width` +fixtures/reject/src/lib.rs:1280:2: rust2-ffi: cannot export method `Counter::try_bump`: `&mut self` of a value returning a Result +fixtures/reject/src/lib.rs:1285:2: rust2-ffi: cannot export method `Counter::bump_later`: `&mut self` of a value in a future +fixtures/reject/src/lib.rs:128:1: rust2-ffi: cannot export fn `poll_ready`: Poll with no Context or waiter parameter `std::task::Poll` +fixtures/reject/src/lib.rs:1290:2: rust2-ffi: cannot export method `Counter::bump_ref`: returned borrow of a value written back `&u8` +fixtures/reject/src/lib.rs:1297:1: rust2-ffi: cannot export fn `object_alone`: JObject with no &mut jni::Env +fixtures/reject/src/lib.rs:1302:1: rust2-ffi: cannot export fn `two_envs`: several JNI envs +fixtures/reject/src/lib.rs:1307:1: rust2-ffi: cannot export fn `env_later`: JNI value lent to a future +fixtures/reject/src/lib.rs:1312:1: rust2-ffi: cannot export fn `env_counted`: &mut of a value beside a JNI value +fixtures/reject/src/lib.rs:1318:1: rust2-ffi: cannot export fn `shared_env`: JNI type other than a parameter's &mut Env or JObject `jni::Env<'_>` +fixtures/reject/src/lib.rs:1323:1: rust2-ffi: cannot export fn `java_string`: JNI type other than a parameter's &mut Env or JObject `jni::objects::JString<'_>` +fixtures/reject/src/lib.rs:1332:1: rust2-ffi: cannot export fn `visit`: trait object `dyn Visit` + fixtures/reject/src/lib.rs:1328:1: note: C cannot implement `Visit`: JNI value in a callback `&mut jni::Env<'_>` +fixtures/reject/src/lib.rs:1338:1: rust2-ffi: cannot export fn `keep_object`: 'static borrow `jni::objects::JObject<'static>` +fixtures/reject/src/lib.rs:1343:1: rust2-ffi: cannot export fn `bound_object`: 'static borrow `&mut jni::Env<'a>`; 'static borrow `jni::objects::JObject<'a>` + fixtures/reject/src/lib.rs:1343:21: note: `'a` is `'static`, as a handle outlives every call + fixtures/reject/src/lib.rs:1343:21: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:1367:2: rust2-ffi: cannot export method `Slot::view`: returned object that borrows `SlotView<'_, u8>` +fixtures/reject/src/lib.rs:1373:2: rust2-ffi: cannot export method `Slot::peek`: returned object that borrows `SlotView<'_, u8>` +fixtures/reject/src/lib.rs:1425:2: rust2-ffi: cannot export method `Slot::hold`: returned object that borrows `SlotHold<'a>` +fixtures/reject/src/lib.rs:1433:2: rust2-ffi: cannot export method `Slot::tag`: returned object that borrows `SlotTag<'_>` +fixtures/reject/src/lib.rs:1438:2: rust2-ffi: cannot export method `Slot::lens`: returned object that borrows `SlotLens<'_>` +fixtures/reject/src/lib.rs:1443:2: rust2-ffi: cannot export method `Slot::peer`: returned object that borrows `SlotPeer<'_>` +fixtures/reject/src/lib.rs:145:2: rust2-ffi: cannot export method `Link::session`: borrowed return that is not Clone `tls::held::Handoff` +fixtures/reject/src/lib.rs:1479:1: rust2-ffi: cannot export fn `unit_error`: unit error `std::result::Result<(), ()>` +fixtures/reject/src/lib.rs:1484:1: rust2-ffi: cannot export fn `unit_error_later`: unit error `std::result::Result` +fixtures/reject/src/lib.rs:1515:1: rust2-ffi: cannot export fn `race`: instance holding a foreign future `reject::Either<((), std::pin::Pin + std::marker::Send>>), ((), std::pin::Pin + std::marker::Send>>)>` +fixtures/reject/src/lib.rs:1523:1: rust2-ffi: cannot export fn `park`: instance holding a foreign future `reject::Parked + std::marker::Send>>>` +fixtures/reject/src/lib.rs:1529:1: rust2-ffi: cannot export instance `Bits`: union +fixtures/reject/src/lib.rs:1535:1: rust2-ffi: cannot export fn `bits`: refused type `reject::Bits` +fixtures/reject/src/lib.rs:1541:1: rust2-ffi: cannot export instance `Tail`: unsized type +fixtures/reject/src/lib.rs:1544:1: rust2-ffi: cannot export fn `tail`: 'static borrow `&'static Tail`; refused type `reject::Tail` +fixtures/reject/src/lib.rs:162:1: rust2-ffi: cannot export fn `measure`: foreign type `tls::held::Local` +fixtures/reject/src/lib.rs:167:1: rust2-ffi: cannot export instance `Cell>`: type argument `std::vec::Vec` +fixtures/reject/src/lib.rs:167:1: rust2-ffi: cannot export instance `Cell`: type argument `tls::held::Cert` +fixtures/reject/src/lib.rs:16:1: rust2-ffi: cannot export fn `generic`: generic parameter `std::marker::Copy` +fixtures/reject/src/lib.rs:170:1: rust2-ffi: cannot export fn `sealed`: refused type `reject::Cell` +fixtures/reject/src/lib.rs:199:1: rust2-ffi: cannot export fn `echo`: borrowing output of a future from a function that is not async `&str` +fixtures/reject/src/lib.rs:204:1: rust2-ffi: cannot export fn `blame`: borrowing output of a future from a function that is not async `std::result::Result>` +fixtures/reject/src/lib.rs:209:1: rust2-ffi: cannot export fn `relay`: borrowing output of a future from a function that is not async `&str` +fixtures/reject/src/lib.rs:214:1: rust2-ffi: cannot export fn `resolve`: borrowing output of a future from a function that is not async `&str` +fixtures/reject/src/lib.rs:219:1: rust2-ffi: cannot export fn `spend`: closure signature `tls::held::Token` +fixtures/reject/src/lib.rs:21:1: rust2-ffi: cannot export fn `nested`: nested Option `std::option::Option>>` +fixtures/reject/src/lib.rs:224:1: rust2-ffi: cannot export fn `mint`: closure signature `tls::held::Token` +fixtures/reject/src/lib.rs:234:1: rust2-ffi: cannot export fn `spent`: reference to a handle inside a value `[tls::held::Token]` +fixtures/reject/src/lib.rs:244:1: rust2-ffi: cannot export fn `adopt`: generic parameter `std::convert::Into` +fixtures/reject/src/lib.rs:256:2: rust2-ffi: cannot export method `Cell::nest`: instance holding an instance of a type inside it `reject::Cell>` +fixtures/reject/src/lib.rs:275:2: rust2-ffi: cannot export method `Pong>::ping`: instance holding an instance of a type inside it `reject::Ping>>` +fixtures/reject/src/lib.rs:286:1: rust2-ffi: cannot export instance `Grow<(u32,)>`: type argument `(u32,)` +fixtures/reject/src/lib.rs:289:2: rust2-ffi: cannot export method `Grow::grow`: refused type `reject::Grow<(u32,)>` +fixtures/reject/src/lib.rs:300:1: rust2-ffi: cannot export instance `Shell<(u32,)>`: type argument `(u32,)` +fixtures/reject/src/lib.rs:309:1: rust2-ffi: cannot export fn `shell`: refused type `reject::Shell<(u32,)>` +fixtures/reject/src/lib.rs:30:1: rust2-ffi: cannot export fn `peek`: reference to a handle inside a value `std::boxed::Box` +fixtures/reject/src/lib.rs:320:1: rust2-ffi: cannot export fn `probe`: const generic `N` +fixtures/reject/src/lib.rs:325:1: rust2-ffi: cannot export fn `listed`: refused type `reject::Cell>` +fixtures/reject/src/lib.rs:330:1: rust2-ffi: cannot export instance `Fixed<'a'>`: const argument `'a'` +fixtures/reject/src/lib.rs:333:1: rust2-ffi: cannot export fn `fixed`: refused type `reject::Fixed<'a'>` +fixtures/reject/src/lib.rs:338:9: rust2-ffi: cannot export use `HashSet`: re-export of the standard library's item `std` +fixtures/reject/src/lib.rs:341:1: rust2-ffi: cannot export fn `lend`: Waker outside a parameter or a return +fixtures/reject/src/lib.rs:359:1: rust2-ffi: cannot export fn `gather`: closure signature `std::vec::Vec` +fixtures/reject/src/lib.rs:35:1: rust2-ffi: cannot export static `COUNT`: static +fixtures/reject/src/lib.rs:364:1: rust2-ffi: cannot export fn `attempt`: closure signature `std::result::Result` +fixtures/reject/src/lib.rs:369:1: rust2-ffi: cannot export fn `consume`: reader not lent as &mut `impl std::io::Read + std::io::Seek` +fixtures/reject/src/lib.rs:374:1: rust2-ffi: cannot export fn `retain`: reader kept past the call `R` +fixtures/reject/src/lib.rs:379:1: rust2-ffi: cannot export fn `rewrite`: reader bound `std::io::Write` +fixtures/reject/src/lib.rs:384:1: rust2-ffi: cannot export fn `read_later`: reader kept past the call `impl std::io::Read + std::io::Seek` +fixtures/reject/src/lib.rs:389:1: rust2-ffi: cannot export fn `twice`: closure bound `std::clone::Clone` +fixtures/reject/src/lib.rs:395:1: rust2-ffi: cannot export fn `both`: closure type taken twice `F` +fixtures/reject/src/lib.rs:39:1: rust2-ffi: cannot export macro `noop`: macro +fixtures/reject/src/lib.rs:401:1: rust2-ffi: cannot export fn `read`: lent object that borrows `&Text<'_>` +fixtures/reject/src/lib.rs:406:1: rust2-ffi: cannot export fn `count_words`: Vec of references `&str` +fixtures/reject/src/lib.rs:411:1: rust2-ffi: cannot export fn `count_some`: Vec of references `std::option::Option<&str>` +fixtures/reject/src/lib.rs:416:1: rust2-ffi: cannot export fn `count_slice`: slice of references `&str` +fixtures/reject/src/lib.rs:421:1: rust2-ffi: cannot export fn `peek_all`: reference to a handle inside a value `[Opaque]` +fixtures/reject/src/lib.rs:426:1: rust2-ffi: cannot export fn `none_opaque`: borrowed return that is not Clone `[Opaque]` +fixtures/reject/src/lib.rs:438:1: rust2-ffi: cannot export fn `stash`: generic parameter `std::convert::Into` +fixtures/reject/src/lib.rs:454:1: rust2-ffi: cannot export fn `hold`: generic parameter `std::convert::Into` +fixtures/reject/src/lib.rs:459:1: rust2-ffi: cannot export fn `bound`: generic parameter `std::convert::Into` +fixtures/reject/src/lib.rs:464:1: rust2-ffi: cannot export fn `kept`: generic parameter `std::convert::Into` +fixtures/reject/src/lib.rs:479:1: rust2-ffi: cannot export fn `holder`: generic parameter `std::convert::Into` +fixtures/reject/src/lib.rs:47:1: rust2-ffi: cannot export fn `excluded`: doc(hidden) type `Excluded` +fixtures/reject/src/lib.rs:494:1: rust2-ffi: cannot export fn `lender`: generic parameter `std::convert::Into` +fixtures/reject/src/lib.rs:510:1: rust2-ffi: cannot export fn `outlived`: generic parameter `std::convert::Into` +fixtures/reject/src/lib.rs:526:1: rust2-ffi: cannot export fn `paired`: generic parameter `std::convert::Into` +fixtures/reject/src/lib.rs:52:1: rust2-ffi: cannot export fn `letters`: Range `char` +fixtures/reject/src/lib.rs:551:1: rust2-ffi: cannot export fn `pinner`: generic parameter `std::convert::Into` +fixtures/reject/src/lib.rs:567:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows` + fixtures/reject/src/lib.rs:559:1: note: applies past the recursion limit +fixtures/reject/src/lib.rs:599:1: rust2-ffi: cannot export fn `call`: ambiguous conversion `std::vec::Vec` + fixtures/reject/src/lib.rs:575:1: note: `std::string::String` converts too, which C passes alike +fixtures/reject/src/lib.rs:604:1: rust2-ffi: cannot export fn `alphabet`: Range `char` +fixtures/reject/src/lib.rs:609:1: rust2-ffi: cannot export fn `naturals`: foreign type `std::ops::RangeFrom` +fixtures/reject/src/lib.rs:614:1: rust2-ffi: cannot export fn `opaques`: borrowed return that is not Clone `Opaque` +fixtures/reject/src/lib.rs:619:1: rust2-ffi: cannot export fn `tried`: foreign type `std::vec::IntoIter` +fixtures/reject/src/lib.rs:624:1: rust2-ffi: cannot export fn `eventually`: foreign type `std::vec::IntoIter` +fixtures/reject/src/lib.rs:650:1: rust2-ffi: cannot export fn `tallied`: unmet bound `u32: std::convert::From` +fixtures/reject/src/lib.rs:655:1: rust2-ffi: cannot export fn `drain`: trait object `dyn Source` + fixtures/reject/src/lib.rs:629:1: note: C cannot implement `Source`: callback signature `items` +fixtures/reject/src/lib.rs:660:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]` +fixtures/reject/src/lib.rs:665:1: rust2-ffi: cannot export fn `retext_last`: 'static borrow `&'a [std::string::String]` + fixtures/reject/src/lib.rs:665:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:66:2: rust2-ffi: cannot export method `Text::view`: returned object that borrows `Text<'_>` +fixtures/reject/src/lib.rs:672:1: rust2-ffi: cannot export fn `outlast`: 'static borrow `&'b [std::string::String]` + fixtures/reject/src/lib.rs:672:20: note: `'b` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:679:1: rust2-ffi: cannot export fn `retext_into`: 'static borrow `&'a [std::string::String]` + fixtures/reject/src/lib.rs:679:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:688:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat` +fixtures/reject/src/lib.rs:694:1: rust2-ffi: cannot export fn `long_words`: foreign type `std::iter::Filter` +fixtures/reject/src/lib.rs:6:1: rust2-ffi: cannot export fn `pair`: tuple of references `(&str, u8)` +fixtures/reject/src/lib.rs:700:1: rust2-ffi: cannot export fn `kept_in`: foreign type `std::iter::Filter` +fixtures/reject/src/lib.rs:717:1: rust2-ffi: cannot export fn `launched`: foreign type `std::iter::Chain` +fixtures/reject/src/lib.rs:734:1: rust2-ffi: cannot export fn `launches`: foreign type `std::iter::Flatten` +fixtures/reject/src/lib.rs:757:1: rust2-ffi: cannot export fn `pumped`: foreign type `std::iter::Flatten` +fixtures/reject/src/lib.rs:771:1: rust2-ffi: cannot export fn `skipped`: foreign type `std::iter::Skip` +fixtures/reject/src/lib.rs:776:1: rust2-ffi: cannot export fn `merged`: foreign type `std::iter::Copied` +fixtures/reject/src/lib.rs:77:1: rust2-ffi: cannot export fn `first`: borrowed return that is not Clone `Opaque` +fixtures/reject/src/lib.rs:783:1: rust2-ffi: cannot export fn `values`: foreign type `std::collections::btree_map::IntoValues` +fixtures/reject/src/lib.rs:789:1: rust2-ffi: cannot export fn `floats`: collection not built from its items `std::collections::BTreeSet` +fixtures/reject/src/lib.rs:794:1: rust2-ffi: cannot export fn `zeros`: foreign type `std::iter::RepeatN` +fixtures/reject/src/lib.rs:799:1: rust2-ffi: cannot export fn `successes`: foreign type `std::iter::Flatten` +fixtures/reject/src/lib.rs:819:1: rust2-ffi: cannot export fn `allocated`: foreign type `std::vec::IntoIter` +fixtures/reject/src/lib.rs:826:1: rust2-ffi: cannot export fn `flattened`: foreign type `std::iter::Flatten` +fixtures/reject/src/lib.rs:850:1: rust2-ffi: cannot export fn `lent`: foreign type `std::vec::IntoIter` +fixtures/reject/src/lib.rs:868:1: rust2-ffi: cannot export fn `halves`: foreign type `std::str::Split` +fixtures/reject/src/lib.rs:873:1: rust2-ffi: cannot export fn `settled`: Poll with no Context or waiter parameter `std::task::Poll` +fixtures/reject/src/lib.rs:878:1: rust2-ffi: cannot export fn `poll_named`: poll's parameter taken by value that is not Copy `std::string::String` +fixtures/reject/src/lib.rs:884:1: rust2-ffi: cannot export fn `poll_first`: borrowed Poll `&u8` +fixtures/reject/src/lib.rs:890:1: rust2-ffi: cannot export fn `poll_until`: poll's parameter taken by value that is not Copy `impl Fn(u8) -> bool` +fixtures/reject/src/lib.rs:901:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future +fixtures/reject/src/lib.rs:920:1: rust2-ffi: cannot export fn `poll_ticket`: Poll with no Context or waiter parameter `std::task::Poll` +fixtures/reject/src/lib.rs:925:1: rust2-ffi: cannot export fn `poll_both`: several task parameters +fixtures/reject/src/lib.rs:932:1: rust2-ffi: cannot export fn `poll_bump`: &mut of a value in a future +fixtures/reject/src/lib.rs:939:1: rust2-ffi: cannot export fn `peek_some`: reference to a handle inside a value `std::boxed::Box` +fixtures/reject/src/lib.rs:944:1: rust2-ffi: cannot export fn `bump_some`: &mut of a value inside an Option `std::option::Option<&mut u32>` +fixtures/reject/src/lib.rs:951:1: rust2-ffi: cannot export fn `rest`: returned borrow of a value written back `&[u8]` +fixtures/reject/src/lib.rs:956:1: rust2-ffi: cannot export fn `fill`: returned borrow of a value written back `impl std::future::Future`; &mut of a value in a future +fixtures/reject/src/lib.rs:961:1: rust2-ffi: cannot export fn `zero`: &mut of a slice `[u8]` +fixtures/reject/src/lib.rs:966:1: rust2-ffi: cannot export fn `reseat`: &mut of another crate's Arc `std::sync::Arc` +fixtures/reject/src/lib.rs:979:2: rust2-ffi: cannot export method `Keeper::check`: borrowed return that is not Clone `Opaque` +fixtures/reject/src/lib.rs:990:9: rust2-ffi: cannot export use `dep`: re-export of a whole crate `dep` +fixtures/reject/src/lib.rs:993:9: rust2-ffi: cannot export use `renamed`: re-export of a whole crate `dep` +fixtures/reject/src/lib.rs:99:2: rust2-ffi: cannot export method `Text::later`: returned object that borrows `impl std::future::Future>` diff --git a/ffi/fixtures/reject/ffi.toml b/ffi/fixtures/reject/ffi.toml deleted file mode 100644 index 9c8903fdc..000000000 --- a/ffi/fixtures/reject/ffi.toml +++ /dev/null @@ -1,2 +0,0 @@ -# An exclusion leaves an item or an instance out, so nothing refuses it. -exclude = ["Called", "Caller", "Cell", "Excluded", "Grows", "Held", "Holder", "Lender", "Outlived", "Paired", "Pinned", "Pinner", "Shed"] diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index 60d5ca8bc..84b221d7f 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -40,8 +40,8 @@ macro_rules! noop { () => {}; } -/// Left out by the config, so it refuses nothing itself, but a signature naming it is -/// refused. +/// Hidden, so it refuses nothing itself, but a signature naming it is refused. +#[doc(hidden)] pub struct Excluded; pub fn excluded() -> Excluded { @@ -321,11 +321,6 @@ pub fn probe(x: impl Into>) { let _ = x; } -/// An instance the config excludes. -pub fn excluded_cell(cell: Cell) -> u16 { - cell.0 -} - /// An instance whose type argument is no value or handle, so it cannot name it. pub fn listed(cell: Cell>) -> usize { cell.0.len() @@ -445,7 +440,8 @@ pub fn stash(value: impl Into) -> u32 { 0 } -/// Excluded, borrowing what it converts from. +/// Hidden, borrowing what it converts from. +#[doc(hidden)] pub struct Held<'a>(pub &'a u32); impl<'a> From<&'a u32> for Held<'a> { @@ -469,7 +465,8 @@ pub fn kept<'a>(value: impl Into> + 'static) -> u32 { *value.into().0 } -/// Excluded, what converts into a `Held<'static>`. +/// Hidden, what converts into a `Held<'static>`. +#[doc(hidden)] pub struct Holder(pub Held<'static>); impl>> From for Holder { @@ -483,7 +480,8 @@ pub fn holder(value: impl Into) -> u32 { *value.into().0.0 } -/// Excluded, what converts into a `Held<'a>`, at the lifetime the parameter names. +/// Hidden, what converts into a `Held<'a>`, at the lifetime the parameter names. +#[doc(hidden)] pub struct Lender<'a>(pub Held<'a>); impl<'a, T: Into>> From for Lender<'a> { @@ -497,7 +495,8 @@ pub fn lender(value: impl Into>) -> u32 { *value.into().0.0 } -/// Excluded, what converts into a `Held<'b>` for a `'b` that outlives its own `'a`. +/// Hidden, what converts into a `Held<'b>` for a `'b` that outlives its own `'a`. +#[doc(hidden)] pub struct Outlived<'a>(pub Held<'a>); impl<'a, 'b: 'a, T: Into>> From for Outlived<'a> { @@ -512,7 +511,8 @@ pub fn outlived(value: impl Into>) -> u32 { *value.into().0.0 } -/// Excluded, two lifetimes, what converts into a `Held` for the second converting into it. +/// Hidden, two lifetimes, what converts into a `Held` for the second converting into it. +#[doc(hidden)] pub struct Paired<'a, 'b>(pub &'a u32, pub Held<'b>); impl<'a, 'b, T: Into>> From for Paired<'a, 'b> { @@ -527,7 +527,8 @@ pub fn paired(value: impl Into>) -> u32 { *value.into().1.0 } -/// Excluded, a `'static` borrow, from what converts into one. +/// Hidden, a `'static` borrow, from what converts into one. +#[doc(hidden)] pub struct Pinned(pub &'static u32); impl> From for Pinned { @@ -536,7 +537,8 @@ impl> From for Pinned { } } -/// Excluded, what converts into a `Pinned`. +/// Hidden, what converts into a `Pinned`. +#[doc(hidden)] pub struct Pinner(pub Pinned); impl> From for Pinner { @@ -550,7 +552,8 @@ pub fn pinner(value: impl Into) -> u32 { *value.into().0.0 } -/// Excluded, what converts into one of a `Vec` of its type, and so into ever larger ones. +/// Hidden, what converts into one of a `Vec` of its type, and so into ever larger ones. +#[doc(hidden)] pub struct Grows(pub Vec); impl>> + Copy> From for Grows { @@ -565,7 +568,8 @@ pub fn grows(value: impl Into>) -> usize { value.into().0.len() } -/// Excluded, a name from a string, or from bytes that need not be UTF-8. +/// Hidden, a name from a string, or from bytes that need not be UTF-8. +#[doc(hidden)] pub struct Called(pub String); impl From for Called { @@ -580,7 +584,8 @@ impl From> for Called { } } -/// Excluded, what converts into a name. +/// Hidden, what converts into a name. +#[doc(hidden)] pub struct Caller(pub Called); impl> From for Caller { @@ -987,9 +992,6 @@ pub use dep; /// The same crate whole, by another name. pub use ::dep as renamed; -/// A crate whole, which the config excludes, so nothing refuses it. -pub use ::dep as Shed; - /// A value whose poll changes it, which C passes as a copy. pub struct Tally { pub count: u8, diff --git a/ffi/justfile b/ffi/justfile index 9ffd4710a..69467c0ba 100644 --- a/ffi/justfile +++ b/ffi/justfile @@ -72,7 +72,7 @@ fix: cargo shear --fix cargo sort --workspace --no-format -# Run the exporter: `just ffi run --config --out `. +# Run the exporter: `just ffi run --manifest-path --out `. run *args: cargo run --locked --quiet -- {{ args }} @@ -90,16 +90,16 @@ surface *flags: (moq-write "") (standin "" "web") exit 1 fi # The api fixture as its tests export it, with wasm32 for the web binding. - cargo run --locked --quiet -- --config fixtures/api/ffi.toml --out target/surface/api --target x86_64-unknown-linux-gnu --target wasm32-wasip1 -- --features doubled - cargo run --locked --quiet -- --config moq/web.toml --manifest-path target/moq-ffi-web/Cargo.toml --target wasm32-wasip1 --out target/surface/moq-web + cargo run --locked --quiet -- --manifest-path fixtures/api/Cargo.toml --out target/surface/api --target x86_64-unknown-linux-gnu --target wasm32-wasip1 -- --features doubled + cargo run --locked --quiet -- --manifest-path target/moq-ffi-web/Cargo.toml --target wasm32-wasip1 --out target/surface/moq-web python3 -I surface/surface.py {{ flags }} target/surface/api surface/api python3 -I surface/surface.py {{ flags }} target/export/moq surface/moq # Its other bindings are moq's on wasm32, which no one ships. python3 -I surface/surface.py {{ flags }} target/surface/moq-web surface/moq-web web.d.ts -# 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 the stand-in facade into target/census/moq-ffi.md, from the pinned moq revision or a checkout. census checkout="": (standin checkout) - cargo run --locked --quiet -- --config moq/ffi.toml --manifest-path target/moq-ffi/Cargo.toml --census target/census + cargo run --locked --quiet -- --manifest-path target/moq-ffi/Cargo.toml --census target/census # Measure the binding benchmark (bench/ffi/README.md) from the pinned moq revision or a checkout, in the bench shell: nix develop .#bench. Its tables go to target/bench/report.md. bench checkout="": (bench-build checkout) bench-run @@ -215,7 +215,7 @@ bench-run rounds="3": } build() { rm -rf "$scratch" - measure export env "$libpath=$sysroot/lib" target/release/rust2-ffi --config moq/ffi.toml --manifest-path target/moq-ffi/Cargo.toml --out "$scratch/moq" + measure export env "$libpath=$sysroot/lib" target/release/rust2-ffi --manifest-path target/moq-ffi/Cargo.toml --out "$scratch/moq" measure check cargo check --quiet --lib --manifest-path target/moq-ffi/Cargo.toml measure generated cargo build --locked --quiet --release --manifest-path "$scratch/moq/Cargo.toml" --features kotlin,dart measure moq cargo build --quiet --release --lib --manifest-path target/moq-ffi/Cargo.toml @@ -476,7 +476,7 @@ moq-write checkout="": (standin checkout) with+=(--with "$api") done # macOS's bash 3.2 reads an empty array as unset. - cargo run --locked --quiet -- --config moq/ffi.toml --manifest-path target/moq-ffi/Cargo.toml --out target/export/moq ${with[@]+"${with[@]}"} + cargo run --locked --quiet -- --manifest-path target/moq-ffi/Cargo.toml --out target/export/moq ${with[@]+"${with[@]}"} # Sources that changed while the export read them leave it matching neither version. if [ -f target/moq-ffi/source ]; then before=$(cat target/moq-ffi/source) @@ -512,7 +512,7 @@ moq-api target checkout="": (standin checkout) mkdir -p target/moq-api rm -f "target/moq-api/$target.json" "target/moq-api/$target.source" before=$(cat target/moq-ffi/source) - cargo run --locked --quiet -- --config moq/ffi.toml --manifest-path target/moq-ffi/Cargo.toml --target "$target" --api "target/moq-api/$target.json" + cargo run --locked --quiet -- --manifest-path target/moq-ffi/Cargo.toml --target "$target" --api "target/moq-api/$target.json" # Sources that changed while the check read them leave the API matching neither version. {{ quote(just_executable()) }} standin {{ quote(checkout) }} if [ "$before" != "$(cat target/moq-ffi/source)" ]; then @@ -525,7 +525,7 @@ moq-api target checkout="": (standin checkout) # Export the wasm32 stand-in, moq's crates but moq-tokio, into target/export/moq-web for wasm32-wasip1, and build its module for the web binding. [private] moq-web checkout="": (standin checkout "web") - cargo run --locked --quiet -- --config moq/web.toml --manifest-path target/moq-ffi-web/Cargo.toml --target wasm32-wasip1 --out target/export/moq-web + cargo run --locked --quiet -- --manifest-path target/moq-ffi-web/Cargo.toml --target wasm32-wasip1 --out target/export/moq-web cargo build --locked --quiet --release --manifest-path target/export/moq-web/Cargo.toml --target wasm32-wasip1 --features web # Export moq's crates' C ABI into target/export/moq and build it, with the libraries a program linking it needs besides in target/moq-native. diff --git a/ffi/moq/ffi.toml b/ffi/moq/ffi.toml deleted file mode 100644 index c80131259..000000000 --- a/ffi/moq/ffi.toml +++ /dev/null @@ -1,13 +0,0 @@ -# What the export refuses at the pinned revision, by paths from the stand-in facade that -# `just ffi standin` writes, as `just ffi census` lists it: the API a hand-written wrapper -# still has to cover. -exclude = [ - "escape", - "moq_tokio::accept::Failure::classify", - "moq_tokio::accept::Health::failed", - "moq_tokio::tcp::TlsAcceptor::accept", - "rustls::client::Resumption::store", - "rustls::client::danger::DangerousClientConfig::cfg", - "tokio::tls::Serve::resolver", - "unescape", -] diff --git a/ffi/moq/web.toml b/ffi/moq/web.toml deleted file mode 100644 index ed102b460..000000000 --- a/ffi/moq/web.toml +++ /dev/null @@ -1,4 +0,0 @@ -# What the export refuses at the pinned revision of the wasm32 stand-in, which `just ffi -# standin` writes into target/moq-ffi-web: moq/ffi.toml's list, less moq-tokio's items, since -# that facade leaves moq-tokio out, as no wasm32 target builds it. -exclude = ["escape", "mux::container::ts::Mpegts::deserialize", "unescape"] diff --git a/ffi/release/package.py b/ffi/release/package.py index 6bd602175..ce189184a 100644 --- a/ffi/release/package.py +++ b/ffi/release/package.py @@ -1029,15 +1029,10 @@ def consume_python(check, native, module): def exporter(manifest, features, *args): - """Run rust2-ffi from this checkout on the package, with its ffi.toml if it keeps one.""" + """Run rust2-ffi from this checkout on the package.""" manifest = Path(manifest).resolve() - config = manifest.parent / "ffi.toml" - if not config.exists(): - # The exporter still requires a config file; an empty one leaves nothing out. - config = Path(tempfile.mkdtemp()) / "ffi.toml" - config.write_text("", encoding="utf-8") cargo = ["--", "--features", features] if features.strip() else [] - run("cargo", "run", "--locked", "--release", "--quiet", "--", "--config", config, "--manifest-path", manifest, + run("cargo", "run", "--locked", "--release", "--quiet", "--", "--manifest-path", manifest, *args, *cargo, cwd=ROOT / "ffi") diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index bfed7b2b7..e15eacb09 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -280,9 +280,6 @@ struct Collector<'tcx> { range_bounds: Option, /// Objects no export returns, left out. orphans: rustc_data_structures::fx::FxHashSet>, - /// Another crate's types an opaque handle would hold that [`Self::prune`] dropped, as no - /// export names them, so none returns them either. - pruned: Vec, /// Types a signature names that the root does not reach, each exported by its public /// path in its own crate. reach: Vec, @@ -447,7 +444,6 @@ pub(crate) fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected bound, range_bounds, orphans: orphans.clone(), - pruned: Vec::new(), reach: reach.to_vec(), dependencies: facade.crates.clone(), unreached: Default::default(), @@ -2136,11 +2132,6 @@ impl<'tcx> Collector<'tcx> { !self.foreign_value(did) && api.objects[i].opaque.is_some() && !held.contains(&Type::Object(i)) }) .map(|&(def_id, _)| Key { def_id, args: None }); - // One only refused items name, such as a field whose getter is refused for not being - // `Clone`, is no less unheld, which leaves those items out. - let pruned = (self.pruned.iter()) - .map(|&def_id| Key { def_id, args: None }) - .filter(|key| !self.orphans.contains(key)); (self.decls.iter()) .filter_map(|(&key, decl)| match decl { Decl::Object(i) if !held.contains(&Type::Object(*i)) => Some(key), @@ -2148,7 +2139,6 @@ impl<'tcx> Collector<'tcx> { _ => None, }) .chain(opaque) - .chain(pruned) .collect() } @@ -2589,10 +2579,7 @@ impl<'tcx> Collector<'tcx> { true => drop(self.api.records.remove(gone)), false => drop(self.api.objects.remove(gone)), } - let (did, _) = self.foreign.remove(n); - if !value { - self.pruned.push(did); - } + self.foreign.remove(n); let values: Vec = (self.foreign[n..].iter()) .map(|&(did, _)| self.foreign_value(did)) .collect(); @@ -2665,9 +2652,9 @@ impl<'tcx> Collector<'tcx> { let read = Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, held); // A field that is an object but not `Clone` is lent from the receiver's handle, // as a method's borrowed return of one is. - // So is an `Option` of one, as `Some` of the borrow. + // So is an `Option` of one, as `Some` of the borrow, through a `Box` too. let object = match held.kind() { - ty::Adt(adt, args) if tcx.is_diagnostic_item(sym::Option, adt.did()) => args.type_at(0), + ty::Adt(adt, args) if tcx.is_diagnostic_item(sym::Option, adt.did()) => unboxed(args.type_at(0)), _ => held, }; let lends = !self.is_clone(held) @@ -2684,7 +2671,15 @@ impl<'tcx> Collector<'tcx> { None => Ok(None), }; match (get, set) { - (Ok(get), Ok(set)) => Ok((get, set)), + (Ok(get), Ok(set)) => Ok((Some(get), set)), + // A value that has no copy to return and no handle to lend from, as another + // crate's is not, is still written: its getter alone is refused, and the + // setter keeps the type in the API, so one no export returns leaves out + // both. + (Err(get), Ok(Some(set))) if get.construct == "borrowed return that is not Clone" => { + self.refuse(&shown, "field", span, vec![get]); + Ok((None, Some(set))) + } (get, set) => { let mut whys: Vec = get.err().into_iter().collect(); // A type neither way maps is one reason, not two. @@ -2735,10 +2730,12 @@ impl<'tcx> Collector<'tcx> { instance: None, home: Home::default(), }; - let lent = lends && lent(&get); - let mut getter = accessor(Receiver::Ref, Vec::new(), get, false); - getter.lends = lent; - accessors.push(getter); + if let Some(get) = get { + let lent = lends && lent(&get); + let mut getter = accessor(Receiver::Ref, Vec::new(), get, false); + getter.lends = lent; + accessors.push(getter); + } if let Some(set) = set { let value = Param { name: "value".to_string(), @@ -5792,12 +5789,16 @@ impl<'tcx> Collector<'tcx> { // another crate's value, which a handle holds only erased and by value. (Type::Object(_), Pos::Return, Mutability::Not) if self.lending.take() && self.opaque_value(*inner).is_none() => {} - // A borrowed `Option` of one is lent as `Some` of a borrow of it, so C holds the - // handle the bare borrow would be. + // A borrowed `Option` of one, or of a `Box` of one, is lent as `Some` of a borrow + // of it, so C holds the handle the bare borrow would be. (Type::Option(object), Pos::Return, Mutability::Not) - if matches!(**object, Type::Object(_)) + if let Type::Object(_) | Type::Box(_) = &**object + && let object = match &**object { + Type::Box(boxed) => boxed, + _ => object, + } && matches!(**object, Type::Object(_)) && let ty::Adt(_, args) = inner.kind() - && self.opaque_value(args.type_at(0)).is_none() + && self.opaque_value(unboxed(args.type_at(0))).is_none() && self.lending.take() => { return Ok(Type::Option(Box::new(Type::Ref(Mutability::Not, object.clone())))); @@ -6262,6 +6263,14 @@ fn returns(api: &Api, ty: &Type, objects: &mut Vec) { } } +/// What `ty` boxes, if it is a `Box`, else `ty`. +fn unboxed(ty: Ty<'_>) -> Ty<'_> { + match ty.kind() { + ty::Adt(adt, args) if adt.is_box() => args.type_at(0), + _ => ty, + } +} + /// Whether `did` is `std::borrow::Cow`. fn cow(tcx: TyCtxt<'_>, did: DefId) -> bool { tcx.is_diagnostic_item(rustc_span::Symbol::intern("Cow"), did) diff --git a/ffi/tests/api.c b/ffi/tests/api.c index 283cf1114..daa3ccd0e 100644 --- a/ffi/tests/api.c +++ b/ffi/tests/api.c @@ -1900,7 +1900,6 @@ static int script(void) { return 1; } print("json ", api_encode(doc, NULL), "\n"); - print("timed text ", api_timed_text(doc, NULL), "\n"); api_Json *tagged = api_tagged(doc, str("t"), NULL); api_Json_free(doc); print("tagged ", api_Json_to_text(tagged, NULL), "\n"); diff --git a/ffi/tests/api.cpp b/ffi/tests/api.cpp index f8019fd8e..a02faeba5 100644 --- a/ffi/tests/api.cpp +++ b/ffi/tests/api.cpp @@ -1186,7 +1186,6 @@ int script() { api::Json doc = api::Json::parse(R"({"b": [1, 2.5, null], "a": "\u00e9"})").value(); print("json ", api::encode(doc), "\n"); - print("timed text ", api::timed_text(doc), "\n"); api::Json tagged = api::tagged(std::move(doc), "t"); print("tagged ", tagged.to_text(), "\n"); { diff --git a/ffi/tests/api.dart b/ffi/tests/api.dart index fbe1758d9..ed551a67e 100644 --- a/ffi/tests/api.dart +++ b/ffi/tests/api.dart @@ -797,7 +797,6 @@ Future script() async { print('joined $parts ${api.joined([]).length} read ${api.readLen(utf8.encode('hello'))}'); final doc = api.Json.parse('{"b": [1, 2.5, null], "a": "é"}'); print('json ${api.encode(doc)}'); - print('timed text ${api.timedText(doc)}'); final tagged = api.tagged(doc, 't'); print('tagged ${tagged.toText()}'); tagged.close(); diff --git a/ffi/tests/api.go b/ffi/tests/api.go index d944aa4b6..e47b337b0 100644 --- a/ffi/tests/api.go +++ b/ffi/tests/api.go @@ -912,7 +912,6 @@ func script() { fmt.Printf("joined %s %d read %d\n", api.Joined(parts).Copy(), len(api.Joined(nil).Copy()), api.ReadLen(rt.NewBytes([]byte("hello")))) doc := must(serdejson.JsonParse(`{"b": [1, 2.5, null], "a": "é"}`)) fmt.Printf("json %s\n", must(api.Encode(doc))) - fmt.Printf("timed text %s\n", must(api.TimedText(doc))) tagged2 := must(api.Tagged(doc, "t")) fmt.Printf("tagged %s\n", must(tagged2.ToText())) tagged2.Close() diff --git a/ffi/tests/api.kt b/ffi/tests/api.kt index 10879ae71..5b919b99c 100644 --- a/ffi/tests/api.kt +++ b/ffi/tests/api.kt @@ -708,7 +708,6 @@ fun script() { println("joined $parts ${joined(emptyList()).toByteArray().size} read ${readLen(Bytes("hello".encodeToByteArray()))}") val doc = Json.parse("""{"b": [1, 2.5, null], "a": "\u00e9"}""") println("json ${encode(doc)}") - println("timed text ${timedText(doc)}") tagged(doc, "t").use { tagged -> println("tagged ${tagged.toText()}") } // A JSON object's entries cross as pairs of a key and its document, each moved in. val jsonEntries = entries(listOf(Pair("b", Json.parse("[1]")), Pair("a", Json.parse("2"))), "t") diff --git a/ffi/tests/api.py b/ffi/tests/api.py index f935361a4..afdaade06 100644 --- a/ffi/tests/api.py +++ b/ffi/tests/api.py @@ -763,7 +763,6 @@ async def polls(): print(f"joined {joined} {len(api.joined([]))} read {api.read_len(b'hello')}") doc = api.Json.parse('{"b": [1, 2.5, null], "a": "é"}') print(f"json {api.encode(doc)}") - print(f"timed text {api.timed_text(doc)}") tagged = api.tagged(doc, "t") print(f"tagged {tagged.to_text()}") # A JSON object's entries cross as pairs of a key and its document, each moved in. diff --git a/ffi/tests/api.swift b/ffi/tests/api.swift index 2e680c490..07a695c94 100644 --- a/ffi/tests/api.swift +++ b/ffi/tests/api.swift @@ -972,7 +972,6 @@ func script() { print("joined \(parts) \(Api.joined([]).count) read \(readLen(Bytes("hello".utf8)))") let doc = try! Json.parse(#"{"b": [1, 2.5, null], "a": "é"}"#) print("json \(try! encode(doc))") - print("timed text \(try! timedText(doc))") let tagged = try! tagged(doc, "t") print("tagged \(try! tagged.toText())") // A JSON object's entries cross as pairs of a key and its document, each moved in. diff --git a/ffi/tests/api.ts b/ffi/tests/api.ts index 4a81f479b..26936212c 100644 --- a/ffi/tests/api.ts +++ b/ffi/tests/api.ts @@ -989,7 +989,6 @@ async function script(): Promise { print(`joined ${parts} ${api.joined([]).length} read ${dec(api.readLen(enc("hello")))}`); const doc = unwrap(Json.parse('{"b": [1, 2.5, null], "a": "é"}')); print(`json ${api.encode(doc)}`); - print(`timed text ${api.timedText(doc)}`); const tagged = api.tagged(doc, "t"); print(`tagged ${Json.toText(tagged)}`); close(tagged); diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index d9a4a360f..bb69d77ef 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -100,8 +100,8 @@ fn exporter(name: &str, out: &Path, targets: &[&str], args: &[&std::ffi::OsStr], let fixture = manifest_dir().join("fixtures").join(name); let mut command = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")); command - .arg("--config") - .arg(fixture.join("ffi.toml")) + .arg("--manifest-path") + .arg(fixture.join("Cargo.toml")) .arg("--out") .arg(out) .args(targets.iter().flat_map(|target| ["--target", target])) @@ -113,28 +113,25 @@ fn exporter(name: &str, out: &Path, targets: &[&str], args: &[&std::ffi::OsStr], } /// What `Deref` forwards: a member the object or a nearer target has hides one past it, even -/// a target that does not export, a method only a method and a field only a field, and the -/// config leaves out a forwarded member by the object's path, a field sharing a method's by -/// `field@`. An exclude naming nothing fails the export, so each one here was forwarded. +/// a target that does not export, a method only a method and a field only a field, and a +/// forwarded field sharing a method's name exports beside it. #[test] fn deref_shadowing() { let header = std::fs::read_to_string(api().out.join("include").join("api.h")).unwrap(); for present in [ "api_Layered_lines(", + "api_Pad_u16_lines(", "api_Pad_u16_title(", + "api_Pad_u16_title_get(", + "api_Marker_x(", "api_Marker_x_get(", "api_Marker_x_set(", + "api_Marker_y(", "api_Marker_y_get(", ] { assert!(header.contains(present), "{present} is not exported"); } - for absent in [ - "api_Layered_describe(", - "api_Pad_u16_lines(", - "api_Pad_u16_title_get(", - "api_Marker_x(", - "api_Marker_y(", - ] { + for absent in ["api_Layered_describe("] { assert!(!header.contains(absent), "{absent} is exported"); } } @@ -2526,8 +2523,8 @@ fn go_reserved_packages() { std::fs::write(package.join("Cargo.toml"), manifest).unwrap(); let out = package.join("out"); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .arg("--out") .arg(&out) .env("CARGO_TARGET_DIR", package.join("build")) @@ -2583,8 +2580,8 @@ fn go_package_names() { ); let out = package.join("out"); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .arg("--out") .arg(&out) .env("CARGO_TARGET_DIR", package.join("build")) @@ -2615,14 +2612,10 @@ fn unreached_types() { let package = package( "unreached_types", &[ - ( - "ffi.toml", - "exclude = [\"seal\", \"bare\", \"opaque\", \"closed\", \"own\", \"Buffer::first\"]\n", - ), ( "Cargo.toml", "[package]\nname = \"unreached_types\"\nversion = \"0.0.0\"\nedition = \"2024\"\n\n[lib]\nname = \"pkg\"\n\n\ - [dependencies]\nkio = { package = \"unreached-kio\", path = \"kio\" }\n\ + [features]\nrefused = []\n\n[dependencies]\nkio = { package = \"unreached-kio\", path = \"kio\" }\n\ net = { package = \"unreached-net\", path = \"net\" }\n\ conv = { package = \"unreached-conv\", path = \"conv\" }\n\n[workspace]\nexclude = [\"kio\", \"net\", \"conv\"]\n", ), @@ -2630,11 +2623,11 @@ fn unreached_types() { "src/lib.rs", "pub use kio::Ready;\n\npub fn pending() -> kio::Pending {\n\tkio::Pending(1)\n}\n\n\ pub fn version() -> kio::version::Version {\n\tkio::version::Version { major: 2 }\n}\n\n\ - pub fn seal() -> kio::Sealed {\n\tkio::sealed()\n}\n\n\ + #[cfg(feature = \"refused\")] pub fn seal() -> kio::Sealed {\n\tkio::sealed()\n}\n\n\ pub fn connect() -> Result {\n\tnet::connect()\n}\n\n\ pub fn handle() -> std::sync::Arc {\n\tstd::sync::Arc::new(net::Handle(4))\n}\n\n\ - pub fn bare(handle: &net::Handle) -> u32 {\n\thandle.0\n}\n\n\ - pub fn opaque() -> Result<(), net::Opaque> {\n\tErr(net::Opaque)\n}\n\n\ + #[cfg(feature = \"refused\")] pub fn bare(handle: &net::Handle) -> u32 {\n\thandle.0\n}\n\n\ + #[cfg(feature = \"refused\")] pub fn opaque() -> Result<(), net::Opaque> {\n\tErr(net::Opaque)\n}\n\n\ pub fn closed() -> net::Closed {\n\tnet::closed()\n}\n\n\ pub enum Failure {\n\tNet(net::Fault),\n}\n\npub fn fail() -> Failure {\n\tFailure::Net(net::Fault)\n}\n\n\ pub struct Buffer(Vec);\n\nimpl Buffer {\n\tpub fn new() -> Self {\n\t\tSelf(vec![1])\n\t}\n\n\ @@ -2642,7 +2635,7 @@ fn unreached_types() { pub fn copied(items: &[u32]) -> impl Iterator + '_ {\n\titems.iter().copied()\n}\n\n\ #[derive(Clone)]\npub struct Held<'a>(&'a u32);\n\nimpl Held<'_> {\n\tpub fn get(&self) -> u32 {\n\t\t*self.0\n\t}\n}\n\n\ pub fn wrap(x: &u32) -> impl Clone + '_ {\n\tSome(Held(x))\n}\n\n#[derive(Clone)]\npub struct Own(u32);\n\nimpl Own {\n\tpub fn get(&self) -> u32 {\n\t\tself.0\n\t}\n}\n\npub fn own() -> impl Clone {\n\tSome(Own(1))\n}\n\n\ - impl Buffer {\n\tpub fn first(&self) -> impl Clone + '_ {\n\t\tOwn(self.0[0])\n\t}\n}\n\n\ + #[cfg(feature = \"refused\")] impl Buffer {\n\tpub fn first(&self) -> impl Clone + '_ {\n\t\tOwn(self.0[0])\n\t}\n}\n\n\ pub struct Counter(u32);\n\nimpl Counter {\n\tpub fn get(&self) -> u32 {\n\t\tself.0\n\t}\n}\n\n\ impl Buffer {\n\tfn counter(&self) -> impl Into + '_ {\n\t\tCounter(self.0[0])\n\t}\n\n\ \tpub fn best(&self) -> impl Into + '_ {\n\t\tself.counter()\n\t}\n}\n\n\ @@ -2690,8 +2683,8 @@ fn unreached_types() { // The export builds, naming `kio`'s types through its own dependency on `kio`. let out = package.join("out"); run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .arg("--out") .arg(&out) .env("CARGO_TARGET_DIR", package.join("build"))); @@ -2722,8 +2715,8 @@ fn unreached_types() { // exporting host's `kio`, not the staging host's, though only the staged target reaches it. let staged = package.join("wasm.json"); run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .args(["--api", staged.to_str().unwrap(), "--target", WASM]) .env("CARGO_TARGET_DIR", package.join("build"))); let moved = scratch().join("unreached_types-moved"); @@ -2731,7 +2724,7 @@ fn unreached_types() { for dir in ["src", "kio", "net", "conv"] { step::mirror(&package.join(dir), &moved.join(dir)); } - for file in ["Cargo.toml", "ffi.toml"] { + for file in ["Cargo.toml"] { std::fs::copy(package.join(file), moved.join(file)).unwrap(); } let lib = std::fs::read_to_string(package.join("src/lib.rs")).unwrap(); @@ -2739,8 +2732,8 @@ fn unreached_types() { let rest = &rest[rest.find("pub fn seal").unwrap()..]; std::fs::write(moved.join("src/lib.rs"), format!("{head}{rest}")).unwrap(); run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(moved.join("ffi.toml")) + .arg("--manifest-path") + .arg(moved.join("Cargo.toml")) .arg("--out") .arg(moved.join("out")) .arg("--with") @@ -2752,13 +2745,14 @@ fn unreached_types() { && !manifest.contains(&format!("{:?}", package.join("kio").display().to_string())), "{manifest}" ); - std::fs::write(package.join("ffi.toml"), "").unwrap(); + // The census, with the items that fail the export. let census = package.join("census"); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .arg("--census") .arg(&census) + .args(["--", "--features", "refused"]) .env("CARGO_TARGET_DIR", package.join("build")) .output() .unwrap(); @@ -2882,8 +2876,8 @@ fn reexport() { let out = package.join("out"); let export = || { run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .arg("--out") .arg(&out) .env("CARGO_TARGET_DIR", package.join("build"))) @@ -2982,42 +2976,22 @@ fn relative_target() { std::fs::create_dir_all(&dir).unwrap(); let census = dir.join("census"); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(manifest_dir().join("fixtures/api/ffi.toml")) + .arg("--manifest-path") + .arg(manifest_dir().join("fixtures/api/Cargo.toml")) .arg("--census") .arg(&census) .current_dir(&dir) .env("CARGO_TARGET_DIR", "build") .output() .expect("running rust2-ffi"); - // The fixture's config leaves out items that export, which the census fails on, after - // writing itself: only on those, and on a field whose method of its name is refused, - // not on that method. let stderr = String::from_utf8_lossy(&output.stderr); - assert!(!output.status.success(), "the census passed:\n{stderr}"); - let errors: Vec<&str> = stderr - .lines() - .filter(|line| line.starts_with("error: rust2-ffi:")) - .collect(); - assert!( - errors.iter().all(|error| error.ends_with(", which exports")), - "the census failed otherwise:\n{stderr}" - ); - assert!( - errors.contains( - &"error: rust2-ffi: exclude `field@Retry::jitter` in the config leaves out `field@Retry::jitter`, which exports" - ), - "the census does not fail on `field@Retry::jitter`:\n{stderr}" - ); - assert!( - !errors.iter().any(|error| error.contains("exclude `Retry::jitter`")), - "the census fails on `Retry::jitter`:\n{stderr}" - ); - assert!( - !errors.iter().any(|error| error.contains("exclude `among`")), - "the census fails on `among`, which Swift refuses:\n{stderr}" - ); + assert!(output.status.success(), "the census failed:\n{stderr}"); let text = std::fs::read_to_string(census.join("api-fixture.md")).unwrap(); + // The fixture exports whole: every row counts no refusal. + let refused = (text.lines()) + .take_while(|line| !line.starts_with("Exported types:")) + .filter_map(|line| line.split(" | ").nth(2)?.parse::().ok()); + assert_eq!(refused.sum::(), 0, "the census refuses some:\n{text}"); for line in [ "- `Lease`: object no export returns", "- `Void`: object no export returns", @@ -3027,35 +3001,9 @@ fn relative_target() { "- `blame`: type C never holds `tls::held::Invalid`", // A type parameter only another crate's trait bounds, which no export implements. "- `pump`: bound no type C holds meets `tls::held::Stream`", - // An exclude that names what exports, by its generic or instance path or as a field, - // even where a method of the field's name is refused. - "## Excluded by the config, though it exports", - "- `Timed`: `Timed`", - "- `Pair::swap`: `Pair::swap`", - "- `Slot::value`: `Slot::value`", - "- `field@Retry::jitter`: `field@Retry::jitter`", - "- `Stack::depth_past`: `Stack::depth_past`", ] { assert!(text.contains(line), "the census lists no `{line}`:\n{text}"); } - let exporting = text - .split("## Excluded by the config, though it exports") - .nth(1) - .unwrap(); - let exporting = exporting.split("\n## ").next().unwrap(); - // Not one that names only what is refused or no export returns. - for refused in [ - "- `Copied`", - "- `Sample`", - "- `Queued`", - "- `Layer`", - "- `Retry::jitter`", - ] { - assert!( - !exporting.contains(refused), - "the census lists `{refused}` as exporting:\n{exporting}" - ); - } // Its error a handle C never holds, `verify` still exports, the error as its message. assert!(!text.contains("`verify`"), "the census lists `verify`:\n{text}"); // Nor does `parse_cert`'s, though it borrows the text. @@ -3508,7 +3456,6 @@ fn package(name: &str, files: &[(&str, &str)]) -> PathBuf { let defaults = [ ("Cargo.toml", manifest.as_str()), ("src/lib.rs", "pub fn one() -> u32 {\n\t1\n}\n"), - ("ffi.toml", ""), ]; let defaults = defaults .into_iter() @@ -3532,8 +3479,8 @@ fn no_std_links() { ); let out = package.join("out"); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .arg("--manifest-path") .arg(package.join("Cargo.toml")) .arg("--out") @@ -3566,7 +3513,7 @@ fn argfile() { &format!("build.rustflags = [\"--remap-path-prefix\", \"{value}\"]\n"), )], ); - let output = census(&package.join("ffi.toml"), &[]).output().unwrap(); + let output = census(&package.join("Cargo.toml"), &[]).output().unwrap(); assert!( output.status.success(), "the census failed:\n{}", @@ -3574,12 +3521,12 @@ fn argfile() { ); } -/// A census of the package whose config is `config` with these cargo args, to run. -fn census(config: &Path, cargo: &[&str]) -> Command { - let dir = config.parent().unwrap(); +/// A census of the package whose manifest is `manifest` with these cargo args, to run. +fn census(manifest: &Path, cargo: &[&str]) -> Command { + let dir = manifest.parent().unwrap(); let mut cmd = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")); - cmd.arg("--config") - .arg(config) + cmd.arg("--manifest-path") + .arg(manifest) .arg("--census") .arg(dir.join("census")) .arg("--") @@ -3594,7 +3541,7 @@ fn census(config: &Path, cargo: &[&str]) -> Command { fn locked() { let package = package("locked", &[]); let _ = std::fs::remove_file(package.join("Cargo.lock")); - let output = census(&package.join("ffi.toml"), &["--locked"]).output().unwrap(); + let output = census(&package.join("Cargo.toml"), &["--locked"]).output().unwrap(); assert!(!output.status.success(), "a census without a lockfile passed --locked"); assert!(!package.join("Cargo.lock").exists(), "the lockfile was written"); } @@ -3609,7 +3556,7 @@ fn symlinked() { if !link.exists() { std::os::unix::fs::symlink(&package, &link).unwrap(); } - let output = census(&link.join("ffi.toml"), &[]).output().unwrap(); + let output = census(&link.join("Cargo.toml"), &[]).output().unwrap(); assert!( output.status.success(), "the census failed:\n{}", @@ -3658,8 +3605,8 @@ fn lookalike() { let out = package.join("out"); let remap = format!("--remap-path-prefix={}=/src", package.display()); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .arg("--out") .arg(&out) .env("CARGO_TARGET_DIR", package.join("build")) @@ -3692,8 +3639,8 @@ fn standard_names() { let lib = "pub struct SocketAddrV4 {\n\tpub port: u16,\n}\n\npub fn port(addr: SocketAddrV4) -> u16 {\n\taddr.port\n}\n"; std::fs::write(package.join("src/lib.rs"), lib).unwrap(); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .arg("--out") .arg(package.join("out")) .args(["--", "--offline"]) @@ -3737,8 +3684,8 @@ fn opaque_values() { let package = package("opaque_values", &[("src/lib.rs", lib)]); let out = package.join("out"); run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .arg("--out") .arg(&out) .args(["--target", WASM, "--target", host(), "--", "--offline"]) @@ -3817,62 +3764,6 @@ fn foreign_role_names() { export_and_build(&package, &[]); } -/// An exclude may name what a `cfg` leaves out of this build, whether the facade's own -/// module or another crate's that the facade re-exports through a glob, or a chain of them, -/// or a field or variant of the facade's or another crate's type, under a `cfg` or one a -/// `cfg_attr` adds, an inline module's type and a const-generic one's included, and by the -/// defining crate's path as well as the facade's, but not what no build has, nor what a -/// module only some of whose items the facade re-exports leaves out. -#[test] -fn configured_out() { - let package = package("configured_out", &[]); - let dep = manifest_dir().join("fixtures/dep"); - let manifest = format!( - "[package]\nname = \"configured_out\"\nversion = \"0.0.0\"\nedition = \"2024\"\n\n\ - [dependencies]\ndep = {{ package = \"dep-fixture\", path = {:?} }}\n\n[workspace]\n", - dep.display().to_string() - ); - write_all( - &package, - &[ - ("Cargo.toml", &manifest), - ( - "src/lib.rs", - "pub use ::dep::Size;\n\npub mod glob {\n\tpub use ::dep::*;\n}\n\n#[cfg(any())]\npub mod local {}\n\n\ - mod inner {\n\tpub fn kept() -> u32 {\n\t\t1\n\t}\n\n\t#[cfg(any())]\n\tpub mod gone {}\n}\n\n\ - mod middle {\n\tpub use crate::inner::*;\n}\n\npub mod outer {\n\tpub use crate::middle::*;\n}\n\n\ - pub struct Shape {\n\tpub n: u32,\n\t#[cfg(any())]\n\tpub gone: u32,\n\t#[cfg_attr(all(), cfg_attr(all(), cfg(any())))]\n\tpub gated: u32,\n}\n\n\ - pub enum Kind {\n\tKept,\n\t#[cfg(any())]\n\tGone,\n}\n\n\ - pub mod nested {\n\tpub struct Inner {\n\t\tpub n: u32,\n\t\t#[cfg(any())]\n\t\tpub gone: u32,\n\t}\n}\n", - ), - ( - "ffi.toml", - "exclude = [\"Gone\", \"Kind::Gone\", \"dep::Size::depth\", \"dep::Size::missing\", \"glob::Area::scaled\", \"Shape::gated\", \"Shape::gone\", \"Shape::missing\", \"Size::depth\", \"nested::Inner::gone\", \"glob::gone::Gone\", \"gone::Gone\", \"local::Gone\", \"outer::gone::Gone\"]\n", - ), - ], - ); - let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) - .arg("--out") - .arg(package.join("out")) - .env("CARGO_TARGET_DIR", package.join("build")) - .output() - .unwrap(); - let stderr = String::from_utf8_lossy(&output.stderr); - let errors: Vec<&str> = stderr.lines().filter(|l| l.starts_with("error: rust2-ffi:")).collect(); - assert_eq!( - errors, - [ - "error: rust2-ffi: exclude `Gone` in the config names nothing exported", - "error: rust2-ffi: exclude `dep::Size::missing` in the config names nothing exported", - "error: rust2-ffi: exclude `Shape::missing` in the config names nothing exported", - "error: rust2-ffi: exclude `gone::Gone` in the config names nothing exported", - ], - "{stderr}" - ); -} - /// The glue declares the facade's `rust-version`, raised to the 1.85 its edition needs. #[test] fn rust_version() { @@ -3885,8 +3776,8 @@ fn rust_version() { ); let out = package.join("out"); run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .arg("--out") .arg(&out) .env("CARGO_TARGET_DIR", package.join("build"))); @@ -3961,8 +3852,8 @@ fn channel() { ); let out = package.join("out"); run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(package.join("ffi.toml")) + .arg("--manifest-path") + .arg(package.join("Cargo.toml")) .arg("--out") .arg(&out) .env("RUSTC", stable_rustc()) @@ -4022,8 +3913,8 @@ fn target() { let package = package("targeted", &[("src/lib.rs", &format!("{shared}\n{differing}"))]); let exporter = |args: &[&str]| { let mut cmd = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")); - cmd.arg("--config") - .arg(package.join("ffi.toml")) + cmd.arg("--manifest-path") + .arg(package.join("Cargo.toml")) .args(args) .env("CARGO_TARGET_DIR", package.join("build")); cmd @@ -4105,13 +3996,13 @@ fn target() { let staged = package.join("differing.json"); run(&mut exporter(&["--api", staged.to_str().unwrap(), "--target", WASM])); let moved = scratch().join("targeted-moved"); - for file in ["Cargo.toml", "ffi.toml", "src/lib.rs"] { + for file in ["Cargo.toml", "src/lib.rs"] { std::fs::create_dir_all(moved.join(file).parent().unwrap()).unwrap(); std::fs::copy(package.join(file), moved.join(file)).unwrap(); } let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(moved.join("ffi.toml")) + .arg("--manifest-path") + .arg(moved.join("Cargo.toml")) .arg("--out") .arg(moved.join("out")) .arg("--with") @@ -4169,8 +4060,8 @@ fn write_all(dir: &Path, files: &[(&str, &str)]) { fn export_and_build(dir: &Path, args: &[&str]) { let out = dir.join("out"); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(dir.join("ffi.toml")) + .arg("--manifest-path") + .arg(dir.join("Cargo.toml")) .arg("--out") .arg(&out) .arg("--") @@ -4364,14 +4255,13 @@ fn replaced() { "src/lib.rs", "pub use rust2_ffi_replaced_dep::Size;\n\npub fn width(size: Size) -> u32 {\n\tsize.width\n}\n", ), - ("ffi.toml", ""), ], ); }; files("{ path = \"dep\" }"); export_and_build(&package, &[]); files(&format!("{{ git = \"{url}\", branch = \"fixed\" }}")); - let output = census(&package.join("ffi.toml"), &[]).output().unwrap(); + let output = census(&package.join("Cargo.toml"), &[]).output().unwrap(); assert!(!output.status.success(), "a replacement from its own source passed"); let stderr = String::from_utf8_lossy(&output.stderr); assert!( @@ -4437,11 +4327,10 @@ fn config_patched() { "pub use rust2_ffi_config_cli::Margin;\npub use rust2_ffi_config_dep::Size;\n\n\ pub fn width(size: Size, cli: Margin) -> u32 {\n\tsize.width + cli.width\n}\n", ); - write("pkg/ffi.toml", ""); let out = root.join("out"); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(root.join("pkg/ffi.toml")) + .arg("--manifest-path") + .arg(root.join("pkg/Cargo.toml")) .arg("--out") .arg(&out) .args(["--", "--offline", "--config", "include = [\".cargo/cli.toml\"]"]) @@ -4489,7 +4378,6 @@ fn profiled() { "[package]\nname = \"rust2-ffi-profiled-dev\"\nversion = \"0.0.0\"\nedition = \"2024\"\n", ), ("dev/src/lib.rs", ""), - ("ffi.toml", ""), ], ); }; @@ -4509,7 +4397,7 @@ fn profiled() { ); assert!(!manifest.contains("rust2-ffi-profiled-dev"), "{manifest}"); files("missing"); - let output = census(&package.join("ffi.toml"), &[]).output().unwrap(); + let output = census(&package.join("Cargo.toml"), &[]).output().unwrap(); assert!(!output.status.success(), "an override of no package passed"); let stderr = String::from_utf8_lossy(&output.stderr); assert!( @@ -4517,7 +4405,7 @@ fn profiled() { "{stderr}" ); files("*"); - let output = census(&package.join("ffi.toml"), &[]).output().unwrap(); + let output = census(&package.join("Cargo.toml"), &[]).output().unwrap(); assert!(!output.status.success(), "a wildcard override passed"); let stderr = String::from_utf8_lossy(&output.stderr); assert!( diff --git a/ffi/tests/fixtures/corpus.rs b/ffi/tests/fixtures/corpus.rs index 1d087e6b7..df863354a 100644 --- a/ffi/tests/fixtures/corpus.rs +++ b/ffi/tests/fixtures/corpus.rs @@ -1,8 +1,9 @@ //! A pinned corpus of popular crates.io crates, `corpus/crates.txt`, each exported through //! a facade of its own, `pub use ::*;`, as a consumer would export it. Each is -//! censused, then exported with the `exclude` its census writes, and its glue and every -//! language's binding of it built. A panic, an error with or without a span, or a binding -//! that does not build fails the run; a refusal does not, since the census lists it. +//! censused, then, if the census refuses nothing, since a refusal fails the export, exported, +//! and its glue and every language's binding of it built. A panic, an error with or without a +//! span, or a binding that does not build fails the run; a refusal does not, since the census +//! lists it. //! //! The facades are one workspace, resolved by `corpus/Cargo.lock`, so a run builds what the //! last update resolved. `just ffi corpus-update` takes the top crates by all-time @@ -242,11 +243,9 @@ fn one(krate: &Krate) -> Result { let facade = workspace().join(name); let dir = base().join("crates").join(name); let build = base().join("build"); - let exporter = |config: &Path, mode: &str, out: &Path| { + let exporter = |mode: &str, out: &Path| { let mut cmd = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")); - cmd.arg("--config") - .arg(config) - .arg("--manifest-path") + cmd.arg("--manifest-path") .arg(facade.join("Cargo.toml")) .arg(mode) .arg(out) @@ -254,20 +253,21 @@ fn one(krate: &Krate) -> Result { .env("CARGO_TARGET_DIR", &build); cmd }; - // The census ignores the config's `exclude`, so an empty one serves. - let empty = dir.join("census.toml"); - step::write(&empty, "exclude = []\n"); let census = dir.join("census"); - let output = super::output(&mut exporter(&empty, "--census", &census)); + let output = super::output(&mut exporter("--census", &census)); if !output.status.success() { return Err(fail(stage(&output, "census"), &output)); } let text = std::fs::read_to_string(census.join(format!("corpus-{name}.md"))).unwrap(); - let exclude = excluded(&text); - let config = dir.join("ffi.toml"); - step::write(&config, &exclude); + let refused = refusals(&text); + if refused > 0 { + return Ok(Passed { + krate: name.clone(), + refused, + }); + } let out = dir.join("out"); - let output = super::output(&mut exporter(&config, "--out", &out)); + let output = super::output(&mut exporter("--out", &out)); if !output.status.success() { return Err(fail(stage(&output, "export"), &output)); } @@ -276,10 +276,7 @@ fn one(krate: &Krate) -> Result { languages(&lib, &out, &dir, &built).map_err(|(stage, output)| fail(stage.to_string(), &output))?; Ok(Passed { krate: name.clone(), - refused: exclude - .lines() - .filter(|line| line.trim_start().starts_with('"')) - .count(), + refused: 0, }) } @@ -301,13 +298,12 @@ fn stage(output: &Output, stage: &str) -> String { } } -/// The `exclude` the census writes, which exports what maps: none where it refuses nothing. -fn excluded(census: &str) -> String { - let Some(start) = census.find("```toml\nexclude = [") else { - return "exclude = []\n".to_string(); - }; - let toml = &census[start + "```toml\n".len()..]; - toml[..toml.find("```").expect("the config's block ends")].to_string() +/// How many items the census refuses: its table's refused column, Swift's included. +fn refusals(census: &str) -> usize { + (census.lines()) + .take_while(|line| !line.starts_with("Exported types:")) + .filter_map(|line| line.strip_prefix("| ")?.split(" | ").nth(2)?.parse::().ok()) + .sum() } /// The first lines of what a command printed, where its first error is, enough to say why diff --git a/ffi/tests/fixtures/shapes.rs b/ffi/tests/fixtures/shapes.rs index 8b6e2fe64..84aefb44a 100644 --- a/ffi/tests/fixtures/shapes.rs +++ b/ffi/tests/fixtures/shapes.rs @@ -634,20 +634,24 @@ fn emit(name: &str, shapes: &[Shape]) -> Crate { ); super::write_all( &dir, - &[("Cargo.toml", &manifest), ("src/lib.rs", &lib), ("ffi.toml", "")], + &[("Cargo.toml", &manifest), ("src/lib.rs", &lib)], ); // The api fixture's versions, resolved offline. super::step::copy(&manifest_dir().join("Cargo.lock"), &dir.join("Cargo.lock")); + // What the census refuses, the crate leaves out, as the export would fail on it. let refused = refused(&dir); let exported = |item: Item, n: usize| !refused.iter().any(|path| *path == item.name(n)); - let mut excludes: Vec<&String> = refused.iter().collect(); - excludes.sort(); - let config = excludes - .iter() - .map(|path| format!(" \"{path}\",\n")) - .collect::(); - super::step::write(&dir.join("ffi.toml"), format!("exclude = [\n{config}]\n")); + let mut kept = lib; + for path in &refused { + let item = ["pub fn ", "pub async fn ", "pub struct ", "pub enum "] + .iter() + .map(|head| format!("{head}{path}")) + .find(|item| kept.contains(&format!("{item}(")) || kept.contains(&format!("{item} "))) + .unwrap_or_else(|| panic!("the census refuses `{path}`, which is no item of the crate's")); + kept = kept.replacen(&item, &format!("#[cfg(any())]\n{item}"), 1); + } + super::write_all(&dir, &[("src/lib.rs", &kept)]); let mut calls = Vec::new(); for n in 0..shapes.len() { @@ -712,27 +716,31 @@ fn later(f: impl Future) -> T { fn main() { "; -/// The paths the census of the crate in `dir` refuses: its config that exports what maps. +/// The paths the census of the crate in `dir` refuses, Swift's refusals included. fn refused(dir: &Path) -> Vec { let census = dir.join("census"); run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(dir.join("ffi.toml")) + .arg("--manifest-path") + .arg(dir.join("Cargo.toml")) .arg("--census") .arg(&census) .env("CARGO_TARGET_DIR", dir.join("build"))); let name = dir.file_name().unwrap().to_string_lossy(); let report = std::fs::read_to_string(census.join(format!("{name}.md"))).unwrap(); - let Some((_, config)) = report.split_once("## The config that exports what maps") else { - return Vec::new(); + let section = |heading: &str| -> Vec { + let Some((_, rest)) = report.split_once(heading) else { + return Vec::new(); + }; + (rest.lines().skip(1)) + .take_while(|line| !line.starts_with("## ")) + .filter_map(|line| Some(line.split_once('`')?.1.split_once('`')?.0.to_string())) + .collect() }; - config - .lines() - .skip_while(|line| *line != "exclude = [") - .skip(1) - .take_while(|line| *line != "]") - .map(|line| line.trim().trim_end_matches(',').trim_matches('"').to_string()) - .collect() + let mut refused = section("## Refused items"); + refused.extend(section("## Refused by Swift")); + refused.sort(); + refused.dedup(); + refused } /// Each variant of the IR's `Type`, from its source. @@ -775,8 +783,8 @@ fn build(name: &str, shapes: &[Shape]) -> Built { let krate = emit(name, shapes); let out = krate.dir.join("out"); run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--config") - .arg(krate.dir.join("ffi.toml")) + .arg("--manifest-path") + .arg(krate.dir.join("Cargo.toml")) .arg("--out") .arg(&out) .env("CARGO_TARGET_DIR", krate.dir.join("build"))); diff --git a/go/bench/ffi.toml b/go/bench/ffi.toml deleted file mode 100644 index 3dce410e7..000000000 --- a/go/bench/ffi.toml +++ /dev/null @@ -1,3 +0,0 @@ -# The codec fixture's C ABI: only its entry points, the rest being crate-private. -package = "codec" -prefix = "codec" diff --git a/go/justfile b/go/justfile index 0273408ac..552d48ef4 100644 --- a/go/justfile +++ b/go/justfile @@ -46,7 +46,7 @@ bench *args: cargo run --locked --quiet -- --manifest-path fixtures/codec/Cargo.toml --out "$out/codec" \ -- --config profile.dev.overflow-checks=false printf 'module codec\n\ngo 1.24\n' > "$out/codec/go.mod" - cargo run --locked --quiet --manifest-path ../ffi/Cargo.toml -- --config bench/ffi.toml --manifest-path fixtures/codec/Cargo.toml --out "$out/ffi" + cargo run --locked --quiet --manifest-path ../ffi/Cargo.toml -- --manifest-path fixtures/codec/Cargo.toml --out "$out/ffi" cargo build --quiet --release --manifest-path "$out/ffi/Cargo.toml" --target-dir "$out/ffi/target" cd bench CGO_CFLAGS="-I$out/ffi/include" CGO_LDFLAGS="$out/ffi/target/release/libcodec.a" go test -count=1 -run Agree -bench . -benchtime 1s {{ args }} From fd359c84f6f9139199218c49e92ca55efc5c805a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 18:02:07 -0800 Subject: [PATCH 04/10] quest: finish the refusals epic; corpus-proved quests note the clean-census rule Co-Authored-By: Claude Opus 5.5 --- quest/m1/ffi-apart.md | 5 ++ quest/m1/ffi-corpus-bugs.md | 5 ++ quest/m1/ffi-export/README.md | 2 +- quest/m1/ffi-export/ship.md | 3 +- quest/m1/ffi-guide.md | 4 +- quest/m1/ffi-refusals/README.md | 92 ------------------------------ quest/m1/ffi-refusals/no-config.md | 41 ------------- 7 files changed, 14 insertions(+), 138 deletions(-) delete mode 100644 quest/m1/ffi-refusals/README.md delete mode 100644 quest/m1/ffi-refusals/no-config.md diff --git a/quest/m1/ffi-apart.md b/quest/m1/ffi-apart.md index 92162db16..4a37ea798 100644 --- a/quest/m1/ffi-apart.md +++ b/quest/m1/ffi-apart.md @@ -26,6 +26,11 @@ Kotlin's `_` parameter. What remains, by generator: - C++: a name a system header defines as a macro, such as `WEXITSTATUS`, `PTHREAD_COND_INITIALIZER`, or `NULL`'s `__null` (libc, hermit-abi, wasm-bindgen). +Since [no config](https://github.com/kixel-ai/rust2/pull/903), the corpus exports only a +crate whose census refuses nothing, as a refusal fails the export, so a crate here that +refuses an item no longer reaches its bindings: prove each fix on its reduction in the api +fixture, and through the corpus only where the crate's census is clean. + Recommended: give each generator the `taken` set C++'s `kept_apart` uses, holding every member the generator itself writes, so the rename happens where the name is made, and add each case to the api fixture's `clash` module. For macros, rename every name a C or C++ diff --git a/quest/m1/ffi-corpus-bugs.md b/quest/m1/ffi-corpus-bugs.md index 7ded7550c..a64d23515 100644 --- a/quest/m1/ffi-corpus-bugs.md +++ b/quest/m1/ffi-corpus-bugs.md @@ -17,6 +17,11 @@ Found by [the corpus](/ffi/tests/fixtures/corpus.rs) on 2026-11-19: - axum and hyper: the glue crate depends on `bytes` twice, at the facade's version and at another, which cargo refuses. +Since [no config](https://github.com/kixel-ai/rust2/pull/903), the corpus exports only a +crate whose census refuses nothing, as a refusal fails the export, so a crate here that +refuses an item no longer reaches its bindings: prove each fix on its reduction in the api +fixture, and through the corpus only where the crate's census is clean. + Recommended: reduce each to a case in the api fixture first, since each is a generator bug the fixtures do not reach yet. diff --git a/quest/m1/ffi-export/README.md b/quest/m1/ffi-export/README.md index 3c29f909f..429760c60 100644 --- a/quest/m1/ffi-export/README.md +++ b/quest/m1/ffi-export/README.md @@ -77,7 +77,7 @@ Every generator, the [targets m3 plans](/quest/m3/README.md) included: Decided with the maintainer on 2026-11-12, in the quest audit: - ✅ The epic's closing work is a child, [ship](/quest/m1/ffi-export/ship.md), which alone - requires [the refusals epic](/quest/m1/ffi-refusals/README.md). Rejected: the epic + required the refusals epic, since finished. Rejected: the epic requiring it, as [#701](https://github.com/kixel-ai/rust2/pull/701) left it, since an epic's `Required` holds back every child, so none could start until moq's pin bump, which then waited on a rind release the maintainer held. diff --git a/quest/m1/ffi-export/ship.md b/quest/m1/ffi-export/ship.md index 48e5d7073..594d77d2e 100644 --- a/quest/m1/ffi-export/ship.md +++ b/quest/m1/ffi-export/ship.md @@ -12,14 +12,13 @@ deleted with its last child. This is the epic's last child, and what Decided with the maintainer on 2026-11-12, in the quest audit: ✅ the closing work is this child, which alone waits on a clean census. Rejected: the epic requiring -[the refusals epic](/quest/m1/ffi-refusals/README.md), which held back every other child. +the refusals epic, since finished, which held back every other child. Every sibling lands first, since each breaks a generated API moq would otherwise adopt and then see change. A sibling planned later adds itself to `Required` here. ## Required -- [Refusals](/quest/m1/ffi-refusals/README.md) - the census lists no refusals at the moq pin, and `ffi.toml` is gone - [C and C++ idioms](/quest/m1/ffi-export/cpp-idioms.md) - numeric slice views and must-use returns change the C++ API - [Swift spans](/quest/m1/ffi-export/swift-span.md) - lent bytes and slices change the Swift API - [Kotlin idioms](/quest/m1/ffi-export/kotlin-idioms.md) - direct buffers and Java annotations change the Kotlin API diff --git a/quest/m1/ffi-guide.md b/quest/m1/ffi-guide.md index 911392e37..a1dd0c112 100644 --- a/quest/m1/ffi-guide.md +++ b/quest/m1/ffi-guide.md @@ -12,7 +12,7 @@ read the census. Found by the 2026-11-18 language audit: refusals are rustc diagnostics at their spans but say only what is refused; the README's scope note says a stock crate needs a facade, and nothing shows how to write one. The nightly corpus's refusals (`just ffi corpus`, whose -report lists each crate's) are the examples to write the notes against. The "exclude it in the config" suffix goes -with [the config](/quest/m1/ffi-refusals/no-config.md), not here. +report lists each crate's) are the examples to write the notes against. The "exclude it in the config" suffix went +with the config, in [#903](https://github.com/kixel-ai/rust2/pull/903). Public API: refusal messages. diff --git a/quest/m1/ffi-refusals/README.md b/quest/m1/ffi-refusals/README.md deleted file mode 100644 index 78888fd06..000000000 --- a/quest/m1/ffi-refusals/README.md +++ /dev/null @@ -1,92 +0,0 @@ -# Every public item exports - -## Goal - -[rust2-ffi](/ffi/README.md) exports every `pub` item of the moq facade it is given, or -leaves out and lists in the census what C can never hold, so `just ffi census` lists no -refusals at the moq pin and `ffi.toml` is deleted: the exporter reads no config, and an -item it cannot export fails the export with a span. - -The epic ends with [the config's deletion](/quest/m1/ffi-refusals/no-config.md), its last -child. - -## Plan - -Decided with the maintainer on 2026-11-04: configless, and an unsupported public item -fails the export rather than being excluded. ✅ Split: the naming rule first, then this. -Rejected: one quest that waits for the census to reach zero. - -Decided with the maintainer on 2026-11-07, from -[kixel-ai/rust2#655](https://github.com/kixel-ai/rust2/pull/655): - -- ✅ A whole-crate re-export (`pub use rustls;`) is refused with one span at its `pub use`, - and moq drops its re-exports. A whole-crate re-export makes that crate's whole API part - of moq's, so any breaking release of it breaks moq's semver; moq wraps the few - third-party types its signatures need instead. Rejected: skipping them silently, as - rustdoc does; exporting their whole APIs. -- ✅ No exemption: the rule covers every crate, moq's own included (`pub use moq_net;`, - `moq_congestion as congestion`), so moq drops those too, per - [moq-dev/moq#8233](https://github.com/moq-dev/moq/pull/8233). Rejected: exempting the - crates the facade already exports, or moq's own; either needs a list, which is config. -- ✅ The stand-in re-exports only the session side moq-ffi ships from moq-tokio. Rejected: - all of moq-tokio, whose tokio QUIC driver, CLI helpers, worker groups, and listeners no - binding calls; the sans-IO driver bindings use instead is - [session-quic](/quest/m3/session-quic.md). Children leave the moq-tokio items - outside that session side alone, since narrowing the stand-in drops them. -- Narrowing the stand-in was to land first; the 2026-11-09 audit dropped that order, and - [kixel-ai/rust2#683](https://github.com/kixel-ai/rust2/pull/683) narrowed it. -- ✅ What C can never hold, an object no export returns or lends to a closure, or a generic - type no export instantiates, is left out of the bindings and kept listed in the census. - Rejected: refusing them, which would make moq add constructors it has no use for. -- ✅ This epic, with the children below ranked by what moq-ffi's hand-written wrapper still - covers. - -Decided with the maintainer on 2026-11-09, from -[kixel-ai/rust2#678](https://github.com/kixel-ai/rust2/pull/678): - -- ✅ rust2 asks moq for no source changes: changing moq is a non-goal, so every refusal - that waited on moq changing a signature gets an answer on rust2's side. moq's merged - removal of its whole-crate re-exports stands, as moq drops them for its semver anyway. - Rejected: refusing a shape and leaving moq to change its signature. -- ✅ A third-party type a signature still names behind an `Arc`, such as - `Arc`, crosses as an opaque handle with none of its API, which - passes back into moq's calls. Rejected: moq wrapping it in a type of its own. - -The census at moq `ffcb7cd9` (2026-11-07) refused 1111 items, which `ffi/moq/ffi.toml`'s -347 excludes hide by naming whole modules. About 790 lay in crates moq re-exports whole, -which [#668](https://github.com/kixel-ai/rust2/pull/668) has since made one refusal each, -and [#671](https://github.com/kixel-ai/rust2/pull/671) moved what C can never hold out of -the refusals, so the figures below predate both. -The other 324 are moq's own, 107 of them in moq-tokio (61 under `quic`); each child gives -its construct's count, and an item counts under every construct it hits. The counts -include the moq-tokio items narrowing drops; each child measures again once it lands. 17 more refuse -only because a type they name is refused, and clear with it. After the stand-in narrows -([kixel-ai/rust2#683](https://github.com/kixel-ai/rust2/pull/683)), the census refuses 130 -items, 41 of them in moq-tokio, and 6 types. - -Decided with the maintainer on 2026-11-12, in the quest audit: - -- ✅ The exporter pins moq on its own, apart from rust2-ts's pin, so its bump no longer - waits on rind building for wasm32, which only the translator needs. Rejected: one pin for - both, at the cost of two revisions to bump. -- The last per-construct child landed in - [#710](https://github.com/kixel-ai/rust2/pull/710), yet the Goal is not reached: the - 2026-11-11 nightly census - ([run 43038758163](https://github.com/kixel-ai/rust2/actions/runs/43038758163)) still - refuses 94 items and 5 types at the pin, behind `ffi/moq/ffi.toml`'s then 100 excludes, and - moq's `main` adds the 36 errors the pin bump measured. So each construct left has a child again: - `NonZero`, which exports, the rest of the errors at moq's main - (exported since by rules for another crate's value, a borrowing future of a function - that is not `async`, and an object field that is not `Clone`), and - what the excludes still hide at moq's main, exported since (`IpAddr` by its family, as - `SocketAddr` is, and `server::Listener::accept_with` as its future need not be `Send`); - `just ffi census` fails on an exclude that names what exports. The - bump is then only the bump. Of the types refused for not being `Send`, `clock::Entered` - and `clock::Rng` export since [#844](https://github.com/kixel-ai/rust2/pull/844), and `catalog::Guard` since - [#848](https://github.com/kixel-ai/rust2/pull/848), whose handle holds the exclusive lend - of the receiver `Producer::modify` borrows mutably. -- ✅ The closing work is a child, [no config](/quest/m1/ffi-refusals/no-config.md), as - [the exporter epic's](/quest/m1/ffi-export/ship.md) is: an epic's `Required` would hold - back every child. - -Public API: the exporter's command line and the C API of every item that exports. diff --git a/quest/m1/ffi-refusals/no-config.md b/quest/m1/ffi-refusals/no-config.md deleted file mode 100644 index 72f5bb8b7..000000000 --- a/quest/m1/ffi-refusals/no-config.md +++ /dev/null @@ -1,41 +0,0 @@ -# [S] Delete the exporter's config - -## Goal - -`just ffi census` lists no refusals at the moq pin, and [rust2-ffi](/ffi/README.md) reads -no config: an item it cannot export fails the export with a span. - -Deleted: `ffi/moq/ffi.toml`, the `--config` flag, `RUST2_FFI_CONFIG`, and `config.rs`'s -`Config` and `exclude`, with the fixtures' `ffi/fixtures/api/ffi.toml` and -`ffi/fixtures/reject/ffi.toml` and the exclude tests in `ffi/tests/fixtures.rs`; -`ffi/README.md` and the recipes stop naming them. `config.rs`'s `Package` and environment -constants stay. Also deleted: the `--config` parsing rust2-ffi takes from -`driver/src/cargo.rs`, which already has `parse_configless`; `go/bench/ffi.toml` and the -`--config` in `go/justfile`'s bench recipe, whose `package` and `prefix` keys `config.rs` -already rejects; and "exclude it in the config" in `ffi/src/driver.rs`'s refusal notes and -`ffi/fixtures/reject/expected.txt`. - -## Plan - -[The epic](/quest/m1/ffi-refusals/README.md) holds the decisions: configless since -2026-11-04, and no exclude stands in for a rule. This is its last child, split out by the -2026-11-12 audit so the epic needs no `Required` of its own. - -Since [#848](https://github.com/kixel-ai/rust2/pull/848) exports an exclusive lend, rustls's -`ClientConfig::dangerous` returns a held `DangerousClientConfig`, whose `pub cfg: &'a mut -ClientConfig` field `ffi/moq/ffi.toml` excludes: no rule yet exports an object's `pub` field -holding a reference, which would need its own rule, such as a getter through the reference -and no setter. - -At the pin, moq `1aa86d5e6` since [kixel-ai/rust2#881](https://github.com/kixel-ai/rust2/pull/881), -the census refuses 6 items and no type, each needing a rule before the config can go: -moq-pattern's `escape` and `unescape`, which return `Cow<'_, str>`; moq-mux's derived -`Mpegts::deserialize`, generic over serde's `Deserializer`; moq-tokio's -`server::Streams::{tcp, unix}`, `Option`s of std listeners that are not `Clone`; and -`DangerousClientConfig::cfg` above. - -One deletion needs no clean census and may land in any sibling's PR first: -`go/bench/ffi.toml` with the `--config` in `go/justfile`'s bench recipe. - -Public API: the `--config` flag and `RUST2_FFI_CONFIG` are removed (breaking for a caller -that passes them). From b38e8165c3a9e2e0244d8cb13231d0a849e83eab Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 21:22:27 -0800 Subject: [PATCH 05/10] ffi: every language prints the new api cases; surface regenerated Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/api/src/lib.rs | 4 +++- ffi/surface/api/c.h | 36 +++++++++++++++++++++++++--- ffi/surface/api/cpp.hpp | 34 +++++++++++++++++++++++++- ffi/surface/api/dart.dart | 30 ++++++++++++++++++++++- ffi/surface/api/go.txt | 30 ++++++++++++++++++++++- ffi/surface/api/kotlin.kt | 28 +++++++++++++++++++++- ffi/surface/api/python.pyi | 37 +++++++++++++++++++++++++++-- ffi/surface/api/swift.swift | 31 ++++++++++++++++++++++-- ffi/surface/api/web.d.ts | 42 +++++++++++++++++++++++++++++++- ffi/surface/moq-web/web.d.ts | 4 ++++ ffi/surface/moq/c.h | 6 ++++- ffi/surface/moq/cpp.hpp | 4 ++++ ffi/surface/moq/dart.dart | 4 ++++ ffi/surface/moq/go.txt | 6 +++++ ffi/surface/moq/kotlin.kt | 4 ++++ ffi/surface/moq/python.pyi | 8 +++++++ ffi/surface/moq/swift.swift | 4 ++++ ffi/tests/api.c | 46 +++++++++++++++++++++++++++++++++--- ffi/tests/api.cpp | 27 +++++++++++++++++++-- ffi/tests/api.dart | 25 ++++++++++++++++++-- ffi/tests/api.go | 26 ++++++++++++++++++-- ffi/tests/api.kt | 22 +++++++++++++++-- ffi/tests/api.py | 23 ++++++++++++++++-- ffi/tests/api.swift | 31 +++++++++++++++++++++--- ffi/tests/api.ts | 25 ++++++++++++++++++-- ffi/tests/fixtures.rs | 8 +++---- 26 files changed, 509 insertions(+), 36 deletions(-) diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index 5278fdc08..ef7bb4bd0 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -3032,7 +3032,9 @@ pub fn hex(payload: impl Payload) -> String { payload.into_bytes().iter().map(|b| format!("{b:02x}")).collect() } -/// A value and when it was stamped, as moq's `Timed` is, which bytes convert into. +/// A value and when it was stamped, as moq's `Timed` is, which bytes convert into. Hidden, +/// so a parameter that converts into one takes what converts instead. +#[doc(hidden)] pub struct Timed

{ pub value: P, pub at: Option, diff --git a/ffi/surface/api/c.h b/ffi/surface/api/c.h index 0a5137410..bd02435dd 100644 --- a/ffi/surface/api/c.h +++ b/ffi/surface/api/c.h @@ -7,7 +7,7 @@ #ifdef __cplusplus extern "C" { #endif -#define API_CONTRACT ((uint64_t)0xdcf4774fd2b0babdULL) +#define API_CONTRACT ((uint64_t)0x502d1ceb3c7c4082ULL) uint64_t api_contract(void); uint32_t api_target(void); typedef int32_t api_status; @@ -90,6 +90,7 @@ typedef enum api_poll { API_POLL_ERROR = 2, } api_poll; typedef struct api_Board api_Board; +typedef struct api_Tab api_Tab; typedef struct api_Receipt api_Receipt; typedef struct api_Draft api_Draft; typedef struct api_Filed_Receipt api_Filed_Receipt; @@ -805,6 +806,10 @@ typedef struct api_Qualifiers { double api; double kotlin; } api_Qualifiers; +typedef struct api_Spot { + uint32_t x; + uint32_t y; +} api_Spot; typedef struct api_polar_Turn { uint8_t part; } api_polar_Turn; @@ -1201,6 +1206,7 @@ api_Pair_u8_Size api_Pair_u32_beside_Size(const api_Pair_u32 *self, api_Size rig void api_Pair_u8_Size_free(api_Pair_u8_Size *self); bool api_Pair_u8_Size_eq(const api_Pair_u8_Size *a, const api_Pair_u8_Size *b); api_buf api_Pair_u8_Size_debug(const api_Pair_u8_Size *self); +api_Pair_Size_u8 api_Pair_u8_Size_swap(const api_Pair_u8_Size *self); void api_Left_Right_u8_free(api_Left_Right_u8 *self); bool api_Left_Right_u8_eq(const api_Left_Right_u8 *a, const api_Left_Right_u8 *b); api_buf api_Left_Right_u8_debug(const api_Left_Right_u8 *self); @@ -1278,6 +1284,10 @@ bool api_a_eq(const api_a *a, const api_a *b); api_buf api_a_debug(const api_a *self); void api_Qualifiers_free(api_Qualifiers *self); bool api_Qualifiers_eq(const api_Qualifiers *a, const api_Qualifiers *b); +void api_Spot_free(api_Spot *self); +bool api_Spot_eq(const api_Spot *a, const api_Spot *b); +api_buf api_Spot_debug(const api_Spot *self); +bool api_Spot_deserialize(api_Json *deserializer, api_Spot *out, api_buf *err, api_status *status); void api_polar_Point_free(api_polar_Point *self); bool api_polar_Point_eq(const api_polar_Point *a, const api_polar_Point *b); api_buf api_polar_Point_debug(const api_polar_Point *self); @@ -1376,6 +1386,9 @@ api_Board *api_Board_new(api_vec_tuple_string_Counter counters, api_status *stat api_vec_tuple_string_Counter api_Board_into_counters(api_Board *self, api_status *status); api_vec_tuple_string_Counter api_Board_ranked(const api_Board *self, api_status *status); api_Counter *api_Board_best(const api_Board *self, api_status *status); +void api_Tab_free(api_Tab *self); +void api_Tab_drop(api_Tab *self, api_status *status); +api_Ledger *api_Tab_ledger_get(const api_Tab *self, api_status *status); void api_Receipt_free(api_Receipt *self); void api_Receipt_drop(api_Receipt *self, api_status *status); api_Receipt *api_Receipt_clone(const api_Receipt *self, api_status *status); @@ -1397,6 +1410,8 @@ void api_Pad_u16_free(api_Pad_u16 *self); api_Pad_u16 *api_Pad_u16_wide(void); uint16_t api_Pad_u16_tag(const api_Pad_u16 *self); uint16_t api_Pad_u16_title(const api_Pad_u16 *self); +api_buf api_Pad_u16_title_get(const api_Pad_u16 *self); +uint32_t api_Pad_u16_lines(const api_Pad_u16 *self); api_buf api_Pad_u16_describe(const api_Pad_u16 *self); void api_Pad_u8_free(api_Pad_u8 *self); api_Pad_u8 *api_Pad_u8_small(void); @@ -1411,6 +1426,8 @@ void api_Marker_free(api_Marker *self); void api_Marker_drop(api_Marker *self, api_status *status); api_Marker *api_Marker_new(api_buf label, int32_t x, int32_t y); api_buf api_Marker_label(const api_Marker *self, api_status *status); +int32_t api_Marker_x(const api_Marker *self, api_status *status); +int32_t api_Marker_y(void); int32_t api_Marker_x_get(const api_Marker *self, api_status *status); void api_Marker_x_set(api_Marker *self, int32_t value, api_status *status); int32_t api_Marker_y_get(const api_Marker *self, api_status *status); @@ -1483,6 +1500,8 @@ void api_Retry_free(api_Retry *self); void api_Retry_drop(api_Retry *self, api_status *status); api_option_u32 api_Retry_limit_get(const api_Retry *self, api_status *status); void api_Retry_limit_set(api_Retry *self, api_option_u32 value, api_status *status); +api_option_u32 api_Retry_delay_get(const api_Retry *self, api_status *status); +void api_Retry_delay_set(api_Retry *self, api_option_u32 value, api_status *status); api_Retry *api_Retry_new(api_option_u32 limit); uint32_t api_Retry_limit(const api_Retry *self, api_status *status); uint32_t api_Retry_delay(const api_Retry *self, api_status *status); @@ -1500,10 +1519,16 @@ void api_Outer_Inner_u8_free(api_Outer_Inner_u8 *self); api_Outer_Inner_u8 *api_Outer_Inner_u8_new(uint8_t value); uint8_t api_Outer_Inner_u8_get(const api_Outer_Inner_u8 *self); void api_Slot_u32_free(api_Slot_u32 *self); +void api_Slot_u32_drop(api_Slot_u32 *self, api_status *status); +uint32_t api_Slot_u32_value_get(const api_Slot_u32 *self, api_status *status); +void api_Slot_u32_value_set(api_Slot_u32 *self, uint32_t value, api_status *status); api_Slot_u32 *api_Slot_u32_new(uint32_t value); void api_Slot_u8_free(api_Slot_u8 *self); +void api_Slot_u8_drop(api_Slot_u8 *self, api_status *status); +uint8_t api_Slot_u8_value_get(const api_Slot_u8 *self, api_status *status); +void api_Slot_u8_value_set(api_Slot_u8 *self, uint8_t value, api_status *status); api_Slot_u8 *api_Slot_u8_new(uint8_t value); -uint16_t api_Slot_u8_value(const api_Slot_u8 *self); +uint16_t api_Slot_u8_value(const api_Slot_u8 *self, api_status *status); void api_Resolving_free(api_Resolving *self); void api_Resolving_drop(api_Resolving *self, api_status *status); api_tls_Resolver *api_Resolving_0_get(const api_Resolving *self, api_status *status); @@ -1626,6 +1651,7 @@ void api_Ledger_seal(api_Ledger *self, api_status *status); api_Receipt *api_Ledger_receipt(api_Ledger *self, api_status *status); api_Receipt *api_Ledger_noted(api_Ledger *self, api_status *status); api_Filed_Receipt *api_Ledger_file_Receipt(api_Ledger *self, api_Receipt *item, api_status *status); +api_Tab *api_Ledger_tab(api_Ledger *self, api_status *status); api_Slip *api_Ledger_slip(api_Ledger *self, api_status *status); api_Slip *api_Ledger_slip_homed(api_Ledger *self, api_status *status); void api_Slip_free(api_Slip *self); @@ -1744,6 +1770,8 @@ void api_Node_drop(api_Node *self, api_status *status); api_buf api_Node_debug(const api_Node *self, api_status *status); uint64_t api_Node_value_get(const api_Node *self, api_status *status); void api_Node_value_set(api_Node *self, uint64_t value, api_status *status); +api_Node *api_Node_next_get(const api_Node *self, api_status *status); +void api_Node_next_set(api_Node *self, api_Node *value, api_status *status); api_Node *api_Node_new(uint64_t value, api_Node *next, api_status *status); void api_Node_push(api_Node *self, uint64_t value, api_status *status); uint64_t api_Node_sum(const api_Node *self, api_status *status); @@ -1823,6 +1851,7 @@ uint64_t api_Stack_depth_past_Point(const api_Stack *self, api_Point from, api_s uint64_t api_Stack_depth_past_Counter(const api_Stack *self, const api_Counter *from, api_status *status); uint64_t api_Stack_depth_past_Size(const api_Stack *self, api_Size from, api_status *status); uint64_t api_Stack_depth_past_Wrap_u32(const api_Stack *self, api_Wrap_u32 from, api_status *status); +uint64_t api_Stack_depth_past_polar_Point(const api_Stack *self, api_polar_Point from, api_status *status); void api_Refusal_free(api_Refusal *self); void api_Refusal_drop(api_Refusal *self, api_status *status); api_buf api_Refusal_to_string(const api_Refusal *self, api_status *status); @@ -2086,7 +2115,6 @@ uint32_t api_peek(const api_Tally *tally, uint32_t (*peek)(void *data, const api size_t api_len(api_buf payload); api_buf api_hex(api_buf payload); api_buf api_timed_hex(api_buf payload); -api_buf api_timed_text(const api_Json *value, api_status *status); api_buf api_sample_hex(api_buf sample); api_buf api_queued_hex(api_buf queued); api_buf api_tick_name(api_Label tick); @@ -2253,6 +2281,8 @@ api_socket_addr api_same_socket_addr(api_socket_addr v); api_socket_addr_v4 api_same_socket_addr_v4(api_socket_addr_v4 v); api_socket_addr_v6 api_same_socket_addr_v6(api_socket_addr_v6 v); api_ip_addr api_same_ip_addr(api_ip_addr v); +api_buf api_unescaped(api_buf text); +api_buf api_unzeroed(api_buf bytes); uint64_t api_crowded(api_Reading reading, api_Stamp a, api_Stamp b, uint64_t n0, uint64_t n1, uint64_t n2, uint64_t n3, uint64_t n4, uint64_t n5, uint64_t n6, uint64_t n7, uint64_t n8, uint64_t n9, uint64_t n10, uint64_t n11, uint64_t n12, uint64_t n13, uint64_t n14, uint64_t n15, uint64_t n16, uint64_t n17, uint64_t n18, uint64_t n19, uint64_t n20, uint64_t n21, uint64_t n22, uint64_t n23, uint64_t n24, uint64_t n25, uint64_t n26, uint64_t n27, uint64_t n28, uint64_t n29, uint64_t n30, uint64_t n31, uint64_t n32, uint64_t n33, uint64_t n34, uint64_t n35, uint64_t n36, uint64_t n37, uint64_t n38, uint64_t n39, uint64_t n40, uint64_t n41, uint64_t n42, uint64_t n43, uint64_t n44, uint64_t n45, uint64_t n46, uint64_t n47, uint64_t n48, uint64_t n49, uint64_t n50, uint64_t n51, uint64_t n52, uint64_t n53, uint64_t n54, uint64_t n55, uint64_t n56, uint64_t n57, uint64_t n58, uint64_t n59, uint64_t n60, uint64_t n61, uint64_t n62, uint64_t n63, uint64_t n64, uint64_t n65, uint64_t n66, uint64_t n67, uint64_t n68, uint64_t n69, uint64_t n70, uint64_t n71, uint64_t n72, uint64_t n73, uint64_t n74, uint64_t n75, uint64_t n76, uint64_t n77, uint64_t n78, uint64_t n79, uint64_t n80, uint64_t n81, uint64_t n82, uint64_t n83, uint64_t n84, uint64_t n85, uint64_t n86, uint64_t n87, uint64_t n88, uint64_t n89, uint64_t n90, uint64_t n91, uint64_t n92, uint64_t n93, uint64_t n94, uint64_t n95, uint64_t n96, uint64_t n97, uint64_t n98, uint64_t n99, uint64_t n100, uint64_t n101, uint64_t n102, uint64_t n103, uint64_t n104, uint64_t n105, uint64_t n106, uint64_t n107, uint64_t n108, uint64_t n109, uint64_t n110, uint64_t n111, uint64_t n112, uint64_t n113, uint64_t n114, uint64_t n115, uint64_t n116, uint64_t n117, uint64_t n118); uint64_t api_crammed(api_Moment a, api_Moment b, uint64_t n0, uint64_t n1, uint64_t n2, uint64_t n3, uint64_t n4, uint64_t n5, uint64_t n6, uint64_t n7, uint64_t n8, uint64_t n9, uint64_t n10, uint64_t n11, uint64_t n12, uint64_t n13, uint64_t n14, uint64_t n15, uint64_t n16, uint64_t n17, uint64_t n18, uint64_t n19, uint64_t n20, uint64_t n21, uint64_t n22, uint64_t n23, uint64_t n24, uint64_t n25, uint64_t n26, uint64_t n27, uint64_t n28, uint64_t n29, uint64_t n30, uint64_t n31, uint64_t n32, uint64_t n33, uint64_t n34, uint64_t n35, uint64_t n36, uint64_t n37, uint64_t n38, uint64_t n39, uint64_t n40, uint64_t n41, uint64_t n42, uint64_t n43, uint64_t n44, uint64_t n45, uint64_t n46, uint64_t n47, uint64_t n48, uint64_t n49, uint64_t n50, uint64_t n51, uint64_t n52, uint64_t n53, uint64_t n54, uint64_t n55, uint64_t n56, uint64_t n57, uint64_t n58, uint64_t n59, uint64_t n60, uint64_t n61, uint64_t n62, uint64_t n63, uint64_t n64, uint64_t n65, uint64_t n66, uint64_t n67, uint64_t n68, uint64_t n69, uint64_t n70, uint64_t n71, uint64_t n72, uint64_t n73, uint64_t n74, uint64_t n75, uint64_t n76, uint64_t n77, uint64_t n78, uint64_t n79, uint64_t n80, uint64_t n81, uint64_t n82, uint64_t n83, uint64_t n84, uint64_t n85, uint64_t n86, uint64_t n87, uint64_t n88, uint64_t n89, uint64_t n90, uint64_t n91, uint64_t n92, uint64_t n93, uint64_t n94, uint64_t n95, uint64_t n96, uint64_t n97, uint64_t n98, uint64_t n99, uint64_t n100, uint64_t n101, uint64_t n102, uint64_t n103, uint64_t n104, uint64_t n105, uint64_t n106, uint64_t n107, uint64_t n108, uint64_t n109, uint64_t n110, uint64_t n111, uint64_t n112, uint64_t n113, uint64_t n114, uint64_t n115, uint64_t n116, uint64_t n117, uint64_t n118, uint64_t n119, uint64_t n120, uint64_t n121, uint64_t n122, uint64_t n123); uint32_t api_jni_one(void); diff --git a/ffi/surface/api/cpp.hpp b/ffi/surface/api/cpp.hpp index 7717f7551..16f3467e2 100644 --- a/ffi/surface/api/cpp.hpp +++ b/ffi/surface/api/cpp.hpp @@ -35,6 +35,11 @@ namespace api { RUST2_FFI_CALLABLE ::std::vector<::std::tuple<::api::buf, ::api::Counter>> ranked() const; RUST2_FFI_CALLABLE ::api::Counter best() const; }; + class RUST2_FFI_CONSUMABLE Tab { + RUST2_FFI_UNCONSUMED Tab(Tab &&other RUST2_FFI_MOVED_FROM) noexcept = default; + Tab &operator=(Tab &&other) noexcept = default; + RUST2_FFI_CALLABLE ::api::Ledger ledger_get() const; + }; class RUST2_FFI_CONSUMABLE Receipt { RUST2_FFI_UNCONSUMED Receipt(Receipt &&other RUST2_FFI_MOVED_FROM) noexcept = default; Receipt &operator=(Receipt &&other) noexcept = default; @@ -64,6 +69,8 @@ namespace api { static ::api::Pad_u16 wide(); RUST2_FFI_CALLABLE ::std::uint16_t tag() const; RUST2_FFI_CALLABLE ::std::uint16_t title() const; + RUST2_FFI_CALLABLE ::api::buf title_get() const; + RUST2_FFI_CALLABLE ::std::uint32_t lines() const; RUST2_FFI_CALLABLE ::api::buf describe() const; }; class RUST2_FFI_CONSUMABLE Pad_u8 { @@ -86,6 +93,8 @@ namespace api { Marker &operator=(Marker &&other) noexcept = default; static ::api::Marker new_(::api::input label, ::std::int32_t x, ::std::int32_t y); RUST2_FFI_CALLABLE ::api::buf label() const; + RUST2_FFI_CALLABLE ::std::int32_t x() const; + static ::std::int32_t y(); RUST2_FFI_CALLABLE ::std::int32_t x_get() const; RUST2_FFI_CALLABLE void x_set(::std::int32_t value); RUST2_FFI_CALLABLE ::std::int32_t y_get() const; @@ -155,6 +164,8 @@ namespace api { Retry &operator=(Retry &&other) noexcept = default; RUST2_FFI_CALLABLE ::std::optional<::std::uint32_t> limit_get() const; RUST2_FFI_CALLABLE void limit_set(const ::std::optional<::std::uint32_t> &value); + RUST2_FFI_CALLABLE ::std::optional<::std::uint32_t> delay_get() const; + RUST2_FFI_CALLABLE void delay_set(const ::std::optional<::std::uint32_t> &value); static ::api::Retry new_(const ::std::optional<::std::uint32_t> &limit); RUST2_FFI_CALLABLE ::std::uint32_t limit() const; RUST2_FFI_CALLABLE ::std::uint32_t delay() const; @@ -182,11 +193,15 @@ namespace api { class RUST2_FFI_CONSUMABLE Slot_u32 { RUST2_FFI_UNCONSUMED Slot_u32(Slot_u32 &&other RUST2_FFI_MOVED_FROM) noexcept = default; Slot_u32 &operator=(Slot_u32 &&other) noexcept = default; + RUST2_FFI_CALLABLE ::std::uint32_t value_get() const; + RUST2_FFI_CALLABLE void value_set(::std::uint32_t value); static ::api::Slot_u32 new_(::std::uint32_t value); }; class RUST2_FFI_CONSUMABLE Slot_u8 { RUST2_FFI_UNCONSUMED Slot_u8(Slot_u8 &&other RUST2_FFI_MOVED_FROM) noexcept = default; Slot_u8 &operator=(Slot_u8 &&other) noexcept = default; + RUST2_FFI_CALLABLE ::std::uint8_t value_get() const; + RUST2_FFI_CALLABLE void value_set(::std::uint8_t value); static ::api::Slot_u8 new_(::std::uint8_t value); RUST2_FFI_CALLABLE ::std::uint16_t value() const; }; @@ -323,6 +338,7 @@ namespace api { RUST2_FFI_CALLABLE ::api::Receipt receipt(); RUST2_FFI_CALLABLE ::api::Receipt noted(); RUST2_FFI_CALLABLE ::api::Filed_Receipt file_Receipt(::api::Receipt item); + RUST2_FFI_CALLABLE ::api::Tab tab(); RUST2_FFI_CALLABLE ::api::Slip slip(); }; class RUST2_FFI_CONSUMABLE Slip { @@ -431,6 +447,8 @@ namespace api { RUST2_FFI_CALLABLE ::api::buf debug() const; RUST2_FFI_CALLABLE ::std::uint64_t value_get() const; RUST2_FFI_CALLABLE void value_set(::std::uint64_t value); + RUST2_FFI_CALLABLE ::std::optional<::api::Node> next_get() const; + RUST2_FFI_CALLABLE void next_set(::std::optional<::api::Node> value); static ::api::Node new_(::std::uint64_t value, ::std::optional<::api::Node> next); RUST2_FFI_CALLABLE void push(::std::uint64_t value); RUST2_FFI_CALLABLE ::std::uint64_t sum() const; @@ -517,6 +535,7 @@ namespace api { RUST2_FFI_CALLABLE ::std::uint64_t depth_past_Counter(const ::api::Counter &from) const; RUST2_FFI_CALLABLE ::std::uint64_t depth_past_Size(const ::api::Size &from) const; RUST2_FFI_CALLABLE ::std::uint64_t depth_past_Wrap_u32(const ::api::Wrap_u32 &from) const; + RUST2_FFI_CALLABLE ::std::uint64_t depth_past_polar_Point(const ::api::polar_Point &from) const; }; class RUST2_FFI_CONSUMABLE Refusal { RUST2_FFI_UNCONSUMED Refusal(Refusal &&other RUST2_FFI_MOVED_FROM) noexcept = default; @@ -858,6 +877,7 @@ namespace api { friend bool operator==(const Pair_u8_Size &a__, const Pair_u8_Size &b_); friend bool operator!=(const Pair_u8_Size &a__, const Pair_u8_Size &b_); ::api::buf debug() const; + ::api::Pair_Size_u8 swap() const; }; struct Right_u8 { ::std::uint8_t value; @@ -1032,6 +1052,14 @@ namespace api { friend bool operator==(const Qualifiers &a__, const Qualifiers &b_); friend bool operator!=(const Qualifiers &a__, const Qualifiers &b_); }; + struct Spot { + ::std::uint32_t x; + ::std::uint32_t y; + friend bool operator==(const Spot &a__, const Spot &b_); + friend bool operator!=(const Spot &a__, const Spot &b_); + ::api::buf debug() const; + static ::api::result<::api::Spot, ::api::buf> deserialize(::api::Json deserializer); + }; struct polar_Point { ::std::uint8_t turns; ::std::uint32_t distance; @@ -1242,6 +1270,7 @@ namespace api { inline bool operator==(const DoubleArray &a__, const DoubleArray &b_); inline bool operator==(const a &a__, const a &b_); inline bool operator==(const Qualifiers &a__, const Qualifiers &b_); + inline bool operator==(const Spot &a__, const Spot &b_); inline bool operator==(const polar_Point &a__, const polar_Point &b_); inline bool operator==(const polar_Turn &a__, const polar_Turn &b_); inline bool operator==(const clash_Tone &a__, const clash_Tone &b_); @@ -1398,7 +1427,6 @@ namespace api { inline ::std::size_t len(::api::input payload); inline ::api::buf hex(::api::input payload); inline ::api::buf timed_hex(::api::input payload); - inline ::api::buf timed_text(const ::api::Json &value); inline ::api::buf sample_hex(::api::input sample); inline ::api::buf queued_hex(::api::input queued); inline ::api::buf tick_name(const ::api::Label &tick); @@ -1553,6 +1581,8 @@ namespace api { inline ::api::socket_addr_v4 same_socket_addr_v4(::api::socket_addr_v4 v); inline ::api::socket_addr_v6 same_socket_addr_v6(::api::socket_addr_v6 v); inline ::api::ip_addr same_ip_addr(::api::ip_addr v); + inline ::api::buf unescaped(::api::input text); + inline ::api::buf unzeroed(::api::input bytes); inline ::std::uint64_t crowded(const ::api::Reading &reading, const ::api::Stamp &a__, const ::api::Stamp &b_, ::std::uint64_t n0, ::std::uint64_t n1, ::std::uint64_t n2, ::std::uint64_t n3, ::std::uint64_t n4, ::std::uint64_t n5, ::std::uint64_t n6, ::std::uint64_t n7, ::std::uint64_t n8, ::std::uint64_t n9, ::std::uint64_t n10, ::std::uint64_t n11, ::std::uint64_t n12, ::std::uint64_t n13, ::std::uint64_t n14, ::std::uint64_t n15, ::std::uint64_t n16, ::std::uint64_t n17, ::std::uint64_t n18, ::std::uint64_t n19, ::std::uint64_t n20, ::std::uint64_t n21, ::std::uint64_t n22, ::std::uint64_t n23, ::std::uint64_t n24, ::std::uint64_t n25, ::std::uint64_t n26, ::std::uint64_t n27, ::std::uint64_t n28, ::std::uint64_t n29, ::std::uint64_t n30, ::std::uint64_t n31, ::std::uint64_t n32, ::std::uint64_t n33, ::std::uint64_t n34, ::std::uint64_t n35, ::std::uint64_t n36, ::std::uint64_t n37, ::std::uint64_t n38, ::std::uint64_t n39, ::std::uint64_t n40, ::std::uint64_t n41, ::std::uint64_t n42, ::std::uint64_t n43, ::std::uint64_t n44, ::std::uint64_t n45, ::std::uint64_t n46, ::std::uint64_t n47, ::std::uint64_t n48, ::std::uint64_t n49, ::std::uint64_t n50, ::std::uint64_t n51, ::std::uint64_t n52, ::std::uint64_t n53, ::std::uint64_t n54, ::std::uint64_t n55, ::std::uint64_t n56, ::std::uint64_t n57, ::std::uint64_t n58, ::std::uint64_t n59, ::std::uint64_t n60, ::std::uint64_t n61, ::std::uint64_t n62, ::std::uint64_t n63, ::std::uint64_t n64, ::std::uint64_t n65, ::std::uint64_t n66, ::std::uint64_t n67, ::std::uint64_t n68, ::std::uint64_t n69, ::std::uint64_t n70, ::std::uint64_t n71, ::std::uint64_t n72, ::std::uint64_t n73, ::std::uint64_t n74, ::std::uint64_t n75, ::std::uint64_t n76, ::std::uint64_t n77, ::std::uint64_t n78, ::std::uint64_t n79, ::std::uint64_t n80, ::std::uint64_t n81, ::std::uint64_t n82, ::std::uint64_t n83, ::std::uint64_t n84, ::std::uint64_t n85, ::std::uint64_t n86, ::std::uint64_t n87, ::std::uint64_t n88, ::std::uint64_t n89, ::std::uint64_t n90, ::std::uint64_t n91, ::std::uint64_t n92, ::std::uint64_t n93, ::std::uint64_t n94, ::std::uint64_t n95, ::std::uint64_t n96, ::std::uint64_t n97, ::std::uint64_t n98, ::std::uint64_t n99, ::std::uint64_t n100, ::std::uint64_t n101, ::std::uint64_t n102, ::std::uint64_t n103, ::std::uint64_t n104, ::std::uint64_t n105, ::std::uint64_t n106, ::std::uint64_t n107, ::std::uint64_t n108, ::std::uint64_t n109, ::std::uint64_t n110, ::std::uint64_t n111, ::std::uint64_t n112, ::std::uint64_t n113, ::std::uint64_t n114, ::std::uint64_t n115, ::std::uint64_t n116, ::std::uint64_t n117, ::std::uint64_t n118); inline ::std::uint64_t crammed(const ::api::Moment &a__, const ::api::Moment &b_, ::std::uint64_t n0, ::std::uint64_t n1, ::std::uint64_t n2, ::std::uint64_t n3, ::std::uint64_t n4, ::std::uint64_t n5, ::std::uint64_t n6, ::std::uint64_t n7, ::std::uint64_t n8, ::std::uint64_t n9, ::std::uint64_t n10, ::std::uint64_t n11, ::std::uint64_t n12, ::std::uint64_t n13, ::std::uint64_t n14, ::std::uint64_t n15, ::std::uint64_t n16, ::std::uint64_t n17, ::std::uint64_t n18, ::std::uint64_t n19, ::std::uint64_t n20, ::std::uint64_t n21, ::std::uint64_t n22, ::std::uint64_t n23, ::std::uint64_t n24, ::std::uint64_t n25, ::std::uint64_t n26, ::std::uint64_t n27, ::std::uint64_t n28, ::std::uint64_t n29, ::std::uint64_t n30, ::std::uint64_t n31, ::std::uint64_t n32, ::std::uint64_t n33, ::std::uint64_t n34, ::std::uint64_t n35, ::std::uint64_t n36, ::std::uint64_t n37, ::std::uint64_t n38, ::std::uint64_t n39, ::std::uint64_t n40, ::std::uint64_t n41, ::std::uint64_t n42, ::std::uint64_t n43, ::std::uint64_t n44, ::std::uint64_t n45, ::std::uint64_t n46, ::std::uint64_t n47, ::std::uint64_t n48, ::std::uint64_t n49, ::std::uint64_t n50, ::std::uint64_t n51, ::std::uint64_t n52, ::std::uint64_t n53, ::std::uint64_t n54, ::std::uint64_t n55, ::std::uint64_t n56, ::std::uint64_t n57, ::std::uint64_t n58, ::std::uint64_t n59, ::std::uint64_t n60, ::std::uint64_t n61, ::std::uint64_t n62, ::std::uint64_t n63, ::std::uint64_t n64, ::std::uint64_t n65, ::std::uint64_t n66, ::std::uint64_t n67, ::std::uint64_t n68, ::std::uint64_t n69, ::std::uint64_t n70, ::std::uint64_t n71, ::std::uint64_t n72, ::std::uint64_t n73, ::std::uint64_t n74, ::std::uint64_t n75, ::std::uint64_t n76, ::std::uint64_t n77, ::std::uint64_t n78, ::std::uint64_t n79, ::std::uint64_t n80, ::std::uint64_t n81, ::std::uint64_t n82, ::std::uint64_t n83, ::std::uint64_t n84, ::std::uint64_t n85, ::std::uint64_t n86, ::std::uint64_t n87, ::std::uint64_t n88, ::std::uint64_t n89, ::std::uint64_t n90, ::std::uint64_t n91, ::std::uint64_t n92, ::std::uint64_t n93, ::std::uint64_t n94, ::std::uint64_t n95, ::std::uint64_t n96, ::std::uint64_t n97, ::std::uint64_t n98, ::std::uint64_t n99, ::std::uint64_t n100, ::std::uint64_t n101, ::std::uint64_t n102, ::std::uint64_t n103, ::std::uint64_t n104, ::std::uint64_t n105, ::std::uint64_t n106, ::std::uint64_t n107, ::std::uint64_t n108, ::std::uint64_t n109, ::std::uint64_t n110, ::std::uint64_t n111, ::std::uint64_t n112, ::std::uint64_t n113, ::std::uint64_t n114, ::std::uint64_t n115, ::std::uint64_t n116, ::std::uint64_t n117, ::std::uint64_t n118, ::std::uint64_t n119, ::std::uint64_t n120, ::std::uint64_t n121, ::std::uint64_t n122, ::std::uint64_t n123); inline ::std::uint32_t jni_one(); @@ -1874,6 +1904,7 @@ namespace api { struct NonZeros; struct a; struct Qualifiers; + struct Spot; struct polar_Point; struct polar_Turn; struct clash_Tone; @@ -1884,6 +1915,7 @@ namespace api { struct tls_policy_Lifetime; struct Core; class Board; + class Tab; class Receipt; class Draft; class Filed_Receipt; diff --git a/ffi/surface/api/dart.dart b/ffi/surface/api/dart.dart index 3cde662a5..6765177e2 100644 --- a/ffi/surface/api/dart.dart +++ b/ffi/surface/api/dart.dart @@ -408,6 +408,7 @@ final class PairU8Size { String debug(); @override bool operator ==(Object other); @override int get hashCode; + PairSizeU8 swap(); } final class LeftRightU8 { final RightU8 value; @@ -606,6 +607,15 @@ final class Qualifiers { @override bool operator ==(Object other); @override int get hashCode; } +final class Spot { + final int x; + final int y; + const Spot({required this.x, required this.y}); + String debug(); + @override bool operator ==(Object other); + @override int get hashCode; + factory Spot.deserialize(Json deserializer); +} final class PolarPoint { final int turns; final int distance; @@ -941,6 +951,9 @@ final class Board extends _Object { List<(String, Counter)> ranked(); Counter best(); } +final class Tab extends _Object { + Ledger get ledgerGet; +} final class Receipt extends _Object { Receipt clone(); int count(); @@ -962,6 +975,8 @@ final class PadU16 extends _Object { factory PadU16.wide(); int tag(); int title(); + String get titleGet; + int lines(); String describe(); } final class PadU8 extends _Object { @@ -978,6 +993,8 @@ final class Layered extends _Object { final class Marker extends _Object { factory Marker(String label, int x, int y); String label(); + int x(); + static int y(); int get xGet; void xSet(int value); int get yGet; @@ -1030,6 +1047,8 @@ final class LocalWaiter extends _Object { final class Retry extends _Object { int? get limitGet; void limitSet(int? value); + int? get delayGet; + void delaySet(int? value); factory Retry(int? limit); int limit(); int delay(); @@ -1049,9 +1068,13 @@ final class OuterInnerU8 extends _Object { int get(); } final class SlotU32 extends _Object { + int get valueGet; + void valueSet(int value); factory SlotU32(int value); } final class SlotU8 extends _Object { + int get valueGet; + void valueSet(int value); factory SlotU8(int value); int value(); } @@ -1170,6 +1193,7 @@ final class Ledger extends _Object { Receipt receipt(); Receipt noted(); FiledReceipt fileReceipt(Receipt item); + Tab tab(); Slip slip(); } final class Slip extends _Object { @@ -1258,6 +1282,8 @@ final class Node extends _Object { String debug(); U64 get valueGet; void valueSet(U64 value); + Node? get nextGet; + void nextSet(Node? value); factory Node(U64 value, Node? next); void push(U64 value); U64 sum(); @@ -1325,6 +1351,7 @@ final class Stack extends _Object { U64 depthPastCounter(Counter from); U64 depthPastSize(Size from); U64 depthPastWrapU32(WrapU32 from); + U64 depthPastPolarPoint(PolarPoint from); } final class Refusal extends _Object implements Exception { @override String toString(); @@ -1553,7 +1580,6 @@ int peek(Tally tally, int Function(Tally) peek); U64 len(typed.Uint8List payload); String hex(typed.Uint8List payload); String timedHex(typed.Uint8List payload); -String timedText(Json value); String sampleHex(typed.Uint8List sample); String queuedHex(typed.Uint8List queued); String tickName(Label tick); @@ -1708,6 +1734,8 @@ SocketAddr sameSocketAddr(SocketAddr v); SocketAddrV4 sameSocketAddrV4(SocketAddrV4 v); SocketAddrV6 sameSocketAddrV6(SocketAddrV6 v); IpAddr sameIpAddr(IpAddr v); +String unescaped(String text); +typed.Uint8List unzeroed(typed.Uint8List bytes); U64 crowded(Reading reading, Stamp a, Stamp b, U64 n0, U64 n1, U64 n2, U64 n3, U64 n4, U64 n5, U64 n6, U64 n7, U64 n8, U64 n9, U64 n10, U64 n11, U64 n12, U64 n13, U64 n14, U64 n15, U64 n16, U64 n17, U64 n18, U64 n19, U64 n20, U64 n21, U64 n22, U64 n23, U64 n24, U64 n25, U64 n26, U64 n27, U64 n28, U64 n29, U64 n30, U64 n31, U64 n32, U64 n33, U64 n34, U64 n35, U64 n36, U64 n37, U64 n38, U64 n39, U64 n40, U64 n41, U64 n42, U64 n43, U64 n44, U64 n45, U64 n46, U64 n47, U64 n48, U64 n49, U64 n50, U64 n51, U64 n52, U64 n53, U64 n54, U64 n55, U64 n56, U64 n57, U64 n58, U64 n59, U64 n60, U64 n61, U64 n62, U64 n63, U64 n64, U64 n65, U64 n66, U64 n67, U64 n68, U64 n69, U64 n70, U64 n71, U64 n72, U64 n73, U64 n74, U64 n75, U64 n76, U64 n77, U64 n78, U64 n79, U64 n80, U64 n81, U64 n82, U64 n83, U64 n84, U64 n85, U64 n86, U64 n87, U64 n88, U64 n89, U64 n90, U64 n91, U64 n92, U64 n93, U64 n94, U64 n95, U64 n96, U64 n97, U64 n98, U64 n99, U64 n100, U64 n101, U64 n102, U64 n103, U64 n104, U64 n105, U64 n106, U64 n107, U64 n108, U64 n109, U64 n110, U64 n111, U64 n112, U64 n113, U64 n114, U64 n115, U64 n116, U64 n117, U64 n118); U64 crammed(Moment a, Moment b, U64 n0, U64 n1, U64 n2, U64 n3, U64 n4, U64 n5, U64 n6, U64 n7, U64 n8, U64 n9, U64 n10, U64 n11, U64 n12, U64 n13, U64 n14, U64 n15, U64 n16, U64 n17, U64 n18, U64 n19, U64 n20, U64 n21, U64 n22, U64 n23, U64 n24, U64 n25, U64 n26, U64 n27, U64 n28, U64 n29, U64 n30, U64 n31, U64 n32, U64 n33, U64 n34, U64 n35, U64 n36, U64 n37, U64 n38, U64 n39, U64 n40, U64 n41, U64 n42, U64 n43, U64 n44, U64 n45, U64 n46, U64 n47, U64 n48, U64 n49, U64 n50, U64 n51, U64 n52, U64 n53, U64 n54, U64 n55, U64 n56, U64 n57, U64 n58, U64 n59, U64 n60, U64 n61, U64 n62, U64 n63, U64 n64, U64 n65, U64 n66, U64 n67, U64 n68, U64 n69, U64 n70, U64 n71, U64 n72, U64 n73, U64 n74, U64 n75, U64 n76, U64 n77, U64 n78, U64 n79, U64 n80, U64 n81, U64 n82, U64 n83, U64 n84, U64 n85, U64 n86, U64 n87, U64 n88, U64 n89, U64 n90, U64 n91, U64 n92, U64 n93, U64 n94, U64 n95, U64 n96, U64 n97, U64 n98, U64 n99, U64 n100, U64 n101, U64 n102, U64 n103, U64 n104, U64 n105, U64 n106, U64 n107, U64 n108, U64 n109, U64 n110, U64 n111, U64 n112, U64 n113, U64 n114, U64 n115, U64 n116, U64 n117, U64 n118, U64 n119, U64 n120, U64 n121, U64 n122, U64 n123); int jniOne(); diff --git a/ffi/surface/api/go.txt b/ffi/surface/api/go.txt index eec351aa7..61e71c7b3 100644 --- a/ffi/surface/api/go.txt +++ b/ffi/surface/api/go.txt @@ -129,6 +129,7 @@ func Longest(words []string) (uint, error) func Louder(filter *p_tracingcore.Level) *p_tracingcore.Level func Made(n uint32, make_ func(uint32) string) string func Marked(apiMarked *Mark) (uint64, error) +func MarkerY() int32 func Named(name string) (*string, error) func NextChar(c rune) (*rune, error) func NextHop(hop *uint64) (*uint64, error) @@ -223,12 +224,13 @@ func TickName(tick Label) (string, error) func TicketClones() uint32 func Tickets(entries []p_rt.Tuple2[string, Ticket]) ([]p_rt.Tuple2[string, Ticket], error) func TimedHex(payload p_rt.Bytes) string -func TimedText(value *p_serdejson.Json) (string, error) func Title(formal bool) *string func TokenBytes(id uint32, len_ uint32) p_rt.Bytes func TokenSlice(id uint32, len_ uint32, of uint32) p_rt.Bytes func Total(range_ p_rt.RangeU64) uint64 +func Unescaped(text string) (string, error) func Unhook() error +func Unzeroed(bytes p_rt.Bytes) p_rt.Bytes func Verify(cert *p_tls.Cert) (uint32, error) func VisitStray(visit func(string)) func WaiterPollFuture(ctx context.Context, future func(context.Context)) error @@ -987,6 +989,7 @@ func (self *Ledger) Published() (uint32, error) func (self *Ledger) Receipt() (*Receipt, error) func (self *Ledger) Seal() error func (self *Ledger) Slip() (*Slip, error) +func (self *Ledger) Tab() (*Tab, error) func (self *Ledger) Title() (string, error) type LeftRightU8 struct { Value RightU8 @@ -1080,6 +1083,7 @@ func NewMarker(label string, x int32, y int32) (*Marker, error) func (self *Marker) Close() error func (self *Marker) Label() (string, error) func (self *Marker) Offset(dx int32, dy int32) (Point, error) +func (self *Marker) X() (int32, error) func (self *Marker) XGet() (int32, error) func (self *Marker) XSet(value int32) error func (self *Marker) YGet() (int32, error) @@ -1155,6 +1159,8 @@ type Node struct { func NewNode(value uint64, next *Node) (*Node, error) func (self *Node) Close() error func (self *Node) GoString() string +func (self *Node) NextGet() (*Node, error) +func (self *Node) NextSet(value *Node) error func (self *Node) Push(value uint64) error func (self *Node) Sum() (uint64, error) func (self *Node) ValueGet() (uint64, error) @@ -1225,8 +1231,10 @@ type PadU16 struct { func PadU16Wide() *PadU16 func (self *PadU16) Close() error func (self *PadU16) Describe() (string, error) +func (self *PadU16) Lines() (uint32, error) func (self *PadU16) Tag() (uint16, error) func (self *PadU16) Title() (uint16, error) +func (self *PadU16) TitleGet() (string, error) type PadU8 struct { Handle_ *p_rt.Handle_ } @@ -1274,6 +1282,7 @@ type PairU8Size struct { } func (self PairU8Size) Equal(other PairU8Size) bool func (self PairU8Size) GoString() string +func (self PairU8Size) Swap() PairSizeU8 type Parcel struct { Mark *Mark Payload p_rt.Bytes @@ -1416,6 +1425,8 @@ type Retry struct { func NewRetry(limit *uint32) *Retry func (self *Retry) Close() error func (self *Retry) Delay() (uint32, error) +func (self *Retry) DelayGet() (*uint32, error) +func (self *Retry) DelaySet(value *uint32) error func (self *Retry) Limit() (uint32, error) func (self *Retry) LimitGet() (*uint32, error) func (self *Retry) LimitSet(value *uint32) error @@ -1502,12 +1513,16 @@ type SlotU32 struct { func NewSlotU32(value uint32) *SlotU32 func Wide_(value uint32) *SlotU32 func (self *SlotU32) Close() error +func (self *SlotU32) ValueGet() (uint32, error) +func (self *SlotU32) ValueSet(value uint32) error type SlotU8 struct { Handle_ *p_rt.Handle_ } func NewSlotU8(value uint8) *SlotU8 func (self *SlotU8) Close() error func (self *SlotU8) Value() (uint16, error) +func (self *SlotU8) ValueGet() (uint8, error) +func (self *SlotU8) ValueSet(value uint8) error type Span struct { Bounds p_rt.Tuple2[uint32, uint32] Named *p_rt.Tuple2[string, Shape] @@ -1520,6 +1535,13 @@ type Spawned struct { func NewSpawned(task func() uint32) (*Spawned, error) func (self *Spawned) Close() error func (self *Spawned) Join() (uint32, error) +type Spot struct { + X uint32 + Y uint32 +} +func SpotDeserialize(deserializer *p_serdejson.Json) (Spot, error) +func (self Spot) Equal(other Spot) bool +func (self Spot) GoString() string type Stack struct { Handle_ *p_rt.Handle_ } @@ -1529,6 +1551,7 @@ func (self *Stack) Close() error func (self *Stack) Depth() (uint, error) func (self *Stack) DepthPastCounter(from *Counter) (uint64, error) func (self *Stack) DepthPastPoint(from Point) (uint64, error) +func (self *Stack) DepthPastPolarPoint(from PolarPoint) (uint64, error) func (self *Stack) DepthPastSize(from p_dep.Size) (uint64, error) func (self *Stack) DepthPastWrapU32(from WrapU32) (uint64, error) func (self *Stack) GoString() string @@ -1576,6 +1599,11 @@ const ( ) func (self Status) Equal(other Status) bool func (self Status) GoString() string +type Tab struct { + Handle_ *p_rt.Handle_ +} +func (self *Tab) Close() error +func (self *Tab) LedgerGet() (*Ledger, error) type Tallies struct { Handle_ *p_rt.Handle_ } diff --git a/ffi/surface/api/kotlin.kt b/ffi/surface/api/kotlin.kt index 280423217..900b54381 100644 --- a/ffi/surface/api/kotlin.kt +++ b/ffi/surface/api/kotlin.kt @@ -263,6 +263,7 @@ data class PairU32(val left: kotlin.UInt, val right: kotlin.UInt) { } data class PairU8Size(val left: kotlin.UByte, val right: api.Size) { fun debug(): kotlin.String + fun swap(): api.PairSizeU8 } data class LeftRightU8(val value: api.RightU8) { fun debug(): kotlin.String @@ -356,6 +357,12 @@ data class Qualifiers(val api: kotlin.Double, val kotlin: kotlin.Double) { override fun equals(other: kotlin.Any?): kotlin.Boolean override fun hashCode(): kotlin.Int } +data class Spot(val x: kotlin.UInt, val y: kotlin.UInt) { + fun debug(): kotlin.String + companion object { + fun deserialize(deserializer: api.Json): api.Spot + } +} data class PolarPoint(val turns: kotlin.UByte, val distance: kotlin.UInt) { fun debug(): kotlin.String } @@ -537,6 +544,10 @@ class Board internal constructor(raw: Long, lent: Boolean = false) : AutoCloseab fun new(counters: kotlin.collections.List>): api.Board } } +class Tab internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { + override fun close() + val ledgerGet: api.Ledger +} class Receipt internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() fun clone(): api.Receipt @@ -561,6 +572,8 @@ class PadU16 internal constructor(raw: Long, lent: Boolean = false) : AutoClosea override fun close() fun tag(): kotlin.UShort fun title(): kotlin.UShort + val titleGet: kotlin.String + fun lines(): kotlin.UInt fun describe(): kotlin.String companion object { fun wide(): api.PadU16 @@ -586,6 +599,7 @@ class Layered internal constructor(raw: Long, lent: Boolean = false) : AutoClose class Marker internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() fun label(): kotlin.String + fun x(): kotlin.Int val xGet: kotlin.Int fun xSet(value: kotlin.Int) val yGet: kotlin.Int @@ -593,6 +607,7 @@ class Marker internal constructor(raw: Long, lent: Boolean = false) : AutoClosea fun offset(dx: kotlin.Int, dy: kotlin.Int): api.Point companion object { fun new(label: kotlin.String, x: kotlin.Int, y: kotlin.Int): api.Marker + fun y(): kotlin.Int } } class Batch internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { @@ -663,6 +678,8 @@ class Retry internal constructor(raw: Long, lent: Boolean = false) : AutoCloseab override fun close() val limitGet: kotlin.UInt? fun limitSet(value: kotlin.UInt?) + val delayGet: kotlin.UInt? + fun delaySet(value: kotlin.UInt?) fun limit(): kotlin.UInt fun delay(): kotlin.UInt fun setLimit(limit: kotlin.UInt) @@ -692,12 +709,16 @@ class OuterInnerU8 internal constructor(raw: Long, lent: Boolean = false) : Auto } class SlotU32 internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() + val valueGet: kotlin.UInt + fun valueSet(value: kotlin.UInt) companion object { fun new(value: kotlin.UInt): api.SlotU32 } } class SlotU8 internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() + val valueGet: kotlin.UByte + fun valueSet(value: kotlin.UByte) fun value(): kotlin.UShort companion object { fun new(value: kotlin.UByte): api.SlotU8 @@ -857,6 +878,7 @@ class Ledger internal constructor(raw: Long, lent: Boolean = false) : AutoClosea fun receipt(): api.Receipt fun noted(): api.Receipt fun fileReceipt(item: api.Receipt): api.FiledReceipt + fun tab(): api.Tab fun slip(): api.Slip companion object { fun default(): api.Ledger @@ -972,6 +994,8 @@ class Node internal constructor(raw: Long, lent: Boolean = false) : AutoCloseabl fun debug(): kotlin.String val valueGet: kotlin.ULong fun valueSet(value: kotlin.ULong) + val nextGet: api.Node? + fun nextSet(value: api.Node?) fun push(value: kotlin.ULong) fun sum(): kotlin.ULong companion object { @@ -1061,6 +1085,7 @@ class Stack internal constructor(raw: Long, lent: Boolean = false) : AutoCloseab fun depthPastCounter(from: api.Counter): kotlin.ULong fun depthPastSize(from: api.Size): kotlin.ULong fun depthPastWrapU32(from: api.WrapU32): kotlin.ULong + fun depthPastPolarPoint(from: api.PolarPoint): kotlin.ULong companion object { fun default(): api.Stack fun new(): api.Stack @@ -1349,7 +1374,6 @@ fun peek(tally: api.Tally, peek: (api.Tally) -> kotlin.UInt): kotlin.UInt fun len(payload: api.Bytes): kotlin.ULong fun hex(payload: api.Bytes): kotlin.String fun timedHex(payload: api.Bytes): kotlin.String -fun timedText(value: api.Json): kotlin.String fun sampleHex(sample: api.Bytes): kotlin.String fun queuedHex(queued: api.Bytes): kotlin.String fun tickName(tick: api.Label): kotlin.String @@ -1504,6 +1528,8 @@ fun sameSocketAddr(v: api.SocketAddr): api.SocketAddr fun sameSocketAddrV4(v: api.SocketAddrV4): api.SocketAddrV4 fun sameSocketAddrV6(v: api.SocketAddrV6): api.SocketAddrV6 fun sameIpAddr(v: api.IpAddr): api.IpAddr +fun unescaped(text: kotlin.String): kotlin.String +fun unzeroed(bytes: api.Bytes): api.Bytes fun crowded(reading: api.Reading, a: api.Stamp, b: api.Stamp, n0: kotlin.ULong, n1: kotlin.ULong, n2: kotlin.ULong, n3: kotlin.ULong, n4: kotlin.ULong, n5: kotlin.ULong, n6: kotlin.ULong, n7: kotlin.ULong, n8: kotlin.ULong, n9: kotlin.ULong, n10: kotlin.ULong, n11: kotlin.ULong, n12: kotlin.ULong, n13: kotlin.ULong, n14: kotlin.ULong, n15: kotlin.ULong, n16: kotlin.ULong, n17: kotlin.ULong, n18: kotlin.ULong, n19: kotlin.ULong, n20: kotlin.ULong, n21: kotlin.ULong, n22: kotlin.ULong, n23: kotlin.ULong, n24: kotlin.ULong, n25: kotlin.ULong, n26: kotlin.ULong, n27: kotlin.ULong, n28: kotlin.ULong, n29: kotlin.ULong, n30: kotlin.ULong, n31: kotlin.ULong, n32: kotlin.ULong, n33: kotlin.ULong, n34: kotlin.ULong, n35: kotlin.ULong, n36: kotlin.ULong, n37: kotlin.ULong, n38: kotlin.ULong, n39: kotlin.ULong, n40: kotlin.ULong, n41: kotlin.ULong, n42: kotlin.ULong, n43: kotlin.ULong, n44: kotlin.ULong, n45: kotlin.ULong, n46: kotlin.ULong, n47: kotlin.ULong, n48: kotlin.ULong, n49: kotlin.ULong, n50: kotlin.ULong, n51: kotlin.ULong, n52: kotlin.ULong, n53: kotlin.ULong, n54: kotlin.ULong, n55: kotlin.ULong, n56: kotlin.ULong, n57: kotlin.ULong, n58: kotlin.ULong, n59: kotlin.ULong, n60: kotlin.ULong, n61: kotlin.ULong, n62: kotlin.ULong, n63: kotlin.ULong, n64: kotlin.ULong, n65: kotlin.ULong, n66: kotlin.ULong, n67: kotlin.ULong, n68: kotlin.ULong, n69: kotlin.ULong, n70: kotlin.ULong, n71: kotlin.ULong, n72: kotlin.ULong, n73: kotlin.ULong, n74: kotlin.ULong, n75: kotlin.ULong, n76: kotlin.ULong, n77: kotlin.ULong, n78: kotlin.ULong, n79: kotlin.ULong, n80: kotlin.ULong, n81: kotlin.ULong, n82: kotlin.ULong, n83: kotlin.ULong, n84: kotlin.ULong, n85: kotlin.ULong, n86: kotlin.ULong, n87: kotlin.ULong, n88: kotlin.ULong, n89: kotlin.ULong, n90: kotlin.ULong, n91: kotlin.ULong, n92: kotlin.ULong, n93: kotlin.ULong, n94: kotlin.ULong, n95: kotlin.ULong, n96: kotlin.ULong, n97: kotlin.ULong, n98: kotlin.ULong, n99: kotlin.ULong, n100: kotlin.ULong, n101: kotlin.ULong, n102: kotlin.ULong, n103: kotlin.ULong, n104: kotlin.ULong, n105: kotlin.ULong, n106: kotlin.ULong, n107: kotlin.ULong, n108: kotlin.ULong, n109: kotlin.ULong, n110: kotlin.ULong, n111: kotlin.ULong, n112: kotlin.ULong, n113: kotlin.ULong, n114: kotlin.ULong, n115: kotlin.ULong, n116: kotlin.ULong, n117: kotlin.ULong, n118: kotlin.ULong): kotlin.ULong fun crammed(a: api.Moment, b: api.Moment, n0: kotlin.ULong, n1: kotlin.ULong, n2: kotlin.ULong, n3: kotlin.ULong, n4: kotlin.ULong, n5: kotlin.ULong, n6: kotlin.ULong, n7: kotlin.ULong, n8: kotlin.ULong, n9: kotlin.ULong, n10: kotlin.ULong, n11: kotlin.ULong, n12: kotlin.ULong, n13: kotlin.ULong, n14: kotlin.ULong, n15: kotlin.ULong, n16: kotlin.ULong, n17: kotlin.ULong, n18: kotlin.ULong, n19: kotlin.ULong, n20: kotlin.ULong, n21: kotlin.ULong, n22: kotlin.ULong, n23: kotlin.ULong, n24: kotlin.ULong, n25: kotlin.ULong, n26: kotlin.ULong, n27: kotlin.ULong, n28: kotlin.ULong, n29: kotlin.ULong, n30: kotlin.ULong, n31: kotlin.ULong, n32: kotlin.ULong, n33: kotlin.ULong, n34: kotlin.ULong, n35: kotlin.ULong, n36: kotlin.ULong, n37: kotlin.ULong, n38: kotlin.ULong, n39: kotlin.ULong, n40: kotlin.ULong, n41: kotlin.ULong, n42: kotlin.ULong, n43: kotlin.ULong, n44: kotlin.ULong, n45: kotlin.ULong, n46: kotlin.ULong, n47: kotlin.ULong, n48: kotlin.ULong, n49: kotlin.ULong, n50: kotlin.ULong, n51: kotlin.ULong, n52: kotlin.ULong, n53: kotlin.ULong, n54: kotlin.ULong, n55: kotlin.ULong, n56: kotlin.ULong, n57: kotlin.ULong, n58: kotlin.ULong, n59: kotlin.ULong, n60: kotlin.ULong, n61: kotlin.ULong, n62: kotlin.ULong, n63: kotlin.ULong, n64: kotlin.ULong, n65: kotlin.ULong, n66: kotlin.ULong, n67: kotlin.ULong, n68: kotlin.ULong, n69: kotlin.ULong, n70: kotlin.ULong, n71: kotlin.ULong, n72: kotlin.ULong, n73: kotlin.ULong, n74: kotlin.ULong, n75: kotlin.ULong, n76: kotlin.ULong, n77: kotlin.ULong, n78: kotlin.ULong, n79: kotlin.ULong, n80: kotlin.ULong, n81: kotlin.ULong, n82: kotlin.ULong, n83: kotlin.ULong, n84: kotlin.ULong, n85: kotlin.ULong, n86: kotlin.ULong, n87: kotlin.ULong, n88: kotlin.ULong, n89: kotlin.ULong, n90: kotlin.ULong, n91: kotlin.ULong, n92: kotlin.ULong, n93: kotlin.ULong, n94: kotlin.ULong, n95: kotlin.ULong, n96: kotlin.ULong, n97: kotlin.ULong, n98: kotlin.ULong, n99: kotlin.ULong, n100: kotlin.ULong, n101: kotlin.ULong, n102: kotlin.ULong, n103: kotlin.ULong, n104: kotlin.ULong, n105: kotlin.ULong, n106: kotlin.ULong, n107: kotlin.ULong, n108: kotlin.ULong, n109: kotlin.ULong, n110: kotlin.ULong, n111: kotlin.ULong, n112: kotlin.ULong, n113: kotlin.ULong, n114: kotlin.ULong, n115: kotlin.ULong, n116: kotlin.ULong, n117: kotlin.ULong, n118: kotlin.ULong, n119: kotlin.ULong, n120: kotlin.ULong, n121: kotlin.ULong, n122: kotlin.ULong, n123: kotlin.ULong): kotlin.ULong fun jniOne(): kotlin.UInt diff --git a/ffi/surface/api/python.pyi b/ffi/surface/api/python.pyi index 1a31c83bb..8a1ca3dcf 100644 --- a/ffi/surface/api/python.pyi +++ b/ffi/surface/api/python.pyi @@ -236,6 +236,7 @@ class PairU8Size: left: _int right: Size def __repr__(self) -> _str: ... + def swap(self) -> PairSizeU8: ... @_dataclass(slots=True, repr=False) class LeftRightU8: value: RightU8 @@ -372,6 +373,13 @@ class Qualifiers: kotlin: _float def __eq__(self, other: _object) -> _bool: ... @_dataclass(slots=True, repr=False) +class Spot: + x: _int + y: _int + def __repr__(self) -> _str: ... + @_staticmethod + def deserialize(deserializer: Json) -> Spot: ... +@_dataclass(slots=True, repr=False) class PolarPoint: turns: _int distance: _int @@ -653,6 +661,9 @@ class Board(_n.Object): def into_counters(self) -> _list[_tuple[_str, Counter]]: ... def ranked(self) -> _list[_tuple[_str, Counter]]: ... def best(self) -> Counter: ... +class Tab(_n.Object): + @_property + def ledger_get(self) -> Ledger: ... class Receipt(_n.Object): def clone(self) -> Receipt: ... def count(self) -> _int: ... @@ -673,6 +684,9 @@ class PadU16(_n.Object): def wide() -> PadU16: ... def tag(self) -> _int: ... def title(self) -> _int: ... + @_property + def title_get(self) -> _str: ... + def lines(self) -> _int: ... def describe(self) -> _str: ... class PadU8(_n.Object): @_staticmethod @@ -691,6 +705,9 @@ class Marker(_n.Object): @_staticmethod def new(label: _str, x: _int, y: _int) -> Marker: ... def label(self) -> _str: ... + def x(self) -> _int: ... + @_staticmethod + def y() -> _int: ... @_property def x_get(self) -> _int: ... def x_set(self, value: _int) -> None: ... @@ -748,6 +765,9 @@ class Retry(_n.Object): @_property def limit_get(self) -> _int | None: ... def limit_set(self, value: _int | None) -> None: ... + @_property + def delay_get(self) -> _int | None: ... + def delay_set(self, value: _int | None) -> None: ... @_staticmethod def new(limit: _int | None) -> Retry: ... def limit(self) -> _int: ... @@ -767,9 +787,15 @@ class OuterInnerU8(_n.Object): def new(value: _int) -> OuterInnerU8: ... def get(self) -> _int: ... class SlotU32(_n.Object): + @_property + def value_get(self) -> _int: ... + def value_set(self, value: _int) -> None: ... @_staticmethod def new(value: _int) -> SlotU32: ... class SlotU8(_n.Object): + @_property + def value_get(self) -> _int: ... + def value_set(self, value: _int) -> None: ... @_staticmethod def new(value: _int) -> SlotU8: ... def value(self) -> _int: ... @@ -904,6 +930,7 @@ class Ledger(_n.Object): def receipt(self) -> Receipt: ... def noted(self) -> Receipt: ... def file_receipt(self, item: Receipt) -> FiledReceipt: ... + def tab(self) -> Tab: ... def slip(self) -> Slip: ... class Slip(_n.Object): def clone(self) -> Slip: ... @@ -996,6 +1023,9 @@ class Node(_n.Object): @_property def value_get(self) -> _int: ... def value_set(self, value: _int) -> None: ... + @_property + def next_get(self) -> Node | None: ... + def next_set(self, value: Node | None) -> None: ... @_staticmethod def new(value: _int, next: Node | None) -> Node: ... def push(self, value: _int) -> None: ... @@ -1069,6 +1099,7 @@ class Stack(_n.Object): def depth_past_counter(self, from_: Counter) -> _int: ... def depth_past_size(self, from_: Size) -> _int: ... def depth_past_wrap_u32(self, from_: WrapU32) -> _int: ... + def depth_past_polar_point(self, from_: PolarPoint) -> _int: ... class Refusal(_n.Object): def __str__(self) -> _str: ... def __repr__(self) -> _str: ... @@ -1291,7 +1322,6 @@ def peek(tally: Tally, peek: _typing.Callable[[Tally], _int]) -> _int: ... def len(payload: _bytes | _bytearray | _memoryview) -> _int: ... def hex(payload: _bytes | _bytearray | _memoryview) -> _str: ... def timed_hex(payload: _bytes | _bytearray | _memoryview) -> _str: ... -def timed_text(value: Json) -> _str: ... def sample_hex(sample: _bytes | _bytearray | _memoryview) -> _str: ... def queued_hex(queued: _bytes | _bytearray | _memoryview) -> _str: ... def tick_name(tick: Label) -> _str: ... @@ -1441,6 +1471,8 @@ def same_socket_addr(v: _tuple[_str, _int] | _tuple[_str, _int, _int, _int]) -> def same_socket_addr_v4(v: _tuple[_str, _int]) -> _tuple[_str, _int]: ... def same_socket_addr_v6(v: _tuple[_str, _int] | _tuple[_str, _int, _int, _int]) -> _tuple[_str, _int, _int, _int]: ... def same_ip_addr(v: _ipaddress.IPv4Address | _ipaddress.IPv6Address) -> _ipaddress.IPv4Address | _ipaddress.IPv6Address: ... +def unescaped(text: _str) -> _str: ... +def unzeroed(bytes: _bytes | _bytearray | _memoryview) -> _memoryview: ... def crowded(reading: Reading, a: Stamp, b: Stamp, n0: _int, n1: _int, n2: _int, n3: _int, n4: _int, n5: _int, n6: _int, n7: _int, n8: _int, n9: _int, n10: _int, n11: _int, n12: _int, n13: _int, n14: _int, n15: _int, n16: _int, n17: _int, n18: _int, n19: _int, n20: _int, n21: _int, n22: _int, n23: _int, n24: _int, n25: _int, n26: _int, n27: _int, n28: _int, n29: _int, n30: _int, n31: _int, n32: _int, n33: _int, n34: _int, n35: _int, n36: _int, n37: _int, n38: _int, n39: _int, n40: _int, n41: _int, n42: _int, n43: _int, n44: _int, n45: _int, n46: _int, n47: _int, n48: _int, n49: _int, n50: _int, n51: _int, n52: _int, n53: _int, n54: _int, n55: _int, n56: _int, n57: _int, n58: _int, n59: _int, n60: _int, n61: _int, n62: _int, n63: _int, n64: _int, n65: _int, n66: _int, n67: _int, n68: _int, n69: _int, n70: _int, n71: _int, n72: _int, n73: _int, n74: _int, n75: _int, n76: _int, n77: _int, n78: _int, n79: _int, n80: _int, n81: _int, n82: _int, n83: _int, n84: _int, n85: _int, n86: _int, n87: _int, n88: _int, n89: _int, n90: _int, n91: _int, n92: _int, n93: _int, n94: _int, n95: _int, n96: _int, n97: _int, n98: _int, n99: _int, n100: _int, n101: _int, n102: _int, n103: _int, n104: _int, n105: _int, n106: _int, n107: _int, n108: _int, n109: _int, n110: _int, n111: _int, n112: _int, n113: _int, n114: _int, n115: _int, n116: _int, n117: _int, n118: _int) -> _int: ... def crammed(a: Moment, b: Moment, n0: _int, n1: _int, n2: _int, n3: _int, n4: _int, n5: _int, n6: _int, n7: _int, n8: _int, n9: _int, n10: _int, n11: _int, n12: _int, n13: _int, n14: _int, n15: _int, n16: _int, n17: _int, n18: _int, n19: _int, n20: _int, n21: _int, n22: _int, n23: _int, n24: _int, n25: _int, n26: _int, n27: _int, n28: _int, n29: _int, n30: _int, n31: _int, n32: _int, n33: _int, n34: _int, n35: _int, n36: _int, n37: _int, n38: _int, n39: _int, n40: _int, n41: _int, n42: _int, n43: _int, n44: _int, n45: _int, n46: _int, n47: _int, n48: _int, n49: _int, n50: _int, n51: _int, n52: _int, n53: _int, n54: _int, n55: _int, n56: _int, n57: _int, n58: _int, n59: _int, n60: _int, n61: _int, n62: _int, n63: _int, n64: _int, n65: _int, n66: _int, n67: _int, n68: _int, n69: _int, n70: _int, n71: _int, n72: _int, n73: _int, n74: _int, n75: _int, n76: _int, n77: _int, n78: _int, n79: _int, n80: _int, n81: _int, n82: _int, n83: _int, n84: _int, n85: _int, n86: _int, n87: _int, n88: _int, n89: _int, n90: _int, n91: _int, n92: _int, n93: _int, n94: _int, n95: _int, n96: _int, n97: _int, n98: _int, n99: _int, n100: _int, n101: _int, n102: _int, n103: _int, n104: _int, n105: _int, n106: _int, n107: _int, n108: _int, n109: _int, n110: _int, n111: _int, n112: _int, n113: _int, n114: _int, n115: _int, n116: _int, n117: _int, n118: _int, n119: _int, n120: _int, n121: _int, n122: _int, n123: _int) -> _int: ... def jni_one() -> _int: ... @@ -1547,7 +1579,6 @@ peek = _n.peek len = _n.len hex = _n.hex timed_hex = _n.timed_hex -timed_text = _n.timed_text sample_hex = _n.sample_hex queued_hex = _n.queued_hex tick_name = _n.tick_name @@ -1697,6 +1728,8 @@ same_socket_addr = _n.same_socket_addr same_socket_addr_v4 = _n.same_socket_addr_v4 same_socket_addr_v6 = _n.same_socket_addr_v6 same_ip_addr = _n.same_ip_addr +unescaped = _n.unescaped +unzeroed = _n.unzeroed crowded = _n.crowded crammed = _n.crammed jni_one = _n.jni_one diff --git a/ffi/surface/api/swift.swift b/ffi/surface/api/swift.swift index cc6d70a84..f5528d84c 100644 --- a/ffi/surface/api/swift.swift +++ b/ffi/surface/api/swift.swift @@ -396,6 +396,7 @@ public struct PairU8Size: Sendable, CustomDebugStringConvertible, Equatable { @inlinable public init(left: Swift.UInt8, right: Size) @inlinable public var debugDescription: Swift.String { get } @inlinable public static func == (a: PairU8Size, b: PairU8Size) -> Swift.Bool + @inlinable public func swap() -> PairSizeU8 } public struct LeftRightU8: Sendable, CustomDebugStringConvertible, Equatable { public var value: RightU8 @@ -571,6 +572,14 @@ public struct Qualifiers: Sendable, Equatable { @inlinable public init(api: Swift.Double, kotlin: Swift.Double) @inlinable public static func == (a: Qualifiers, b: Qualifiers) -> Swift.Bool } +public struct Spot: Sendable, CustomDebugStringConvertible, Equatable { + public var x: Swift.UInt32 + public var y: Swift.UInt32 + @inlinable public init(x: Swift.UInt32, y: Swift.UInt32) + @inlinable public var debugDescription: Swift.String { get } + @inlinable public static func == (a: Spot, b: Spot) -> Swift.Bool + @inlinable public static func deserialize(_ deserializer: consuming Json) throws -> Spot +} public struct PolarPoint: Sendable, CustomDebugStringConvertible, Equatable { public var turns: Swift.UInt8 public var distance: Swift.UInt32 @@ -764,6 +773,9 @@ public struct Board: ~Copyable, @unchecked Sendable { @inlinable public func ranked() throws -> UniqueArray @inlinable public func best() throws -> Counter } +public struct Tab: ~Copyable, @unchecked Sendable { + @inlinable public func ledgerGet() throws -> Ledger +} public struct Receipt: ~Copyable, @unchecked Sendable { @inlinable public func clone() throws -> Receipt @inlinable public func count() throws -> Swift.UInt32 @@ -785,6 +797,8 @@ public struct PadU16: ~Copyable, @unchecked Sendable { @inlinable public static func wide() -> PadU16 @inlinable public func tag() -> Swift.UInt16 @inlinable public func title() -> Swift.UInt16 + @inlinable public var titleGet: Swift.String { get } + @inlinable public func lines() -> Swift.UInt32 @inlinable public func describe() -> Swift.String } public struct PadU8: ~Copyable, @unchecked Sendable { @@ -801,6 +815,8 @@ public struct Layered: ~Copyable, @unchecked Sendable { public struct Marker: ~Copyable, @unchecked Sendable { @inlinable public static func new(_ label: Swift.String, _ x: Swift.Int32, _ y: Swift.Int32) -> Marker @inlinable public func label() throws -> Swift.String + @inlinable public func x() throws -> Swift.Int32 + @inlinable public static func y() -> Swift.Int32 @inlinable public var xGet: Swift.Int32 { get } @inlinable public mutating func xSet(_ value: Swift.Int32) throws @inlinable public var yGet: Swift.Int32 { get } @@ -853,6 +869,8 @@ public struct LocalWaiter: ~Copyable { public struct Retry: ~Copyable, @unchecked Sendable { @inlinable public var limitGet: Swift.UInt32? { get } @inlinable public mutating func limitSet(_ value: Swift.UInt32?) throws + @inlinable public var delayGet: Swift.UInt32? { get } + @inlinable public mutating func delaySet(_ value: Swift.UInt32?) throws @inlinable public static func new(_ limit: Swift.UInt32?) -> Retry @inlinable public func limit() throws -> Swift.UInt32 @inlinable public func delay() throws -> Swift.UInt32 @@ -872,11 +890,15 @@ public struct OuterInnerU8: ~Copyable, @unchecked Sendable { @inlinable public func get() -> Swift.UInt8 } public struct SlotU32: ~Copyable, @unchecked Sendable { + @inlinable public var valueGet: Swift.UInt32 { get } + @inlinable public mutating func valueSet(_ value: Swift.UInt32) throws @inlinable public static func new(_ value: Swift.UInt32) -> SlotU32 } public struct SlotU8: ~Copyable, @unchecked Sendable { + @inlinable public var valueGet: Swift.UInt8 { get } + @inlinable public mutating func valueSet(_ value: Swift.UInt8) throws @inlinable public static func new(_ value: Swift.UInt8) -> SlotU8 - @inlinable public func value() -> Swift.UInt16 + @inlinable public func value() throws -> Swift.UInt16 } public struct Resolving: ~Copyable, @unchecked Sendable { @inlinable public func _0_get() throws -> TlsResolver @@ -998,6 +1020,7 @@ public struct Ledger: ~Copyable, @unchecked Sendable { @inlinable public mutating func receipt() throws -> Receipt @inlinable public mutating func noted() throws -> Receipt @inlinable public mutating func fileReceipt(_ item: consuming Receipt) throws -> FiledReceipt + @inlinable public mutating func tab() throws -> Tab @inlinable public mutating func slip() throws -> Slip } public struct Slip: ~Copyable { @@ -1083,6 +1106,8 @@ public struct Node: ~Copyable, @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } @inlinable public var valueGet: Swift.UInt64 { get } @inlinable public mutating func valueSet(_ value: Swift.UInt64) throws + @inlinable public func nextGet() throws -> Node? + @inlinable public mutating func nextSet(_ value: consuming Node?) throws @inlinable public static func new(_ value: Swift.UInt64, _ next: consuming Node?) throws -> Node @inlinable public mutating func push(_ value: Swift.UInt64) throws @inlinable public func sum() throws -> Swift.UInt64 @@ -1152,6 +1177,7 @@ public struct Stack: ~Copyable, @unchecked Sendable { @inlinable public func depthPastCounter(_ from: borrowing Counter) throws -> Swift.UInt64 @inlinable public func depthPastSize(_ from: Size) throws -> Swift.UInt64 @inlinable public func depthPastWrapU32(_ from: WrapU32) throws -> Swift.UInt64 + @inlinable public func depthPastPolarPoint(_ from: PolarPoint) throws -> Swift.UInt64 } public final class Refusal: @unchecked Sendable { @inlinable public var description: Swift.String { get } @@ -1383,7 +1409,6 @@ public let FAR: Swift.Int64 @inlinable public func len(_ payload: Bytes) -> Swift.UInt @inlinable public func hex(_ payload: Bytes) -> Swift.String @inlinable public func timedHex(_ payload: Bytes) -> Swift.String -@inlinable public func timedText(_ value: borrowing Json) throws -> Swift.String @inlinable public func sampleHex(_ sample: Bytes) -> Swift.String @inlinable public func queuedHex(_ queued: Bytes) -> Swift.String @inlinable public func tickName(_ tick: Label) -> Swift.String @@ -1538,6 +1563,8 @@ public let FAR: Swift.Int64 @inlinable public func sameSocketAddrV4(_ v: SocketAddrV4) -> SocketAddrV4 @inlinable public func sameSocketAddrV6(_ v: SocketAddrV6) -> SocketAddrV6 @inlinable public func sameIpAddr(_ v: IpAddr) -> IpAddr +@inlinable public func unescaped(_ text: Swift.String) -> Swift.String +@inlinable public func unzeroed(_ bytes: Bytes) -> Bytes @inlinable public func crowded(_ reading: Reading, _ a: Stamp, _ b: Stamp, _ n0: Swift.UInt64, _ n1: Swift.UInt64, _ n2: Swift.UInt64, _ n3: Swift.UInt64, _ n4: Swift.UInt64, _ n5: Swift.UInt64, _ n6: Swift.UInt64, _ n7: Swift.UInt64, _ n8: Swift.UInt64, _ n9: Swift.UInt64, _ n10: Swift.UInt64, _ n11: Swift.UInt64, _ n12: Swift.UInt64, _ n13: Swift.UInt64, _ n14: Swift.UInt64, _ n15: Swift.UInt64, _ n16: Swift.UInt64, _ n17: Swift.UInt64, _ n18: Swift.UInt64, _ n19: Swift.UInt64, _ n20: Swift.UInt64, _ n21: Swift.UInt64, _ n22: Swift.UInt64, _ n23: Swift.UInt64, _ n24: Swift.UInt64, _ n25: Swift.UInt64, _ n26: Swift.UInt64, _ n27: Swift.UInt64, _ n28: Swift.UInt64, _ n29: Swift.UInt64, _ n30: Swift.UInt64, _ n31: Swift.UInt64, _ n32: Swift.UInt64, _ n33: Swift.UInt64, _ n34: Swift.UInt64, _ n35: Swift.UInt64, _ n36: Swift.UInt64, _ n37: Swift.UInt64, _ n38: Swift.UInt64, _ n39: Swift.UInt64, _ n40: Swift.UInt64, _ n41: Swift.UInt64, _ n42: Swift.UInt64, _ n43: Swift.UInt64, _ n44: Swift.UInt64, _ n45: Swift.UInt64, _ n46: Swift.UInt64, _ n47: Swift.UInt64, _ n48: Swift.UInt64, _ n49: Swift.UInt64, _ n50: Swift.UInt64, _ n51: Swift.UInt64, _ n52: Swift.UInt64, _ n53: Swift.UInt64, _ n54: Swift.UInt64, _ n55: Swift.UInt64, _ n56: Swift.UInt64, _ n57: Swift.UInt64, _ n58: Swift.UInt64, _ n59: Swift.UInt64, _ n60: Swift.UInt64, _ n61: Swift.UInt64, _ n62: Swift.UInt64, _ n63: Swift.UInt64, _ n64: Swift.UInt64, _ n65: Swift.UInt64, _ n66: Swift.UInt64, _ n67: Swift.UInt64, _ n68: Swift.UInt64, _ n69: Swift.UInt64, _ n70: Swift.UInt64, _ n71: Swift.UInt64, _ n72: Swift.UInt64, _ n73: Swift.UInt64, _ n74: Swift.UInt64, _ n75: Swift.UInt64, _ n76: Swift.UInt64, _ n77: Swift.UInt64, _ n78: Swift.UInt64, _ n79: Swift.UInt64, _ n80: Swift.UInt64, _ n81: Swift.UInt64, _ n82: Swift.UInt64, _ n83: Swift.UInt64, _ n84: Swift.UInt64, _ n85: Swift.UInt64, _ n86: Swift.UInt64, _ n87: Swift.UInt64, _ n88: Swift.UInt64, _ n89: Swift.UInt64, _ n90: Swift.UInt64, _ n91: Swift.UInt64, _ n92: Swift.UInt64, _ n93: Swift.UInt64, _ n94: Swift.UInt64, _ n95: Swift.UInt64, _ n96: Swift.UInt64, _ n97: Swift.UInt64, _ n98: Swift.UInt64, _ n99: Swift.UInt64, _ n100: Swift.UInt64, _ n101: Swift.UInt64, _ n102: Swift.UInt64, _ n103: Swift.UInt64, _ n104: Swift.UInt64, _ n105: Swift.UInt64, _ n106: Swift.UInt64, _ n107: Swift.UInt64, _ n108: Swift.UInt64, _ n109: Swift.UInt64, _ n110: Swift.UInt64, _ n111: Swift.UInt64, _ n112: Swift.UInt64, _ n113: Swift.UInt64, _ n114: Swift.UInt64, _ n115: Swift.UInt64, _ n116: Swift.UInt64, _ n117: Swift.UInt64, _ n118: Swift.UInt64) -> Swift.UInt64 @inlinable public func crammed(_ a: Moment, _ b: Moment, _ n0: Swift.UInt64, _ n1: Swift.UInt64, _ n2: Swift.UInt64, _ n3: Swift.UInt64, _ n4: Swift.UInt64, _ n5: Swift.UInt64, _ n6: Swift.UInt64, _ n7: Swift.UInt64, _ n8: Swift.UInt64, _ n9: Swift.UInt64, _ n10: Swift.UInt64, _ n11: Swift.UInt64, _ n12: Swift.UInt64, _ n13: Swift.UInt64, _ n14: Swift.UInt64, _ n15: Swift.UInt64, _ n16: Swift.UInt64, _ n17: Swift.UInt64, _ n18: Swift.UInt64, _ n19: Swift.UInt64, _ n20: Swift.UInt64, _ n21: Swift.UInt64, _ n22: Swift.UInt64, _ n23: Swift.UInt64, _ n24: Swift.UInt64, _ n25: Swift.UInt64, _ n26: Swift.UInt64, _ n27: Swift.UInt64, _ n28: Swift.UInt64, _ n29: Swift.UInt64, _ n30: Swift.UInt64, _ n31: Swift.UInt64, _ n32: Swift.UInt64, _ n33: Swift.UInt64, _ n34: Swift.UInt64, _ n35: Swift.UInt64, _ n36: Swift.UInt64, _ n37: Swift.UInt64, _ n38: Swift.UInt64, _ n39: Swift.UInt64, _ n40: Swift.UInt64, _ n41: Swift.UInt64, _ n42: Swift.UInt64, _ n43: Swift.UInt64, _ n44: Swift.UInt64, _ n45: Swift.UInt64, _ n46: Swift.UInt64, _ n47: Swift.UInt64, _ n48: Swift.UInt64, _ n49: Swift.UInt64, _ n50: Swift.UInt64, _ n51: Swift.UInt64, _ n52: Swift.UInt64, _ n53: Swift.UInt64, _ n54: Swift.UInt64, _ n55: Swift.UInt64, _ n56: Swift.UInt64, _ n57: Swift.UInt64, _ n58: Swift.UInt64, _ n59: Swift.UInt64, _ n60: Swift.UInt64, _ n61: Swift.UInt64, _ n62: Swift.UInt64, _ n63: Swift.UInt64, _ n64: Swift.UInt64, _ n65: Swift.UInt64, _ n66: Swift.UInt64, _ n67: Swift.UInt64, _ n68: Swift.UInt64, _ n69: Swift.UInt64, _ n70: Swift.UInt64, _ n71: Swift.UInt64, _ n72: Swift.UInt64, _ n73: Swift.UInt64, _ n74: Swift.UInt64, _ n75: Swift.UInt64, _ n76: Swift.UInt64, _ n77: Swift.UInt64, _ n78: Swift.UInt64, _ n79: Swift.UInt64, _ n80: Swift.UInt64, _ n81: Swift.UInt64, _ n82: Swift.UInt64, _ n83: Swift.UInt64, _ n84: Swift.UInt64, _ n85: Swift.UInt64, _ n86: Swift.UInt64, _ n87: Swift.UInt64, _ n88: Swift.UInt64, _ n89: Swift.UInt64, _ n90: Swift.UInt64, _ n91: Swift.UInt64, _ n92: Swift.UInt64, _ n93: Swift.UInt64, _ n94: Swift.UInt64, _ n95: Swift.UInt64, _ n96: Swift.UInt64, _ n97: Swift.UInt64, _ n98: Swift.UInt64, _ n99: Swift.UInt64, _ n100: Swift.UInt64, _ n101: Swift.UInt64, _ n102: Swift.UInt64, _ n103: Swift.UInt64, _ n104: Swift.UInt64, _ n105: Swift.UInt64, _ n106: Swift.UInt64, _ n107: Swift.UInt64, _ n108: Swift.UInt64, _ n109: Swift.UInt64, _ n110: Swift.UInt64, _ n111: Swift.UInt64, _ n112: Swift.UInt64, _ n113: Swift.UInt64, _ n114: Swift.UInt64, _ n115: Swift.UInt64, _ n116: Swift.UInt64, _ n117: Swift.UInt64, _ n118: Swift.UInt64, _ n119: Swift.UInt64, _ n120: Swift.UInt64, _ n121: Swift.UInt64, _ n122: Swift.UInt64, _ n123: Swift.UInt64) -> Swift.UInt64 @inlinable public func jniOne() -> Swift.UInt32 diff --git a/ffi/surface/api/web.d.ts b/ffi/surface/api/web.d.ts index 19c475741..ddf08ca0b 100644 --- a/ffi/surface/api/web.d.ts +++ b/ffi/surface/api/web.d.ts @@ -620,6 +620,7 @@ import type { Error_ } from "./Error_.ts"; import type { FiledReceipt } from "./FiledReceipt.ts"; import type { Receipt } from "./Receipt.ts"; import type { Slip } from "./Slip.ts"; +import type { Tab } from "./Tab.ts"; export type Ledger = rt.Handle<"Ledger">; export declare function default$(): Ledger; export declare function new$(): Ledger; @@ -630,6 +631,7 @@ export declare function seal(self: Ledger): void; export declare function receipt(self: Ledger): Receipt; export declare function noted(self: Ledger): Receipt; export declare function fileReceipt(self: Ledger, item: Receipt): FiledReceipt; +export declare function tab(self: Ledger): Tab; export declare function slip(self: Ledger): Slip; export { default$ as default, new$ as new }; @@ -739,6 +741,8 @@ import type { Point } from "./Point.ts"; export type Marker = rt.Handle<"Marker">; export declare function new$(label: string, x: number, y: number): Marker; export declare function label(self: Marker): string; +export declare function x(self: Marker): number; +export declare function y(): number; export declare function xGet(self: Marker): number; export declare function xSet(self: Marker, value: number): void; export declare function yGet(self: Marker): number; @@ -823,6 +827,8 @@ export type Node = rt.Handle<"Node">; export declare function debug(self: Node): string; export declare function valueGet(self: Node): rt.u64; export declare function valueSet(self: Node, value: rt.u64): void; +export declare function nextGet(self: Node): Node | undefined; +export declare function nextSet(self: Node, value: Node | undefined): void; export declare function new$(value: rt.u64, next: Node | undefined): Node; export declare function push(self: Node, value: rt.u64): void; export declare function sum(self: Node): rt.u64; @@ -909,6 +915,8 @@ export type PadU16 = rt.Handle<"PadU16">; export declare function wide(): PadU16; export declare function tag(self: PadU16): number; export declare function title(self: PadU16): number; +export declare function titleGet(self: PadU16): string; +export declare function lines(self: PadU16): number; export declare function describe(self: PadU16): string; // PadU8.ts @@ -964,6 +972,7 @@ export declare function sum(self: PairU32): number; export declare function besideSize(self: PairU32, right: Size): PairU8Size; // PairU8Size.ts +import type { PairSizeU8 } from "./PairSizeU8.ts"; import type { Size } from "./Size.ts"; export type PairU8Size = { left: number; @@ -971,6 +980,7 @@ export type PairU8Size = { }; export declare function debug(self: PairU8Size): string; export declare function eq(a: PairU8Size, b: PairU8Size): boolean; +export declare function swap(self: PairU8Size): PairSizeU8; // Parcel.ts import type { Mark } from "./Mark.ts"; @@ -1117,6 +1127,8 @@ import * as rt from "./rt.ts"; export type Retry = rt.Handle<"Retry">; export declare function limitGet(self: Retry): number | undefined; export declare function limitSet(self: Retry, value: number | undefined): void; +export declare function delayGet(self: Retry): number | undefined; +export declare function delaySet(self: Retry, value: number | undefined): void; export declare function new$(limit: number | undefined): Retry; export declare function limit(self: Retry): number; export declare function delay(self: Retry): number; @@ -1222,12 +1234,16 @@ export declare function count(self: Slip): number; // SlotU32.ts import * as rt from "./rt.ts"; export type SlotU32 = rt.Handle<"SlotU32">; +export declare function valueGet(self: SlotU32): number; +export declare function valueSet(self: SlotU32, value: number): void; export declare function new$(value: number): SlotU32; export { new$ as new }; // SlotU8.ts import * as rt from "./rt.ts"; export type SlotU8 = rt.Handle<"SlotU8">; +export declare function valueGet(self: SlotU8): number; +export declare function valueSet(self: SlotU8, value: number): void; export declare function new$(value: number): SlotU8; export declare function value(self: SlotU8): number; export { new$ as new }; @@ -1241,10 +1257,22 @@ export type Span = { export declare function debug(self: Span): string; export declare function eq(a: Span, b: Span): boolean; +// Spot.ts +import * as rt from "./rt.ts"; +import type { Json } from "./Json.ts"; +export type Spot = { + x: number; + y: number; +}; +export declare function debug(self: Spot): string; +export declare function eq(a: Spot, b: Spot): boolean; +export declare function deserialize(deserializer: Json): rt.Result; + // Stack.ts import * as rt from "./rt.ts"; import type { Counter } from "./Counter.ts"; import type { Point } from "./Point.ts"; +import type { PolarPoint } from "./PolarPoint.ts"; import type { Size } from "./Size.ts"; import type { WrapU32 } from "./WrapU32.ts"; export type Stack = rt.Handle<"Stack">; @@ -1258,6 +1286,7 @@ export declare function depthPastPoint(self: Stack, from: Point): rt.u64; export declare function depthPastCounter(self: Stack, from: Counter): rt.u64; export declare function depthPastSize(self: Stack, from: Size): rt.u64; export declare function depthPastWrapU32(self: Stack, from: WrapU32): rt.u64; +export declare function depthPastPolarPoint(self: Stack, from: PolarPoint): rt.u64; export { default$ as default, new$ as new }; // Stage.ts @@ -1305,6 +1334,12 @@ export declare function debug(self: Status): string; import * as rt from "./rt.ts"; export type StdIoError = rt.Handle<"StdIoError">; +// Tab.ts +import * as rt from "./rt.ts"; +import type { Ledger } from "./Ledger.ts"; +export type Tab = rt.Handle<"Tab">; +export declare function ledgerGet(self: Tab): Ledger; + // Tallies.ts import * as rt from "./rt.ts"; import type { Tally } from "./Tally.ts"; @@ -1554,6 +1589,7 @@ import type { Shadowed } from "./Shadowed.ts"; import type { Shape } from "./Shape.ts"; import type { Size } from "./Size.ts"; import type { Span } from "./Span.ts"; +import type { Spot } from "./Spot.ts"; import type { Stage } from "./Stage.ts"; import type { Stamp } from "./Stamp.ts"; import type { Stamped } from "./Stamped.ts"; @@ -1643,6 +1679,7 @@ export declare const k_Slip: rt.Kind; export declare const k_Slot_u32: rt.Kind; export declare const k_Slot_u8: rt.Kind; export declare const k_Stack: rt.Kind; +export declare const k_Tab: rt.Kind; export declare const k_Tallies: rt.Kind; export declare const k_Tally: rt.Kind; export declare const k_Token: rt.Kind; @@ -1729,6 +1766,7 @@ export declare function r_Reading(p: number, o: boolean): Reading; export declare function r_Score(p: number, o: boolean): Score; export declare function r_Seat(p: number, o: boolean): Seat; export declare function r_Size(p: number, o: boolean): Size; +export declare function r_Spot(p: number, o: boolean): Spot; export declare function r_Stage(p: number, o: boolean): Stage; export declare function r_Stamp(p: number, o: boolean): Stamp; export declare function r_Ticket(p: number, o: boolean): Ticket; @@ -1915,6 +1953,7 @@ export declare function w_Seat(p: number, v: Seat): void; export declare function w_Shadowed(p: number, v: Shadowed): void; export declare function w_Size(p: number, v: Size): void; export declare function w_Span(p: number, v: Span): void; +export declare function w_Spot(p: number, v: Spot): void; export declare function w_Stage(p: number, v: Stage): void; export declare function w_Stamp(p: number, v: Stamp): void; export declare function w_Stamped(p: number, v: Stamped): void; @@ -2306,7 +2345,6 @@ export declare function peek(tally: Tally, peek: (a0: Tally) => number): number; export declare function len(payload: Uint8Array | rt.Bytes): number; export declare function hex(payload: Uint8Array | rt.Bytes): string; export declare function timedHex(payload: Uint8Array | rt.Bytes): string; -export declare function timedText(value: Json): string; export declare function sampleHex(sample: Uint8Array | rt.Bytes): string; export declare function queuedHex(queued: Uint8Array | rt.Bytes): string; export declare function tickName(tick: Label): string; @@ -2461,6 +2499,8 @@ export declare function sameSocketAddr(v: rt.SocketAddr): rt.SocketAddr; export declare function sameSocketAddrV4(v: rt.SocketAddrV4): rt.SocketAddrV4; export declare function sameSocketAddrV6(v: rt.SocketAddrV6): rt.SocketAddrV6; export declare function sameIpAddr(v: rt.IpAddr): rt.IpAddr; +export declare function unescaped(text: string): string; +export declare function unzeroed(bytes: Uint8Array | rt.Bytes): rt.Bytes; export declare function crowded(reading: Reading, a: Stamp, b: Stamp, n0: rt.u64, n1: rt.u64, n2: rt.u64, n3: rt.u64, n4: rt.u64, n5: rt.u64, n6: rt.u64, n7: rt.u64, n8: rt.u64, n9: rt.u64, n10: rt.u64, n11: rt.u64, n12: rt.u64, n13: rt.u64, n14: rt.u64, n15: rt.u64, n16: rt.u64, n17: rt.u64, n18: rt.u64, n19: rt.u64, n20: rt.u64, n21: rt.u64, n22: rt.u64, n23: rt.u64, n24: rt.u64, n25: rt.u64, n26: rt.u64, n27: rt.u64, n28: rt.u64, n29: rt.u64, n30: rt.u64, n31: rt.u64, n32: rt.u64, n33: rt.u64, n34: rt.u64, n35: rt.u64, n36: rt.u64, n37: rt.u64, n38: rt.u64, n39: rt.u64, n40: rt.u64, n41: rt.u64, n42: rt.u64, n43: rt.u64, n44: rt.u64, n45: rt.u64, n46: rt.u64, n47: rt.u64, n48: rt.u64, n49: rt.u64, n50: rt.u64, n51: rt.u64, n52: rt.u64, n53: rt.u64, n54: rt.u64, n55: rt.u64, n56: rt.u64, n57: rt.u64, n58: rt.u64, n59: rt.u64, n60: rt.u64, n61: rt.u64, n62: rt.u64, n63: rt.u64, n64: rt.u64, n65: rt.u64, n66: rt.u64, n67: rt.u64, n68: rt.u64, n69: rt.u64, n70: rt.u64, n71: rt.u64, n72: rt.u64, n73: rt.u64, n74: rt.u64, n75: rt.u64, n76: rt.u64, n77: rt.u64, n78: rt.u64, n79: rt.u64, n80: rt.u64, n81: rt.u64, n82: rt.u64, n83: rt.u64, n84: rt.u64, n85: rt.u64, n86: rt.u64, n87: rt.u64, n88: rt.u64, n89: rt.u64, n90: rt.u64, n91: rt.u64, n92: rt.u64, n93: rt.u64, n94: rt.u64, n95: rt.u64, n96: rt.u64, n97: rt.u64, n98: rt.u64, n99: rt.u64, n100: rt.u64, n101: rt.u64, n102: rt.u64, n103: rt.u64, n104: rt.u64, n105: rt.u64, n106: rt.u64, n107: rt.u64, n108: rt.u64, n109: rt.u64, n110: rt.u64, n111: rt.u64, n112: rt.u64, n113: rt.u64, n114: rt.u64, n115: rt.u64, n116: rt.u64, n117: rt.u64, n118: rt.u64): rt.u64; export declare function crammed(a: Moment, b: Moment, n0: rt.u64, n1: rt.u64, n2: rt.u64, n3: rt.u64, n4: rt.u64, n5: rt.u64, n6: rt.u64, n7: rt.u64, n8: rt.u64, n9: rt.u64, n10: rt.u64, n11: rt.u64, n12: rt.u64, n13: rt.u64, n14: rt.u64, n15: rt.u64, n16: rt.u64, n17: rt.u64, n18: rt.u64, n19: rt.u64, n20: rt.u64, n21: rt.u64, n22: rt.u64, n23: rt.u64, n24: rt.u64, n25: rt.u64, n26: rt.u64, n27: rt.u64, n28: rt.u64, n29: rt.u64, n30: rt.u64, n31: rt.u64, n32: rt.u64, n33: rt.u64, n34: rt.u64, n35: rt.u64, n36: rt.u64, n37: rt.u64, n38: rt.u64, n39: rt.u64, n40: rt.u64, n41: rt.u64, n42: rt.u64, n43: rt.u64, n44: rt.u64, n45: rt.u64, n46: rt.u64, n47: rt.u64, n48: rt.u64, n49: rt.u64, n50: rt.u64, n51: rt.u64, n52: rt.u64, n53: rt.u64, n54: rt.u64, n55: rt.u64, n56: rt.u64, n57: rt.u64, n58: rt.u64, n59: rt.u64, n60: rt.u64, n61: rt.u64, n62: rt.u64, n63: rt.u64, n64: rt.u64, n65: rt.u64, n66: rt.u64, n67: rt.u64, n68: rt.u64, n69: rt.u64, n70: rt.u64, n71: rt.u64, n72: rt.u64, n73: rt.u64, n74: rt.u64, n75: rt.u64, n76: rt.u64, n77: rt.u64, n78: rt.u64, n79: rt.u64, n80: rt.u64, n81: rt.u64, n82: rt.u64, n83: rt.u64, n84: rt.u64, n85: rt.u64, n86: rt.u64, n87: rt.u64, n88: rt.u64, n89: rt.u64, n90: rt.u64, n91: rt.u64, n92: rt.u64, n93: rt.u64, n94: rt.u64, n95: rt.u64, n96: rt.u64, n97: rt.u64, n98: rt.u64, n99: rt.u64, n100: rt.u64, n101: rt.u64, n102: rt.u64, n103: rt.u64, n104: rt.u64, n105: rt.u64, n106: rt.u64, n107: rt.u64, n108: rt.u64, n109: rt.u64, n110: rt.u64, n111: rt.u64, n112: rt.u64, n113: rt.u64, n114: rt.u64, n115: rt.u64, n116: rt.u64, n117: rt.u64, n118: rt.u64, n119: rt.u64, n120: rt.u64, n121: rt.u64, n122: rt.u64, n123: rt.u64): rt.u64; export declare function jniOne(): number; diff --git a/ffi/surface/moq-web/web.d.ts b/ffi/surface/moq-web/web.d.ts index e7855956d..ba0b4e0df 100644 --- a/ffi/surface/moq-web/web.d.ts +++ b/ffi/surface/moq-web/web.d.ts @@ -6535,6 +6535,7 @@ export { new$ as new }; // MuxContainerTsMpegts.ts import * as rt from "./rt.ts"; +import type { Json } from "./Json.ts"; import type { MuxContainerTsDescriptor } from "./MuxContainerTsDescriptor.ts"; import type { MuxContainerTsPassthroughTrack } from "./MuxContainerTsPassthroughTrack.ts"; import type { MuxContainerTsProgram } from "./MuxContainerTsProgram.ts"; @@ -6557,6 +6558,7 @@ export declare function muxRateGet(self: MuxContainerTsMpegts): rt.u64 | undefin export declare function muxRateSet(self: MuxContainerTsMpegts, value: rt.u64 | undefined): void; export declare function passthroughGet(self: MuxContainerTsMpegts): MuxContainerTsPassthroughTrack | undefined; export declare function passthroughSet(self: MuxContainerTsMpegts, value: MuxContainerTsPassthroughTrack | undefined): void; +export declare function deserialize(deserializer: Json): rt.Result; export declare function isEmpty(self: MuxContainerTsMpegts): boolean; export { default$ as default }; @@ -10461,6 +10463,8 @@ export declare const TRANSPORT_SETUP_RECEIVE_WINDOW: rt.u64; export declare const HANG_CATALOG_MAX_SAFE_INTEGER: rt.u64; export declare function IMPLEMENTATION(): string; export declare function ALPNS(): string[]; +export declare function escape(content: string): string; +export declare function unescape(segment: string): string; export declare function clockNow(): ClockInstant; export declare function clockWall(): ClockWall; export declare function clockOrigin(): [ClockInstant, ClockWall]; diff --git a/ffi/surface/moq/c.h b/ffi/surface/moq/c.h index 3120435e1..838a9ed7a 100644 --- a/ffi/surface/moq/c.h +++ b/ffi/surface/moq/c.h @@ -7,7 +7,7 @@ #ifdef __cplusplus extern "C" { #endif -#define MOQ_CONTRACT ((uint64_t)0x4e64edc3aadb27fcULL) +#define MOQ_CONTRACT ((uint64_t)0x61c9a9924ab0827cULL) uint64_t moq_contract(void); uint32_t moq_target(void); typedef int32_t moq_status; @@ -8400,6 +8400,7 @@ moq_option_u64 moq_mux_container_ts_Mpegts_mux_rate_get(const moq_mux_container_ void moq_mux_container_ts_Mpegts_mux_rate_set(moq_mux_container_ts_Mpegts *self, moq_option_u64 value, moq_status *status); moq_mux_container_ts_PassthroughTrack *moq_mux_container_ts_Mpegts_passthrough_get(const moq_mux_container_ts_Mpegts *self, moq_status *status); void moq_mux_container_ts_Mpegts_passthrough_set(moq_mux_container_ts_Mpegts *self, moq_mux_container_ts_PassthroughTrack *value, moq_status *status); +bool moq_mux_container_ts_Mpegts_deserialize(moq_Json *__deserializer, moq_mux_container_ts_Mpegts **out, moq_buf *err, moq_status *status); bool moq_mux_container_ts_Mpegts_is_empty(const moq_mux_container_ts_Mpegts *self, moq_status *status); void moq_mux_container_ts_PassthroughTrack_free(moq_mux_container_ts_PassthroughTrack *self); void moq_mux_container_ts_PassthroughTrack_drop(moq_mux_container_ts_PassthroughTrack *self, moq_status *status); @@ -9162,6 +9163,7 @@ void moq_moq_tokio_listen_Forward_peers_set(moq_moq_tokio_listen_Forward *self, void moq_rustls_client_danger_DangerousClientConfig_free(moq_rustls_client_danger_DangerousClientConfig *self); void moq_rustls_client_danger_DangerousClientConfig_drop(moq_rustls_client_danger_DangerousClientConfig *self, moq_status *status); moq_buf moq_rustls_client_danger_DangerousClientConfig_debug(const moq_rustls_client_danger_DangerousClientConfig *self, moq_status *status); +moq_rustls_ClientConfig *moq_rustls_client_danger_DangerousClientConfig_cfg_get(const moq_rustls_client_danger_DangerousClientConfig *self, moq_status *status); void moq_rustls_client_Resumption_free(moq_rustls_client_Resumption *self); void moq_rustls_client_Resumption_drop(moq_rustls_client_Resumption *self, moq_status *status); bool moq_rustls_client_Resumption_borrowed(const moq_rustls_client_Resumption *self); @@ -9290,6 +9292,8 @@ bool moq_rustls_CryptoProvider_borrowed(const moq_rustls_CryptoProvider *self); moq_rustls_CryptoProvider *moq_rustls_CryptoProvider_clone(const moq_rustls_CryptoProvider *self); moq_buf moq_IMPLEMENTATION(void); moq_vec_string moq_ALPNS(void); +moq_buf moq_escape(moq_buf content); +moq_buf moq_unescape(moq_buf segment); moq_clock_Instant moq_clock_now(void); moq_clock_Wall moq_clock_wall(void); void moq_clock_origin(moq_clock_Instant *out0, moq_clock_Wall *out1); diff --git a/ffi/surface/moq/cpp.hpp b/ffi/surface/moq/cpp.hpp index c3c26a97e..1f4ecb270 100644 --- a/ffi/surface/moq/cpp.hpp +++ b/ffi/surface/moq/cpp.hpp @@ -4203,6 +4203,7 @@ namespace moq { RUST2_FFI_CALLABLE void mux_rate_set(const ::std::optional<::std::uint64_t> &value); RUST2_FFI_CALLABLE ::std::optional<::moq::mux_container_ts_PassthroughTrack> passthrough_get() const; RUST2_FFI_CALLABLE void passthrough_set(::std::optional<::moq::mux_container_ts_PassthroughTrack> value); + static ::moq::result<::moq::mux_container_ts_Mpegts, ::moq::buf> deserialize(::moq::Json __deserializer); RUST2_FFI_CALLABLE bool is_empty() const; }; class RUST2_FFI_CONSUMABLE mux_container_ts_PassthroughTrack { @@ -7303,6 +7304,8 @@ namespace moq { inline bool operator!=(const ::moq::Segment &a, const ::moq::Segment &b); inline ::moq::buf Segment_to_string(const ::moq::Segment &self); inline ::moq::buf Segment_debug(const ::moq::Segment &self); + inline ::moq::buf escape(::moq::input content); + inline ::moq::buf unescape(::moq::input segment); } namespace std { template <> struct hash<::moq::Pattern> { @@ -8542,6 +8545,7 @@ namespace moq { RUST2_FFI_UNCONSUMED rustls_client_danger_DangerousClientConfig(rustls_client_danger_DangerousClientConfig &&other RUST2_FFI_MOVED_FROM) noexcept = default; rustls_client_danger_DangerousClientConfig &operator=(rustls_client_danger_DangerousClientConfig &&other) noexcept = default; RUST2_FFI_CALLABLE ::moq::buf debug() const; + RUST2_FFI_CALLABLE ::moq::rustls_ClientConfig cfg_get() const; }; class RUST2_FFI_CONSUMABLE rustls_client_Resumption { RUST2_FFI_UNCONSUMED rustls_client_Resumption(rustls_client_Resumption &&other RUST2_FFI_MOVED_FROM) noexcept = default; diff --git a/ffi/surface/moq/dart.dart b/ffi/surface/moq/dart.dart index 911580ecd..b4db0c385 100644 --- a/ffi/surface/moq/dart.dart +++ b/ffi/surface/moq/dart.dart @@ -6838,6 +6838,7 @@ final class MuxContainerTsMpegts extends _Object { void muxRateSet(U64? value); MuxContainerTsPassthroughTrack? get passthroughGet; void passthroughSet(MuxContainerTsPassthroughTrack? value); + factory MuxContainerTsMpegts.deserialize(Json deserializer); bool isEmpty(); } final class MuxContainerTsPassthroughTrack extends _Object { @@ -7573,6 +7574,7 @@ final class MoqTokioListenForward extends _Object { } final class RustlsClientDangerDangerousClientConfig extends _Object { String debug(); + RustlsClientConfig get cfgGet; } final class RustlsClientResumption extends _Object { String debug(); @@ -7709,6 +7711,8 @@ const TRANSPORT_SETUP_RECEIVE_WINDOW = U64.fromBits(131102); const HANG_CATALOG_MAX_SAFE_INTEGER = U64.fromBits(9007199254740991); String get IMPLEMENTATION; List get ALPNS; +String escape(String content); +String unescape(String segment); ClockInstant clockNow(); ClockWall clockWall(); (ClockInstant, ClockWall) clockOrigin(); diff --git a/ffi/surface/moq/go.txt b/ffi/surface/moq/go.txt index 24b635f79..ef7c88f3c 100644 --- a/ffi/surface/moq/go.txt +++ b/ffi/surface/moq/go.txt @@ -4384,6 +4384,7 @@ type ContainerTsMpegts struct { Handle_ *p_rt.Handle_ } func ContainerTsMpegtsDefault() *ContainerTsMpegts +func ContainerTsMpegtsDeserialize(deserializer *p_serdejson.Json) (*ContainerTsMpegts, error) func (self *ContainerTsMpegts) Clone() (*ContainerTsMpegts, error) func (self *ContainerTsMpegts) Close() error func (self *ContainerTsMpegts) Equal(other *ContainerTsMpegts) (bool, error) @@ -7468,6 +7469,10 @@ CONSTANTS const PATTERN_MAX_INTERSECTIONS uint = 1024 const PATTERN_MAX_SEGMENTS uint = 32 +FUNCTIONS +func Escape(content string) (string, error) +func Unescape(segment string) (string, error) + TYPES type IntersectionError int32 const ( @@ -7850,6 +7855,7 @@ func (self *ClientConfig) TimeProviderSet(value *TimeProvider) error type ClientDangerDangerousClientConfig struct { Handle_ *p_rt.Handle_ } +func (self *ClientDangerDangerousClientConfig) CfgGet() (*ClientConfig, error) func (self *ClientDangerDangerousClientConfig) Close() error func (self *ClientDangerDangerousClientConfig) GoString() string type ClientResumption struct { diff --git a/ffi/surface/moq/kotlin.kt b/ffi/surface/moq/kotlin.kt index dfede547d..d177a302a 100644 --- a/ffi/surface/moq/kotlin.kt +++ b/ffi/surface/moq/kotlin.kt @@ -6949,6 +6949,7 @@ class MuxContainerTsMpegts internal constructor(raw: Long, lent: Boolean = false fun isEmpty(): kotlin.Boolean companion object { fun default(): moq.MuxContainerTsMpegts + fun deserialize(deserializer: moq.Json): moq.MuxContainerTsMpegts } } class MuxContainerTsPassthroughTrack internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { @@ -7856,6 +7857,7 @@ class MoqTokioListenForward internal constructor(raw: Long, lent: Boolean = fals class RustlsClientDangerDangerousClientConfig internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() fun debug(): kotlin.String + val cfgGet: moq.RustlsClientConfig } class RustlsClientResumption internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() @@ -8210,6 +8212,8 @@ const val TRANSPORT_SETUP_RECEIVE_WINDOW: ULong const val HANG_CATALOG_MAX_SAFE_INTEGER: ULong val IMPLEMENTATION: kotlin.String val ALPNS: kotlin.collections.List +fun escape(content: kotlin.String): kotlin.String +fun unescape(segment: kotlin.String): kotlin.String fun clockNow(): moq.ClockInstant fun clockWall(): moq.ClockWall fun clockOrigin(): kotlin.Pair diff --git a/ffi/surface/moq/python.pyi b/ffi/surface/moq/python.pyi index a6b3c1163..87b9c8141 100644 --- a/ffi/surface/moq/python.pyi +++ b/ffi/surface/moq/python.pyi @@ -6959,6 +6959,8 @@ class MuxContainerTsMpegts(_n.Object): @_property def passthrough_get(self) -> MuxContainerTsPassthroughTrack | None: ... def passthrough_set(self, value: MuxContainerTsPassthroughTrack | None) -> None: ... + @_staticmethod + def deserialize(__deserializer: Json) -> MuxContainerTsMpegts: ... def is_empty(self) -> _bool: ... class MuxContainerTsPassthroughTrack(_n.Object): def __eq__(self, other: _object) -> _bool: ... @@ -7788,6 +7790,8 @@ class MoqTokioListenForward(_n.Object): def peers_set(self, value: _str | None) -> None: ... class RustlsClientDangerDangerousClientConfig(_n.Object): def __repr__(self) -> _str: ... + @_property + def cfg_get(self) -> RustlsClientConfig: ... class RustlsClientResumption(_n.Object): def __repr__(self) -> _str: ... def clone(self) -> RustlsClientResumption: ... @@ -8102,6 +8106,8 @@ TRANSPORT_MIN_RECEIVE_WINDOW = 1048576 TRANSPORT_SETUP_RECEIVE_WINDOW = 131102 HANG_CATALOG_MAX_SAFE_INTEGER = 9007199254740991 async def clock_drive(poll: _typing.Callable[[ClockInstant, Waiter], ClockInstant | None]) -> _str: ... +def escape(content: _str) -> _str: ... +def unescape(segment: _str) -> _str: ... def clock_now() -> ClockInstant: ... def clock_wall() -> ClockWall: ... def clock_origin() -> _tuple[ClockInstant, ClockWall]: ... @@ -8136,6 +8142,8 @@ def mux_codec_mp3_config(init: _bytes | _bytearray | _memoryview) -> HangCatalog def mux_codec_opus_packet_samples(packet: _bytes | _bytearray | _memoryview) -> _int | None: ... def mux_codec_opus_config(init: _bytes | _bytearray | _memoryview) -> HangCatalogAudioConfig: ... def mux_container_mp4_repair(file: ForeignReader) -> MuxContainerMp4Finish | None: ... +escape = _n.escape +unescape = _n.unescape clock_now = _n.clock_now clock_wall = _n.clock_wall clock_origin = _n.clock_origin diff --git a/ffi/surface/moq/swift.swift b/ffi/surface/moq/swift.swift index 3c524d1db..146bb6822 100644 --- a/ffi/surface/moq/swift.swift +++ b/ffi/surface/moq/swift.swift @@ -6402,6 +6402,7 @@ public struct MuxContainerTsMpegts: ~Copyable, @unchecked Sendable { @inlinable public mutating func muxRateSet(_ value: Swift.UInt64?) throws @inlinable public func passthroughGet() throws -> MuxContainerTsPassthroughTrack? @inlinable public mutating func passthroughSet(_ value: consuming MuxContainerTsPassthroughTrack?) throws + @inlinable public static func deserialize(_ deserializer: consuming Json) throws -> MuxContainerTsMpegts @inlinable public func isEmpty() throws -> Swift.Bool } public struct MuxContainerTsPassthroughTrack: ~Copyable, @unchecked Sendable { @@ -7121,6 +7122,7 @@ public struct MoqTokioListenForward: ~Copyable, @unchecked Sendable { } public struct RustlsClientDangerDangerousClientConfig: ~Copyable, @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } + @inlinable public func cfgGet() throws -> RustlsClientConfig } public struct RustlsClientResumption: ~Copyable, @unchecked Sendable { @inlinable public var debugDescription: Swift.String { get } @@ -7315,6 +7317,8 @@ public let TRANSPORT_SETUP_RECEIVE_WINDOW: Swift.UInt64 public let HANG_CATALOG_MAX_SAFE_INTEGER: Swift.UInt64 @inlinable public var IMPLEMENTATION: Swift.String { get } @inlinable public var ALPNS: [Swift.String] { get } +@inlinable public func escape(_ content: Swift.String) -> Swift.String +@inlinable public func unescape(_ segment: Swift.String) -> Swift.String @inlinable public func clockNow() -> ClockInstant @inlinable public func clockWall() -> ClockWall @inlinable public func clockOrigin() -> (ClockInstant, ClockWall) diff --git a/ffi/tests/api.c b/ffi/tests/api.c index daa3ccd0e..ada67dd1b 100644 --- a/ffi/tests/api.c +++ b/ffi/tests/api.c @@ -1340,9 +1340,13 @@ static int script(void) { api_Channel_free(channel); /* A value that holds itself is an object. */ - api_Node *list = api_Node_new(1, NULL, NULL); - api_Node_push(list, 2, NULL); + api_Node *list = api_Node_new(2, NULL, NULL); + api_Node_push(list, 1, NULL); printf("node %llu\n", (unsigned long long)api_Node_sum(list, NULL)); + /* An optional boxed field that is not Clone, lent as a handle or NULL. */ + api_Node *tail = api_Node_next_get(list, NULL); + printf("node next %llu\n", (unsigned long long)(tail != NULL ? api_Node_value_get(tail, NULL) : 0)); + api_Node_free(tail); api_Node_free(list); api_Tally *tally = api_Tally_new(); @@ -1471,7 +1475,7 @@ static int script(void) { printf("retry %u\n", api_Retry_limit(retry, NULL)); api_Retry_free(retry); api_Slot_u8 *slot = api_Slot_u8_new(200); - printf("slot %u\n", api_Slot_u8_value(slot)); + printf("slot %u\n", api_Slot_u8_value(slot, NULL)); api_Slot_u8_free(slot); /* Foreign types: a URL parsed from text, socket addresses, OS paths, and `Vec`s. */ api_Url *base; @@ -1745,6 +1749,12 @@ static int script(void) { api_Receipt *receipt = api_Ledger_receipt(ledger, NULL); printf("receipt %u\n", api_Receipt_count(receipt, NULL)); api_Receipt_free(receipt); + /* A field holding a borrow, read through. */ + api_Tab *tab = api_Ledger_tab(ledger, NULL); + api_Ledger *tabbed = api_Tab_ledger_get(tab, NULL); + printf("tab %u\n", api_Ledger_published(tabbed, NULL)); + api_Ledger_free(tabbed); + api_Tab_free(tab); { api_Pad_u8 *small = api_Pad_u8_small(); api_Pad_u16 *wide = api_Pad_u16_wide(); @@ -1900,6 +1910,36 @@ static int script(void) { return 1; } print("json ", api_encode(doc, NULL), "\n"); + /* A returned Cow crosses as an owned string or bytes. */ + print("cow ", api_unescaped(str("a\\b")), " "); + print("", api_unescaped(str("plain")), " "); + uint8_t zeroed[] = {1, 0, 2}; + uint8_t unzeroed[] = {3}; + api_buf zeros = api_unzeroed((api_buf){.ptr = zeroed, .len = 3}); + api_buf no_zeros = api_unzeroed((api_buf){.ptr = unzeroed, .len = 1}); + printf("%zu %zu\n", zeros.len, no_zeros.len); + api_buf_free(zeros); + api_buf_free(no_zeros); + /* A type parameter bounded by Deserializer takes a JSON document, moved in. */ + api_Json *spot_doc; + if (!api_Json_parse(str("[1, 2]"), &spot_doc, &parse_err)) { + return 1; + } + api_Spot spot; + api_buf spot_err; + if (!api_Spot_deserialize(spot_doc, &spot, &spot_err, NULL)) { + return 1; + } + api_Json_free(spot_doc); + printf("spot %u %u\n", spot.x, spot.y); + if (!api_Json_parse(str("\"x\""), &spot_doc, &parse_err)) { + return 1; + } + if (api_Spot_deserialize(spot_doc, &spot, &spot_err, NULL)) { + return 1; + } + api_Json_free(spot_doc); + print("spot err ", spot_err, "\n"); api_Json *tagged = api_tagged(doc, str("t"), NULL); api_Json_free(doc); print("tagged ", api_Json_to_text(tagged, NULL), "\n"); diff --git a/ffi/tests/api.cpp b/ffi/tests/api.cpp index a02faeba5..da5960dee 100644 --- a/ffi/tests/api.cpp +++ b/ffi/tests/api.cpp @@ -774,9 +774,12 @@ int script() { // A value that holds itself is an object. { - api::Node list = api::Node::new_(1, std::nullopt); - list.push(2); + api::Node list = api::Node::new_(2, std::nullopt); + list.push(1); std::printf("node %llu\n", ull(list.sum())); + // An optional boxed field that is not Clone, lent as `Some` of a handle. + std::optional next = list.next_get(); + std::printf("node next %llu\n", ull(next ? next->value_get() : 0)); } { @@ -1068,6 +1071,8 @@ int script() { } std::printf("dropped %u\n", ledger.published()); std::printf("receipt %u\n", ledger.receipt().count()); + // A field holding a borrow, read through. + std::printf("tab %u\n", ledger.tab().ledger_get().published()); { auto marker = api::Marker::new_(api::input("m"), 3, 5); marker.y_set(7); @@ -1186,6 +1191,24 @@ int script() { api::Json doc = api::Json::parse(R"({"b": [1, 2.5, null], "a": "\u00e9"})").value(); print("json ", api::encode(doc), "\n"); + // A returned Cow crosses as an owned string or bytes. + print("cow ", api::unescaped("a\\b"), " "); + print("", api::unescaped("plain"), " "); + { + std::uint8_t zeroed[] = {1, 0, 2}; + std::uint8_t unzeroed[] = {3}; + std::printf("%zu %zu\n", api::unzeroed(api::view(zeroed, 3)).size(), api::unzeroed(api::view(unzeroed, 1)).size()); + } + // A type parameter bounded by Deserializer takes a JSON document, moved in. + { + api::Spot spot = api::Spot::deserialize(api::Json::parse("[1, 2]").value()).value(); + std::printf("spot %u %u\n", spot.x, spot.y); + auto bad = api::Spot::deserialize(api::Json::parse("\"x\"").value()); + if (bad) { + return 1; + } + print("spot err ", bad.error(), "\n"); + } api::Json tagged = api::tagged(std::move(doc), "t"); print("tagged ", tagged.to_text(), "\n"); { diff --git a/ffi/tests/api.dart b/ffi/tests/api.dart index ed551a67e..da22dcd6b 100644 --- a/ffi/tests/api.dart +++ b/ffi/tests/api.dart @@ -503,9 +503,13 @@ Future script() async { await until(() => wakes == 5, 'a returned waker wakes the waiter'); print('woken $wakes'); - final nodes = api.Node(api.U64(1), null); - nodes.push(api.U64(2)); + final nodes = api.Node(api.U64(2), null); + nodes.push(api.U64(1)); print('node ${nodes.sum()}'); + // An optional boxed field that is not Clone, lent as a handle or null. + final next = nodes.nextGet; + print('node next ${next?.valueGet ?? 0}'); + next?.close(); final tally = api.Tally(); tally.bump(); @@ -732,6 +736,12 @@ Future script() async { final receipt = ledger.receipt(); print('receipt ${receipt.count()}'); receipt.close(); + // A field holding a borrow, read through. + final tab = ledger.tab(); + final tabbed = tab.ledgerGet; + print('tab ${tabbed.published()}'); + tabbed.close(); + tab.close(); final padSmall = api.PadU8.small(), padWide = api.PadU16.wide(), layered = api.Layered(); final marker = api.Marker('m', 3, 5); marker.ySet(7); @@ -797,6 +807,17 @@ Future script() async { print('joined $parts ${api.joined([]).length} read ${api.readLen(utf8.encode('hello'))}'); final doc = api.Json.parse('{"b": [1, 2.5, null], "a": "é"}'); print('json ${api.encode(doc)}'); + // A returned Cow crosses as an owned string or bytes. + print('cow ${api.unescaped(r'a\b')} ${api.unescaped('plain')} ${api.unzeroed(bytes([1, 0, 2])).length} ${api.unzeroed(bytes([3])).length}'); + // A type parameter bounded by Deserializer takes a JSON document, moved in. + final spot = api.Spot.deserialize(api.Json.parse('[1, 2]')); + print('spot ${spot.x} ${spot.y}'); + try { + api.Spot.deserialize(api.Json.parse('"x"')); + check(false, 'a spot refuses a string'); + } on api.StringException catch (e) { + print('spot err ${e.error}'); + } final tagged = api.tagged(doc, 't'); print('tagged ${tagged.toText()}'); tagged.close(); diff --git a/ffi/tests/api.go b/ffi/tests/api.go index e47b337b0..b9f1c9be3 100644 --- a/ffi/tests/api.go +++ b/ffi/tests/api.go @@ -606,9 +606,16 @@ func script() { waiter.Close() fmt.Printf("woken %d\n", wakes) - list1 := must(api.NewNode(1, nil)) - ok(list1.Push(2)) + list1 := must(api.NewNode(2, nil)) + ok(list1.Push(1)) fmt.Printf("node %d\n", must(list1.Sum())) + // An optional boxed field that is not Clone, lent as a handle or nil. + if next := must(list1.NextGet()); next != nil { + fmt.Printf("node next %d\n", must(next.ValueGet())) + next.Close() + } else { + fmt.Printf("node next 0\n") + } tally := api.NewTally() must(tally.Bump()) @@ -836,6 +843,12 @@ func script() { receipt := must(ledger.Receipt()) fmt.Printf("receipt %d\n", must(receipt.Count())) check(receipt.Close() == nil, "a receipt closes") + // A field holding a borrow, read through. + tab := must(ledger.Tab()) + tabbed := must(tab.LedgerGet()) + fmt.Printf("tab %d\n", must(tabbed.Published())) + tabbed.Close() + tab.Close() padSmall, padWide, layered := api.PadU8Small(), api.PadU16Wide(), api.NewLayered() marker := must(api.NewMarker("m", 3, 5)) check(marker.YSet(7) == nil, "a marker's point sets") @@ -912,6 +925,15 @@ func script() { fmt.Printf("joined %s %d read %d\n", api.Joined(parts).Copy(), len(api.Joined(nil).Copy()), api.ReadLen(rt.NewBytes([]byte("hello")))) doc := must(serdejson.JsonParse(`{"b": [1, 2.5, null], "a": "é"}`)) fmt.Printf("json %s\n", must(api.Encode(doc))) + // A returned Cow crosses as an owned string or bytes. + fmt.Printf("cow %s %s %d %d\n", must(api.Unescaped(`a\b`)), must(api.Unescaped("plain")), + len(api.Unzeroed(rt.NewBytes([]byte{1, 0, 2})).Copy()), len(api.Unzeroed(rt.NewBytes([]byte{3})).Copy())) + // A type parameter bounded by Deserializer takes a JSON document, moved in. + spot := must(api.SpotDeserialize(must(serdejson.JsonParse(`[1, 2]`)))) + fmt.Printf("spot %d %d\n", spot.X, spot.Y) + _, err = api.SpotDeserialize(must(serdejson.JsonParse(`"x"`))) + check(err != nil, "a spot refuses a string") + fmt.Printf("spot err %s\n", err) tagged2 := must(api.Tagged(doc, "t")) fmt.Printf("tagged %s\n", must(tagged2.ToText())) tagged2.Close() diff --git a/ffi/tests/api.kt b/ffi/tests/api.kt index 5b919b99c..ac647e5d9 100644 --- a/ffi/tests/api.kt +++ b/ffi/tests/api.kt @@ -407,9 +407,11 @@ fun script() { } println("woken $wakes") - val list = Node.new(1u, null) - list.push(2u) + val list = Node.new(2u, null) + list.push(1u) println("node ${list.sum()}") + // An optional boxed field that is not Clone, lent as a handle or null. + println("node next ${list.nextGet?.use { it.valueGet } ?: 0u}") val tally = Tally.new() tally.bump() @@ -642,6 +644,8 @@ fun script() { ledger.edit().use { it.write("second") } println("dropped ${ledger.published()}") println("receipt ${ledger.receipt().use { it.count() }}") + // A field holding a borrow, read through. + println("tab ${ledger.tab().use { tab -> tab.ledgerGet.use { it.published() } }}") Marker.new("m", 3, 5).use { marker -> marker.ySet(7) val title = PadU16.wide().use { it.title() } @@ -708,6 +712,20 @@ fun script() { println("joined $parts ${joined(emptyList()).toByteArray().size} read ${readLen(Bytes("hello".encodeToByteArray()))}") val doc = Json.parse("""{"b": [1, 2.5, null], "a": "\u00e9"}""") println("json ${encode(doc)}") + // A returned Cow crosses as an owned string or bytes. + println( + "cow ${unescaped("a\\b")} ${unescaped("plain")} ${unzeroed(Bytes(byteArrayOf(1, 0, 2))).size} " + + "${unzeroed(Bytes(byteArrayOf(3))).size}", + ) + // A type parameter bounded by Deserializer takes a JSON document, moved in. + val spot = Spot.deserialize(Json.parse("[1, 2]")) + println("spot ${spot.x} ${spot.y}") + try { + Spot.deserialize(Json.parse("\"x\"")) + check(false, "a spot refuses a string") + } catch (e: StringException) { + println("spot err ${e.error}") + } tagged(doc, "t").use { tagged -> println("tagged ${tagged.toText()}") } // A JSON object's entries cross as pairs of a key and its document, each moved in. val jsonEntries = entries(listOf(Pair("b", Json.parse("[1]")), Pair("a", Json.parse("2"))), "t") diff --git a/ffi/tests/api.py b/ffi/tests/api.py index afdaade06..d38136af4 100644 --- a/ffi/tests/api.py +++ b/ffi/tests/api.py @@ -500,9 +500,12 @@ async def polls(): channel.clear() loop.close() - nodes = api.Node.new(1, None) - nodes.push(2) + nodes = api.Node.new(2, None) + nodes.push(1) print(f"node {nodes.sum()}") + # An optional boxed field that is not Clone, lent as a handle or None. + next_node = nodes.next_get + print(f"node next {next_node.value_get if next_node is not None else 0}") tally = api.Tally.new() tally.bump() @@ -708,6 +711,11 @@ async def polls(): del draft print(f"dropped {ledger.published()}") print(f"receipt {ledger.receipt().count()}") + # A field holding a borrow, read through. + # The tab lends its field, so it outlives the read. + tab = ledger.tab() + print(f"tab {tab.ledger_get.published()}") + del tab marker = api.Marker.new("m", 3, 5) marker.y_set(7) print( @@ -763,6 +771,17 @@ async def polls(): print(f"joined {joined} {len(api.joined([]))} read {api.read_len(b'hello')}") doc = api.Json.parse('{"b": [1, 2.5, null], "a": "é"}') print(f"json {api.encode(doc)}") + # A returned Cow crosses as an owned string or bytes. + unescaped = api.unescaped("a\\b") + print(f"cow {unescaped} {api.unescaped('plain')} {len(api.unzeroed(bytes([1, 0, 2])))} {len(api.unzeroed(bytes([3])))}") + # A type parameter bounded by Deserializer takes a JSON document, moved in. + spot = api.Spot.deserialize(api.Json.parse("[1, 2]")) + print(f"spot {spot.x} {spot.y}") + try: + api.Spot.deserialize(api.Json.parse('"x"')) + raise AssertionError("a spot refuses a string") + except api.StringException as e: + print(f"spot err {e.error}") tagged = api.tagged(doc, "t") print(f"tagged {tagged.to_text()}") # A JSON object's entries cross as pairs of a key and its document, each moved in. diff --git a/ffi/tests/api.swift b/ffi/tests/api.swift index 07a695c94..17d18f3fe 100644 --- a/ffi/tests/api.swift +++ b/ffi/tests/api.swift @@ -622,9 +622,15 @@ func script() { } print("woken \(wakes.value)") - var list = try! Node.new(1, nil) - try! list.push(2) + var list = try! Node.new(2, nil) + try! list.push(1) print("node \(try! list.sum())") + // An optional boxed field that is not Clone, lent as `Some` of a handle. + if let next = try! list.nextGet() { + print("node next \(try! next.valueGet)") + } else { + print("node next 0") + } let tally = Tally.new() _ = try! tally.bump() @@ -712,7 +718,7 @@ func script() { // The renamed field's setter, named as its getter. try! retry.limitSet(nil) print("retry \(try! retry.limit())") - print("slot \(SlotU8.new(200).value())") + print("slot \(try! SlotU8.new(200).value())") // Foreign types: a URL parsed from text, socket addresses, OS paths, and `Vec`s. let base = try! Url.parse("https://example.com/a/b") @@ -922,6 +928,12 @@ func script() { _ = consume second print("dropped \(try! ledger.published())") print("receipt \(try! ledger.receipt().count())") + // A field holding a borrow, read through. + do { + // The tab lends its field, so it outlives the read. + let tab = try! ledger.tab() + print("tab \(try! tab.ledgerGet().published())") + } var marker = Marker.new("m", 3, 5) try! marker.ySet(7) print("forwarded \(PadU16.wide().title()) \(Layered.new().lines()) \(try! marker.xGet) \(try! marker.yGet) [\(PadU8.small().describe())] [\(PadU16.wide().describe())]") @@ -972,6 +984,19 @@ func script() { print("joined \(parts) \(Api.joined([]).count) read \(readLen(Bytes("hello".utf8)))") let doc = try! Json.parse(#"{"b": [1, 2.5, null], "a": "é"}"#) print("json \(try! encode(doc))") + // A returned Cow crosses as an owned string or bytes. + print("cow \(unescaped(#"a\b"#)) \(unescaped("plain")) \(unzeroed(Bytes([1, 0, 2])).count) \(unzeroed(Bytes([3])).count)") + // A type parameter bounded by Deserializer takes a JSON document, moved in. + let spot = try! Spot.deserialize(try! Json.parse("[1, 2]")) + print("spot \(spot.x) \(spot.y)") + do { + _ = try Spot.deserialize(try! Json.parse("\"x\"")) + check(false, "a spot refuses a string") + } catch let e as StringError { + print("spot err \(e.error)") + } catch { + check(false, "deserialize throws its message") + } let tagged = try! tagged(doc, "t") print("tagged \(try! tagged.toText())") // A JSON object's entries cross as pairs of a key and its document, each moved in. diff --git a/ffi/tests/api.ts b/ffi/tests/api.ts index 26936212c..565432b0c 100644 --- a/ffi/tests/api.ts +++ b/ffi/tests/api.ts @@ -72,8 +72,10 @@ import * as Shape from "./web/Shape.ts"; import * as Site from "./web/Site.ts"; import * as SlotU8 from "./web/SlotU8.ts"; import * as Span from "./web/Span.ts"; +import * as Spot from "./web/Spot.ts"; import * as Stack from "./web/Stack.ts"; import * as Stamp from "./web/Stamp.ts"; +import * as Tab from "./web/Tab.ts"; import * as Tallies from "./web/Tallies.ts"; import * as Tally from "./web/Tally.ts"; import * as Ticket from "./web/Ticket.ts"; @@ -711,9 +713,13 @@ async function script(): Promise { await until(() => wakes === 5, "a returned waker wakes the waiter"); print(`woken ${wakes}`); - const nodes = Node.new(1, undefined); - Node.push(nodes, 2); + const nodes = Node.new(2, undefined); + Node.push(nodes, 1); print(`node ${dec(Node.sum(nodes))}`); + // An optional boxed field that is not Clone, lent as a handle or undefined. + const nextNode = Node.nextGet(nodes); + print(`node next ${nextNode === undefined ? 0 : dec(Node.valueGet(nextNode))}`); + if (nextNode !== undefined) close(nextNode); const tally = Tally.new(); Tally.bump(tally); @@ -930,6 +936,12 @@ async function script(): Promise { const receipt = Ledger.receipt(ledger); print(`receipt ${Receipt.count(receipt)}`); close(receipt); + // A field holding a borrow, read through. + const tab = Ledger.tab(ledger); + const tabbed = Tab.ledgerGet(tab); + print(`tab ${Ledger.published(tabbed)}`); + close(tabbed); + close(tab); { const small = PadU8.small(); const wide = PadU16.wide(); @@ -989,6 +1001,15 @@ async function script(): Promise { print(`joined ${parts} ${api.joined([]).length} read ${dec(api.readLen(enc("hello")))}`); const doc = unwrap(Json.parse('{"b": [1, 2.5, null], "a": "é"}')); print(`json ${api.encode(doc)}`); + // A returned Cow crosses as an owned string or bytes. + const unzeroed = api.unzeroed(new Uint8Array([1, 0, 2])).length; + print(`cow ${api.unescaped("a\\b")} ${api.unescaped("plain")} ${unzeroed} ${api.unzeroed(new Uint8Array([3])).length}`); + // A type parameter bounded by Deserializer takes a JSON document, moved in. + const spot = unwrap(Spot.deserialize(unwrap(Json.parse("[1, 2]")))); + print(`spot ${spot.x} ${spot.y}`); + const badSpot = Spot.deserialize(unwrap(Json.parse('"x"'))); + if (badSpot.ok) throw new Error("a spot refuses a string"); + print(`spot err ${badSpot.error}`); const tagged = api.tagged(doc, "t"); print(`tagged ${Json.toText(tagged)}`); close(tagged); diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index bb69d77ef..8b2525d6e 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -2729,7 +2729,7 @@ fn unreached_types() { } let lib = std::fs::read_to_string(package.join("src/lib.rs")).unwrap(); let (head, rest) = lib.split_once("pub fn pending").unwrap(); - let rest = &rest[rest.find("pub fn seal").unwrap()..]; + let rest = &rest[rest.find("#[cfg(feature = \"refused\")] pub fn seal").unwrap()..]; std::fs::write(moved.join("src/lib.rs"), format!("{head}{rest}")).unwrap(); run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) .arg("--manifest-path") @@ -2773,8 +2773,8 @@ fn unreached_types() { // A type an `Arc` holds, and a `Result`'s error without `Display`, stay refused as // foreign; one no public path names is held by value instead. for refused in [ - "fn `bare` at src/lib.rs:23:1: foreign type `net::Handle`", - "fn `opaque` at src/lib.rs:27:1: foreign type `net::Opaque`", + "fn `bare` at src/lib.rs:23:29: foreign type `net::Handle`", + "fn `opaque` at src/lib.rs:27:29: foreign type `net::Opaque`", ] { assert!(report.contains(refused), "{report}"); } @@ -2797,7 +2797,7 @@ fn unreached_types() { // through an `impl Trait`: `own`'s `Option` is refused, and `Own` left out with it. assert!(report.contains("- `own`: type C never holds `Own`"), "{report}"); assert!( - report.contains("fn `seal` at src/lib.rs:11:1: type not reachable from the crate root `kio::sealed::Sealed`"), + report.contains("fn `seal` at src/lib.rs:11:29: type not reachable from the crate root `kio::sealed::Sealed`"), "{report}" ); assert_eq!(report.matches("not reachable").count(), 3, "{report}"); From afaae034fa5e6cfdfd5b102c680675ee0a4ade8e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 21:35:15 -0800 Subject: [PATCH 06/10] ffi: read a reference field through it in the glue, so a Clone referent copies Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/api/examples/transcript.rs | 9 +++++++-- ffi/fixtures/api/src/lib.rs | 15 ++++++++------- ffi/src/collect.rs | 8 ++++++-- ffi/src/glue.rs | 7 ++++++- ffi/src/ir.rs | 9 +++++++-- ffi/surface/api/c.h | 3 ++- ffi/surface/api/cpp.hpp | 1 + ffi/surface/api/dart.dart | 1 + ffi/surface/api/go.txt | 1 + ffi/surface/api/kotlin.kt | 1 + ffi/surface/api/python.pyi | 2 ++ ffi/surface/api/swift.swift | 1 + ffi/surface/api/web.d.ts | 1 + ffi/tests/api.c | 1 + ffi/tests/api.cpp | 6 +++++- ffi/tests/api.dart | 1 + ffi/tests/api.go | 1 + ffi/tests/api.kt | 5 ++++- ffi/tests/api.py | 1 + ffi/tests/api.swift | 1 + ffi/tests/api.ts | 1 + ffi/tests/fixtures.rs | 11 +++++------ ffi/tests/fixtures/shapes.rs | 5 +---- 23 files changed, 65 insertions(+), 27 deletions(-) diff --git a/ffi/fixtures/api/examples/transcript.rs b/ffi/fixtures/api/examples/transcript.rs index 3cd4be955..bb4e301ae 100644 --- a/ffi/fixtures/api/examples/transcript.rs +++ b/ffi/fixtures/api/examples/transcript.rs @@ -760,7 +760,9 @@ fn main() { drop(draft); println!("dropped {}", ledger.published()); println!("receipt {}", ledger.receipt().count()); - println!("tab {}", ledger.tab().ledger.published()); + let tab = ledger.tab(); + println!("tab {}", tab.ledger.published()); + println!("tab label {}", tab.label); // Members a `Deref` reaches: past an unexported target, beside a method of the same // name, and a field a method's path shares. let mut marker = api::Marker::new("m", 3, 5); @@ -872,7 +874,10 @@ fn main() { ); let spot = api::Spot::deserialize(serde_json::json!([1, 2])).unwrap(); println!("spot {} {}", spot.x, spot.y); - println!("spot err {}", api::Spot::deserialize(serde_json::json!("x")).unwrap_err()); + println!( + "spot err {}", + api::Spot::deserialize(serde_json::json!("x")).unwrap_err() + ); println!("tagged {}", api::tagged(doc, "t")); let entries = api::entries( [("b", "[1]"), ("a", "2")] diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index ef7bb4bd0..bae9f4bff 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -813,7 +813,10 @@ impl Ledger { /// A tab on this ledger, holding its exclusive borrow in a field, as rustls's /// `ClientConfig::dangerous` does. pub fn tab(&mut self) -> Tab<'_> { - Tab { ledger: self } + Tab { + ledger: self, + label: "ledger", + } } pub fn slip(&mut self) -> Slip<'_> { @@ -825,11 +828,12 @@ impl Ledger { } } -/// What [`Ledger::tab`] lends: a field holding a mutable borrow, which C reads through and -/// never assigns. +/// What [`Ledger::tab`] lends: fields holding borrows, which C reads through and never +/// assigns, lent where what they borrow is not `Clone`, and copied where it is. #[non_exhaustive] pub struct Tab<'a> { pub ledger: &'a mut Ledger, + pub label: &'a str, } mod noted { @@ -2857,10 +2861,7 @@ pub struct Retry { impl Retry { pub fn new(limit: Option) -> Self { - Self { - limit, - delay: None, - } + Self { limit, delay: None } } pub fn limit(&self) -> u32 { diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index e15eacb09..48925ef83 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -2726,7 +2726,10 @@ impl<'tcx> Collector<'tcx> { lends_mut: false, derefs: 0, ties, - access: Access::Field { set }, + access: Access::Field { + set, + through: !assigned, + }, instance: None, home: Home::default(), }; @@ -5796,7 +5799,8 @@ impl<'tcx> Collector<'tcx> { && let object = match &**object { Type::Box(boxed) => boxed, _ => object, - } && matches!(**object, Type::Object(_)) + } + && matches!(**object, Type::Object(_)) && let ty::Adt(_, args) = inner.kind() && self.opaque_value(unboxed(args.type_at(0))).is_none() && self.lending.take() => diff --git a/ffi/src/glue.rs b/ffi/src/glue.rs index 012d3a8c5..38c73f5a0 100644 --- a/ffi/src/glue.rs +++ b/ffi/src/glue.rs @@ -2756,7 +2756,12 @@ impl Gen<'_> { ) } Access::Call => format!("{callee}({})", args.join(", ")), - Access::Field { set: false, .. } => format!("&({}).{}", args[0], ident(function.name())), + Access::Field { set: false, through } => format!( + "&{}({}).{}", + if through { "*" } else { "" }, + args[0], + ident(function.name()) + ), Access::Field { set: true, .. } => format!("({}).{} = {}", args[0], ident(function.name()), args[1]), Access::Const => callee, Access::Parse => format!( diff --git a/ffi/src/ir.rs b/ffi/src/ir.rs index 24a1bf52f..b6f3c8be8 100644 --- a/ffi/src/ir.rs +++ b/ffi/src/ir.rs @@ -515,8 +515,13 @@ pub(crate) struct Instance { pub(crate) enum Access { /// It calls the function. Call, - /// It reads a `pub` field of its receiver, or with `set` assigns it. - Field { set: bool }, + /// It reads a `pub` field of its receiver, or with `set` assigns it; `through` the + /// reference the field holds, which then has no setter. + Field { + set: bool, + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + through: bool, + }, /// It reads a constant that is not a `bool` or integer. Const, /// It parses its receiver's type from text, with `FromStr`, failing with the parse diff --git a/ffi/surface/api/c.h b/ffi/surface/api/c.h index bd02435dd..a599fa971 100644 --- a/ffi/surface/api/c.h +++ b/ffi/surface/api/c.h @@ -7,7 +7,7 @@ #ifdef __cplusplus extern "C" { #endif -#define API_CONTRACT ((uint64_t)0x502d1ceb3c7c4082ULL) +#define API_CONTRACT ((uint64_t)0x258a865fea197bc9ULL) uint64_t api_contract(void); uint32_t api_target(void); typedef int32_t api_status; @@ -1389,6 +1389,7 @@ api_Counter *api_Board_best(const api_Board *self, api_status *status); void api_Tab_free(api_Tab *self); void api_Tab_drop(api_Tab *self, api_status *status); api_Ledger *api_Tab_ledger_get(const api_Tab *self, api_status *status); +api_buf api_Tab_label_get(const api_Tab *self, api_status *status); void api_Receipt_free(api_Receipt *self); void api_Receipt_drop(api_Receipt *self, api_status *status); api_Receipt *api_Receipt_clone(const api_Receipt *self, api_status *status); diff --git a/ffi/surface/api/cpp.hpp b/ffi/surface/api/cpp.hpp index 16f3467e2..5e06e8491 100644 --- a/ffi/surface/api/cpp.hpp +++ b/ffi/surface/api/cpp.hpp @@ -39,6 +39,7 @@ namespace api { RUST2_FFI_UNCONSUMED Tab(Tab &&other RUST2_FFI_MOVED_FROM) noexcept = default; Tab &operator=(Tab &&other) noexcept = default; RUST2_FFI_CALLABLE ::api::Ledger ledger_get() const; + RUST2_FFI_CALLABLE ::api::buf label_get() const; }; class RUST2_FFI_CONSUMABLE Receipt { RUST2_FFI_UNCONSUMED Receipt(Receipt &&other RUST2_FFI_MOVED_FROM) noexcept = default; diff --git a/ffi/surface/api/dart.dart b/ffi/surface/api/dart.dart index 6765177e2..2634076d5 100644 --- a/ffi/surface/api/dart.dart +++ b/ffi/surface/api/dart.dart @@ -953,6 +953,7 @@ final class Board extends _Object { } final class Tab extends _Object { Ledger get ledgerGet; + String get labelGet; } final class Receipt extends _Object { Receipt clone(); diff --git a/ffi/surface/api/go.txt b/ffi/surface/api/go.txt index 61e71c7b3..24c64a8b6 100644 --- a/ffi/surface/api/go.txt +++ b/ffi/surface/api/go.txt @@ -1603,6 +1603,7 @@ type Tab struct { Handle_ *p_rt.Handle_ } func (self *Tab) Close() error +func (self *Tab) LabelGet() (string, error) func (self *Tab) LedgerGet() (*Ledger, error) type Tallies struct { Handle_ *p_rt.Handle_ diff --git a/ffi/surface/api/kotlin.kt b/ffi/surface/api/kotlin.kt index 900b54381..23c0acfbf 100644 --- a/ffi/surface/api/kotlin.kt +++ b/ffi/surface/api/kotlin.kt @@ -547,6 +547,7 @@ class Board internal constructor(raw: Long, lent: Boolean = false) : AutoCloseab class Tab internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() val ledgerGet: api.Ledger + val labelGet: kotlin.String } class Receipt internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() diff --git a/ffi/surface/api/python.pyi b/ffi/surface/api/python.pyi index 8a1ca3dcf..c9b9fb2cb 100644 --- a/ffi/surface/api/python.pyi +++ b/ffi/surface/api/python.pyi @@ -664,6 +664,8 @@ class Board(_n.Object): class Tab(_n.Object): @_property def ledger_get(self) -> Ledger: ... + @_property + def label_get(self) -> _str: ... class Receipt(_n.Object): def clone(self) -> Receipt: ... def count(self) -> _int: ... diff --git a/ffi/surface/api/swift.swift b/ffi/surface/api/swift.swift index f5528d84c..b381ddd94 100644 --- a/ffi/surface/api/swift.swift +++ b/ffi/surface/api/swift.swift @@ -775,6 +775,7 @@ public struct Board: ~Copyable, @unchecked Sendable { } public struct Tab: ~Copyable, @unchecked Sendable { @inlinable public func ledgerGet() throws -> Ledger + @inlinable public var labelGet: Swift.String { get } } public struct Receipt: ~Copyable, @unchecked Sendable { @inlinable public func clone() throws -> Receipt diff --git a/ffi/surface/api/web.d.ts b/ffi/surface/api/web.d.ts index ddf08ca0b..59c965678 100644 --- a/ffi/surface/api/web.d.ts +++ b/ffi/surface/api/web.d.ts @@ -1339,6 +1339,7 @@ import * as rt from "./rt.ts"; import type { Ledger } from "./Ledger.ts"; export type Tab = rt.Handle<"Tab">; export declare function ledgerGet(self: Tab): Ledger; +export declare function labelGet(self: Tab): string; // Tallies.ts import * as rt from "./rt.ts"; diff --git a/ffi/tests/api.c b/ffi/tests/api.c index ada67dd1b..3496c2e2e 100644 --- a/ffi/tests/api.c +++ b/ffi/tests/api.c @@ -1753,6 +1753,7 @@ static int script(void) { api_Tab *tab = api_Ledger_tab(ledger, NULL); api_Ledger *tabbed = api_Tab_ledger_get(tab, NULL); printf("tab %u\n", api_Ledger_published(tabbed, NULL)); + print("tab label ", api_Tab_label_get(tab, NULL), "\n"); api_Ledger_free(tabbed); api_Tab_free(tab); { diff --git a/ffi/tests/api.cpp b/ffi/tests/api.cpp index da5960dee..4c7e8906b 100644 --- a/ffi/tests/api.cpp +++ b/ffi/tests/api.cpp @@ -1072,7 +1072,11 @@ int script() { std::printf("dropped %u\n", ledger.published()); std::printf("receipt %u\n", ledger.receipt().count()); // A field holding a borrow, read through. - std::printf("tab %u\n", ledger.tab().ledger_get().published()); + { + api::Tab tab = ledger.tab(); + std::printf("tab %u\n", tab.ledger_get().published()); + print("tab label ", tab.label_get(), "\n"); + } { auto marker = api::Marker::new_(api::input("m"), 3, 5); marker.y_set(7); diff --git a/ffi/tests/api.dart b/ffi/tests/api.dart index da22dcd6b..196c02405 100644 --- a/ffi/tests/api.dart +++ b/ffi/tests/api.dart @@ -740,6 +740,7 @@ Future script() async { final tab = ledger.tab(); final tabbed = tab.ledgerGet; print('tab ${tabbed.published()}'); + print('tab label ${tab.labelGet}'); tabbed.close(); tab.close(); final padSmall = api.PadU8.small(), padWide = api.PadU16.wide(), layered = api.Layered(); diff --git a/ffi/tests/api.go b/ffi/tests/api.go index b9f1c9be3..c3e63c7fa 100644 --- a/ffi/tests/api.go +++ b/ffi/tests/api.go @@ -847,6 +847,7 @@ func script() { tab := must(ledger.Tab()) tabbed := must(tab.LedgerGet()) fmt.Printf("tab %d\n", must(tabbed.Published())) + fmt.Printf("tab label %s\n", must(tab.LabelGet())) tabbed.Close() tab.Close() padSmall, padWide, layered := api.PadU8Small(), api.PadU16Wide(), api.NewLayered() diff --git a/ffi/tests/api.kt b/ffi/tests/api.kt index ac647e5d9..6090e9fc4 100644 --- a/ffi/tests/api.kt +++ b/ffi/tests/api.kt @@ -645,7 +645,10 @@ fun script() { println("dropped ${ledger.published()}") println("receipt ${ledger.receipt().use { it.count() }}") // A field holding a borrow, read through. - println("tab ${ledger.tab().use { tab -> tab.ledgerGet.use { it.published() } }}") + ledger.tab().use { tab -> + println("tab ${tab.ledgerGet.use { it.published() }}") + println("tab label ${tab.labelGet}") + } Marker.new("m", 3, 5).use { marker -> marker.ySet(7) val title = PadU16.wide().use { it.title() } diff --git a/ffi/tests/api.py b/ffi/tests/api.py index d38136af4..4378595ec 100644 --- a/ffi/tests/api.py +++ b/ffi/tests/api.py @@ -715,6 +715,7 @@ async def polls(): # The tab lends its field, so it outlives the read. tab = ledger.tab() print(f"tab {tab.ledger_get.published()}") + print(f"tab label {tab.label_get}") del tab marker = api.Marker.new("m", 3, 5) marker.y_set(7) diff --git a/ffi/tests/api.swift b/ffi/tests/api.swift index 17d18f3fe..c313aa439 100644 --- a/ffi/tests/api.swift +++ b/ffi/tests/api.swift @@ -933,6 +933,7 @@ func script() { // The tab lends its field, so it outlives the read. let tab = try! ledger.tab() print("tab \(try! tab.ledgerGet().published())") + print("tab label \(try! tab.labelGet)") } var marker = Marker.new("m", 3, 5) try! marker.ySet(7) diff --git a/ffi/tests/api.ts b/ffi/tests/api.ts index 565432b0c..4c7324bd0 100644 --- a/ffi/tests/api.ts +++ b/ffi/tests/api.ts @@ -940,6 +940,7 @@ async function script(): Promise { const tab = Ledger.tab(ledger); const tabbed = Tab.ledgerGet(tab); print(`tab ${Ledger.published(tabbed)}`); + print(`tab label ${Tab.labelGet(tab)}`); close(tabbed); close(tab); { diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index 8b2525d6e..c1ca5c309 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -131,9 +131,10 @@ fn deref_shadowing() { ] { assert!(header.contains(present), "{present} is not exported"); } - for absent in ["api_Layered_describe("] { - assert!(!header.contains(absent), "{absent} is exported"); - } + assert!( + !header.contains("api_Layered_describe("), + "api_Layered_describe( is exported" + ); } /// The api fixture, exported and built once for each language's test. @@ -2724,9 +2725,7 @@ fn unreached_types() { for dir in ["src", "kio", "net", "conv"] { step::mirror(&package.join(dir), &moved.join(dir)); } - for file in ["Cargo.toml"] { - std::fs::copy(package.join(file), moved.join(file)).unwrap(); - } + std::fs::copy(package.join("Cargo.toml"), moved.join("Cargo.toml")).unwrap(); let lib = std::fs::read_to_string(package.join("src/lib.rs")).unwrap(); let (head, rest) = lib.split_once("pub fn pending").unwrap(); let rest = &rest[rest.find("#[cfg(feature = \"refused\")] pub fn seal").unwrap()..]; diff --git a/ffi/tests/fixtures/shapes.rs b/ffi/tests/fixtures/shapes.rs index 84aefb44a..410fb88c0 100644 --- a/ffi/tests/fixtures/shapes.rs +++ b/ffi/tests/fixtures/shapes.rs @@ -632,10 +632,7 @@ fn emit(name: &str, shapes: &[Shape]) -> Crate { "[package]\nname = \"{name}\"\nversion = \"0.0.0\"\nedition = \"2024\"\npublish = false\n\n\ [dependencies]\nbytes = \"1\"\nserde_json = \"1\"\nurl = \"2\"\n\n[workspace]\n" ); - super::write_all( - &dir, - &[("Cargo.toml", &manifest), ("src/lib.rs", &lib)], - ); + super::write_all(&dir, &[("Cargo.toml", &manifest), ("src/lib.rs", &lib)]); // The api fixture's versions, resolved offline. super::step::copy(&manifest_dir().join("Cargo.lock"), &dir.join("Cargo.lock")); From 2d84e078f8fff47b65aef106d5b10159757ca0b0 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 22:21:44 -0800 Subject: [PATCH 07/10] ffi: the TS bench and bindings workflow take no config Co-Authored-By: Claude Opus 5.5 --- .github/workflows/bindings.yml | 12 ++++++------ ts/bench/build.ts | 2 +- ts/fixtures/codec/web/ffi.toml | 1 - ts/fixtures/task/web/ffi.toml | 1 - 4 files changed, 7 insertions(+), 9 deletions(-) delete mode 100644 ts/fixtures/codec/web/ffi.toml delete mode 100644 ts/fixtures/task/web/ffi.toml diff --git a/.github/workflows/bindings.yml b/.github/workflows/bindings.yml index 09619381f..a3891db91 100644 --- a/.github/workflows/bindings.yml +++ b/.github/workflows/bindings.yml @@ -141,7 +141,7 @@ jobs: - name: Stand-in if: steps.mode.outputs.fixture == 'true' working-directory: source - run: just ffi standin && cp ffi/moq/ffi.toml ffi/target/moq-ffi/ffi.toml + run: just ffi standin - id: facts working-directory: source run: python3 -I ../rust2/ffi/release/package.py facts --manifest-path "$MANIFEST" >> "$GITHUB_OUTPUT" @@ -206,7 +206,7 @@ jobs: - name: Stand-in if: needs.facts.outputs.fixture == 'true' working-directory: source - run: just ffi standin && cp ffi/moq/ffi.toml ffi/target/moq-ffi/ffi.toml + run: just ffi standin - name: Exporter working-directory: rust2/ffi env: @@ -279,7 +279,7 @@ jobs: - name: Stand-in if: needs.facts.outputs.fixture == 'true' working-directory: source - run: just ffi standin && cp ffi/moq/ffi.toml ffi/target/moq-ffi/ffi.toml + run: just ffi standin # The tools that build and repair, apart from the CPython the consumers test on. - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 with: @@ -425,7 +425,7 @@ jobs: - name: Stand-in if: needs.facts.outputs.fixture == 'true' working-directory: source - run: just ffi standin && cp ffi/moq/ffi.toml ffi/target/moq-ffi/ffi.toml + run: just ffi standin - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: pattern: ${{ needs.facts.outputs.name }}-build-apple-* @@ -609,7 +609,7 @@ jobs: - name: Stand-in if: needs.facts.outputs.web-fixture == 'true' working-directory: source - run: just ffi standin "" web && cp ffi/moq/web.toml ffi/target/moq-ffi-web/ffi.toml + run: just ffi standin "" web # npm packs, and Node's WASI runs the native example. - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: @@ -701,7 +701,7 @@ jobs: - name: Stand-in if: needs.facts.outputs.fixture == 'true' working-directory: source - run: just ffi standin && cp ffi/moq/ffi.toml ffi/target/moq-ffi/ffi.toml + run: just ffi standin - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: pattern: ${{ needs.facts.outputs.name }}-build-* diff --git a/ts/bench/build.ts b/ts/bench/build.ts index 2b3b20524..68593d5d3 100644 --- a/ts/bench/build.ts +++ b/ts/bench/build.ts @@ -99,7 +99,7 @@ export async function build(name: string, translated: string, tools: Tools): Pro const facade = join(root, "fixtures", name, "web"); await rm(built.export, { recursive: true, force: true }); - await step("rust2-ffi", [tools.ffi, "--config", join(facade, "ffi.toml"), "--target", "wasm32-wasip1", "--out", built.export]); + await step("rust2-ffi", [tools.ffi, "--manifest-path", join(facade, "Cargo.toml"), "--target", "wasm32-wasip1", "--out", built.export]); await step("export's build", [ "cargo", "build", diff --git a/ts/fixtures/codec/web/ffi.toml b/ts/fixtures/codec/web/ffi.toml deleted file mode 100644 index 35122f437..000000000 --- a/ts/fixtures/codec/web/ffi.toml +++ /dev/null @@ -1 +0,0 @@ -# Empty: rust2-ffi takes a config until /quest/m1/ffi-refusals/no-config.md drops it. diff --git a/ts/fixtures/task/web/ffi.toml b/ts/fixtures/task/web/ffi.toml deleted file mode 100644 index 35122f437..000000000 --- a/ts/fixtures/task/web/ffi.toml +++ /dev/null @@ -1 +0,0 @@ -# Empty: rust2-ffi takes a config until /quest/m1/ffi-refusals/no-config.md drops it. From dd76c7f3e9f7603dca57ba6b4508ce496c9fb1fa Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 22:45:57 -0800 Subject: [PATCH 08/10] ffi: a future's returned Cow is owned before the future ends Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/api/src/lib.rs | 11 +++++++ ffi/src/glue.rs | 59 +++++++++++++++++++++++-------------- ffi/surface/api/c.h | 12 +++++++- ffi/surface/api/cpp.hpp | 4 +++ ffi/surface/api/dart.dart | 2 ++ ffi/surface/api/go.txt | 2 ++ ffi/surface/api/kotlin.kt | 2 ++ ffi/surface/api/python.pyi | 2 ++ ffi/surface/api/swift.swift | 2 ++ ffi/surface/api/web.d.ts | 4 +++ ffi/tests/api.py | 5 ++++ 11 files changed, 82 insertions(+), 23 deletions(-) diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index f7ec62972..31c0153a8 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -5077,6 +5077,17 @@ pub fn unescaped(text: &str) -> Cow<'_, str> { } } +/// [`unescaped`], later: the future owns the text it borrows, so what it returns is +/// owned before the future ends. +pub async fn unescaped_later(text: &str) -> Cow<'_, str> { + unescaped(text) +} + +/// [`unescaped`] of `text` if any, later. +pub async fn unescaped_maybe(text: Option<&str>) -> Option> { + text.map(unescaped) +} + /// `bytes` without their zeros, borrowed where they have none. pub fn unzeroed(bytes: &[u8]) -> Cow<'_, [u8]> { match bytes.contains(&0) { diff --git a/ffi/src/glue.rs b/ffi/src/glue.rs index 692d5e6dd..ff0563f7d 100644 --- a/ffi/src/glue.rs +++ b/ffi/src/glue.rs @@ -3126,34 +3126,49 @@ fn ok_tail(body: &str) -> String { format!("Ok({{\n\t{body}\n\t}})") } -/// What a function returns, owned: each reference at its top or in a returned tuple as -/// its clone's type, with the expression cloning `v` into it, if any is one. +/// What a function returns, owned: each reference or `Cow` at its top, in a returned +/// tuple, or a `Cow` in its `Option`, as what it owns, with the expression owning `v`, if +/// any is one. fn owned(ok: &Type) -> (Type, Option) { - let one = |ty: &Type| match ty { - Type::Ref(_, inner) => Some(match &**inner { - Type::Str => Type::String, - Type::Slice => Type::Vec, - Type::Path => Type::PathBuf, - Type::List(Collection::Slice, item) => Type::List(Collection::Vec, item.clone()), - inner => inner.clone(), - }), - _ => None, - }; + // What `v` owns of `ty`, and how: a reference's copy, or the string or bytes a `Cow` + // crosses as, which may borrow too and is a move where it is already owned. + fn one(ty: &Type, v: &str) -> Option<(Type, String)> { + match ty { + Type::Ref(_, inner) => Some(( + match &**inner { + Type::Str => Type::String, + Type::Slice => Type::Vec, + Type::Path => Type::PathBuf, + Type::List(Collection::Slice, item) => Type::List(Collection::Vec, item.clone()), + inner => inner.clone(), + }, + format!("::std::borrow::ToOwned::to_owned({v})"), + )), + Type::String => Some((Type::String, format!("::std::string::String::from({v})"))), + Type::Vec => Some((Type::Vec, format!("::std::vec::Vec::::from({v})"))), + Type::Option(inner) if matches!(**inner, Type::String | Type::Vec) => { + let (ty, own) = one(inner, "v")?; + Some((Type::Option(Box::new(ty)), format!("{v}.map(|v| {own})"))) + } + _ => None, + } + } match ok { - Type::Tuple(elements) if elements.iter().any(|e| one(e).is_some()) => { + Type::Tuple(elements) if elements.iter().any(|e| one(e, "v").is_some()) => { let names: Vec = (0..elements.len()).map(|n| format!("v{n}")).collect(); - let owned: Vec = (elements.iter().zip(&names)) - .map(|(e, n)| match one(e) { - Some(_) => format!("::std::borrow::ToOwned::to_owned({n})"), - None => n.clone(), - }) + let owned: Vec<(Type, String)> = (elements.iter().zip(&names)) + .map(|(e, n)| one(e, n).unwrap_or_else(|| (e.clone(), n.clone()))) .collect(); - let ty = Type::Tuple(elements.iter().map(|e| one(e).unwrap_or_else(|| e.clone())).collect()); - let own = format!("{{ let ({},) = v; ({},) }}", names.join(", "), owned.join(", ")); + let ty = Type::Tuple(owned.iter().map(|(ty, _)| ty.clone()).collect()); + let own = format!( + "{{ let ({},) = v; ({},) }}", + names.join(", "), + owned.iter().map(|(_, own)| own.as_str()).collect::>().join(", ") + ); (ty, Some(own)) } - ok => match one(ok) { - Some(ty) => (ty, Some("::std::borrow::ToOwned::to_owned(v)".to_string())), + ok => match one(ok, "v") { + Some((ty, own)) => (ty, Some(own)), None => (ok.clone(), None), }, } diff --git a/ffi/surface/api/c.h b/ffi/surface/api/c.h index 6e472b953..f37d99afe 100644 --- a/ffi/surface/api/c.h +++ b/ffi/surface/api/c.h @@ -7,7 +7,7 @@ #ifdef __cplusplus extern "C" { #endif -#define API_CONTRACT ((uint64_t)0x1f86b0f8d481ff25ULL) +#define API_CONTRACT ((uint64_t)0xc3f575a8876239f4ULL) uint64_t api_contract(void); uint32_t api_target(void); typedef int32_t api_status; @@ -2294,6 +2294,16 @@ api_socket_addr_v4 api_same_socket_addr_v4(api_socket_addr_v4 v); api_socket_addr_v6 api_same_socket_addr_v6(api_socket_addr_v6 v); api_ip_addr api_same_ip_addr(api_ip_addr v); api_buf api_unescaped(api_buf text); +typedef struct api_unescaped_later_future api_unescaped_later_future; +api_unescaped_later_future *api_unescaped_later(api_buf text); +api_poll api_unescaped_later_start(api_buf text, api_buf *out, api_unescaped_later_future **future); +api_poll api_unescaped_later_poll(api_unescaped_later_future *future, api_waker waker, api_buf *out); +void api_unescaped_later_future_free(api_unescaped_later_future *future); +typedef struct api_unescaped_maybe_future api_unescaped_maybe_future; +api_unescaped_maybe_future *api_unescaped_maybe(api_buf text); +api_poll api_unescaped_maybe_start(api_buf text, api_buf *out, api_unescaped_maybe_future **future); +api_poll api_unescaped_maybe_poll(api_unescaped_maybe_future *future, api_waker waker, api_buf *out); +void api_unescaped_maybe_future_free(api_unescaped_maybe_future *future); api_buf api_unzeroed(api_buf bytes); uint64_t api_crowded(api_Reading reading, api_Stamp a, api_Stamp b, uint64_t n0, uint64_t n1, uint64_t n2, uint64_t n3, uint64_t n4, uint64_t n5, uint64_t n6, uint64_t n7, uint64_t n8, uint64_t n9, uint64_t n10, uint64_t n11, uint64_t n12, uint64_t n13, uint64_t n14, uint64_t n15, uint64_t n16, uint64_t n17, uint64_t n18, uint64_t n19, uint64_t n20, uint64_t n21, uint64_t n22, uint64_t n23, uint64_t n24, uint64_t n25, uint64_t n26, uint64_t n27, uint64_t n28, uint64_t n29, uint64_t n30, uint64_t n31, uint64_t n32, uint64_t n33, uint64_t n34, uint64_t n35, uint64_t n36, uint64_t n37, uint64_t n38, uint64_t n39, uint64_t n40, uint64_t n41, uint64_t n42, uint64_t n43, uint64_t n44, uint64_t n45, uint64_t n46, uint64_t n47, uint64_t n48, uint64_t n49, uint64_t n50, uint64_t n51, uint64_t n52, uint64_t n53, uint64_t n54, uint64_t n55, uint64_t n56, uint64_t n57, uint64_t n58, uint64_t n59, uint64_t n60, uint64_t n61, uint64_t n62, uint64_t n63, uint64_t n64, uint64_t n65, uint64_t n66, uint64_t n67, uint64_t n68, uint64_t n69, uint64_t n70, uint64_t n71, uint64_t n72, uint64_t n73, uint64_t n74, uint64_t n75, uint64_t n76, uint64_t n77, uint64_t n78, uint64_t n79, uint64_t n80, uint64_t n81, uint64_t n82, uint64_t n83, uint64_t n84, uint64_t n85, uint64_t n86, uint64_t n87, uint64_t n88, uint64_t n89, uint64_t n90, uint64_t n91, uint64_t n92, uint64_t n93, uint64_t n94, uint64_t n95, uint64_t n96, uint64_t n97, uint64_t n98, uint64_t n99, uint64_t n100, uint64_t n101, uint64_t n102, uint64_t n103, uint64_t n104, uint64_t n105, uint64_t n106, uint64_t n107, uint64_t n108, uint64_t n109, uint64_t n110, uint64_t n111, uint64_t n112, uint64_t n113, uint64_t n114, uint64_t n115, uint64_t n116, uint64_t n117, uint64_t n118); uint64_t api_crammed(api_Moment a, api_Moment b, uint64_t n0, uint64_t n1, uint64_t n2, uint64_t n3, uint64_t n4, uint64_t n5, uint64_t n6, uint64_t n7, uint64_t n8, uint64_t n9, uint64_t n10, uint64_t n11, uint64_t n12, uint64_t n13, uint64_t n14, uint64_t n15, uint64_t n16, uint64_t n17, uint64_t n18, uint64_t n19, uint64_t n20, uint64_t n21, uint64_t n22, uint64_t n23, uint64_t n24, uint64_t n25, uint64_t n26, uint64_t n27, uint64_t n28, uint64_t n29, uint64_t n30, uint64_t n31, uint64_t n32, uint64_t n33, uint64_t n34, uint64_t n35, uint64_t n36, uint64_t n37, uint64_t n38, uint64_t n39, uint64_t n40, uint64_t n41, uint64_t n42, uint64_t n43, uint64_t n44, uint64_t n45, uint64_t n46, uint64_t n47, uint64_t n48, uint64_t n49, uint64_t n50, uint64_t n51, uint64_t n52, uint64_t n53, uint64_t n54, uint64_t n55, uint64_t n56, uint64_t n57, uint64_t n58, uint64_t n59, uint64_t n60, uint64_t n61, uint64_t n62, uint64_t n63, uint64_t n64, uint64_t n65, uint64_t n66, uint64_t n67, uint64_t n68, uint64_t n69, uint64_t n70, uint64_t n71, uint64_t n72, uint64_t n73, uint64_t n74, uint64_t n75, uint64_t n76, uint64_t n77, uint64_t n78, uint64_t n79, uint64_t n80, uint64_t n81, uint64_t n82, uint64_t n83, uint64_t n84, uint64_t n85, uint64_t n86, uint64_t n87, uint64_t n88, uint64_t n89, uint64_t n90, uint64_t n91, uint64_t n92, uint64_t n93, uint64_t n94, uint64_t n95, uint64_t n96, uint64_t n97, uint64_t n98, uint64_t n99, uint64_t n100, uint64_t n101, uint64_t n102, uint64_t n103, uint64_t n104, uint64_t n105, uint64_t n106, uint64_t n107, uint64_t n108, uint64_t n109, uint64_t n110, uint64_t n111, uint64_t n112, uint64_t n113, uint64_t n114, uint64_t n115, uint64_t n116, uint64_t n117, uint64_t n118, uint64_t n119, uint64_t n120, uint64_t n121, uint64_t n122, uint64_t n123); diff --git a/ffi/surface/api/cpp.hpp b/ffi/surface/api/cpp.hpp index da5f5d27e..daccf13cf 100644 --- a/ffi/surface/api/cpp.hpp +++ b/ffi/surface/api/cpp.hpp @@ -1592,6 +1592,8 @@ namespace api { inline ::api::socket_addr_v6 same_socket_addr_v6(::api::socket_addr_v6 v); inline ::api::ip_addr same_ip_addr(::api::ip_addr v); inline ::api::buf unescaped(::api::input text); + inline ::api::unescaped_later_future unescaped_later(::api::input text); + inline ::api::unescaped_maybe_future unescaped_maybe(::std::optional<::api::input> text); inline ::api::buf unzeroed(::api::input bytes); inline ::std::uint64_t crowded(const ::api::Reading &reading, const ::api::Stamp &a__, const ::api::Stamp &b_, ::std::uint64_t n0, ::std::uint64_t n1, ::std::uint64_t n2, ::std::uint64_t n3, ::std::uint64_t n4, ::std::uint64_t n5, ::std::uint64_t n6, ::std::uint64_t n7, ::std::uint64_t n8, ::std::uint64_t n9, ::std::uint64_t n10, ::std::uint64_t n11, ::std::uint64_t n12, ::std::uint64_t n13, ::std::uint64_t n14, ::std::uint64_t n15, ::std::uint64_t n16, ::std::uint64_t n17, ::std::uint64_t n18, ::std::uint64_t n19, ::std::uint64_t n20, ::std::uint64_t n21, ::std::uint64_t n22, ::std::uint64_t n23, ::std::uint64_t n24, ::std::uint64_t n25, ::std::uint64_t n26, ::std::uint64_t n27, ::std::uint64_t n28, ::std::uint64_t n29, ::std::uint64_t n30, ::std::uint64_t n31, ::std::uint64_t n32, ::std::uint64_t n33, ::std::uint64_t n34, ::std::uint64_t n35, ::std::uint64_t n36, ::std::uint64_t n37, ::std::uint64_t n38, ::std::uint64_t n39, ::std::uint64_t n40, ::std::uint64_t n41, ::std::uint64_t n42, ::std::uint64_t n43, ::std::uint64_t n44, ::std::uint64_t n45, ::std::uint64_t n46, ::std::uint64_t n47, ::std::uint64_t n48, ::std::uint64_t n49, ::std::uint64_t n50, ::std::uint64_t n51, ::std::uint64_t n52, ::std::uint64_t n53, ::std::uint64_t n54, ::std::uint64_t n55, ::std::uint64_t n56, ::std::uint64_t n57, ::std::uint64_t n58, ::std::uint64_t n59, ::std::uint64_t n60, ::std::uint64_t n61, ::std::uint64_t n62, ::std::uint64_t n63, ::std::uint64_t n64, ::std::uint64_t n65, ::std::uint64_t n66, ::std::uint64_t n67, ::std::uint64_t n68, ::std::uint64_t n69, ::std::uint64_t n70, ::std::uint64_t n71, ::std::uint64_t n72, ::std::uint64_t n73, ::std::uint64_t n74, ::std::uint64_t n75, ::std::uint64_t n76, ::std::uint64_t n77, ::std::uint64_t n78, ::std::uint64_t n79, ::std::uint64_t n80, ::std::uint64_t n81, ::std::uint64_t n82, ::std::uint64_t n83, ::std::uint64_t n84, ::std::uint64_t n85, ::std::uint64_t n86, ::std::uint64_t n87, ::std::uint64_t n88, ::std::uint64_t n89, ::std::uint64_t n90, ::std::uint64_t n91, ::std::uint64_t n92, ::std::uint64_t n93, ::std::uint64_t n94, ::std::uint64_t n95, ::std::uint64_t n96, ::std::uint64_t n97, ::std::uint64_t n98, ::std::uint64_t n99, ::std::uint64_t n100, ::std::uint64_t n101, ::std::uint64_t n102, ::std::uint64_t n103, ::std::uint64_t n104, ::std::uint64_t n105, ::std::uint64_t n106, ::std::uint64_t n107, ::std::uint64_t n108, ::std::uint64_t n109, ::std::uint64_t n110, ::std::uint64_t n111, ::std::uint64_t n112, ::std::uint64_t n113, ::std::uint64_t n114, ::std::uint64_t n115, ::std::uint64_t n116, ::std::uint64_t n117, ::std::uint64_t n118); inline ::std::uint64_t crammed(const ::api::Moment &a__, const ::api::Moment &b_, ::std::uint64_t n0, ::std::uint64_t n1, ::std::uint64_t n2, ::std::uint64_t n3, ::std::uint64_t n4, ::std::uint64_t n5, ::std::uint64_t n6, ::std::uint64_t n7, ::std::uint64_t n8, ::std::uint64_t n9, ::std::uint64_t n10, ::std::uint64_t n11, ::std::uint64_t n12, ::std::uint64_t n13, ::std::uint64_t n14, ::std::uint64_t n15, ::std::uint64_t n16, ::std::uint64_t n17, ::std::uint64_t n18, ::std::uint64_t n19, ::std::uint64_t n20, ::std::uint64_t n21, ::std::uint64_t n22, ::std::uint64_t n23, ::std::uint64_t n24, ::std::uint64_t n25, ::std::uint64_t n26, ::std::uint64_t n27, ::std::uint64_t n28, ::std::uint64_t n29, ::std::uint64_t n30, ::std::uint64_t n31, ::std::uint64_t n32, ::std::uint64_t n33, ::std::uint64_t n34, ::std::uint64_t n35, ::std::uint64_t n36, ::std::uint64_t n37, ::std::uint64_t n38, ::std::uint64_t n39, ::std::uint64_t n40, ::std::uint64_t n41, ::std::uint64_t n42, ::std::uint64_t n43, ::std::uint64_t n44, ::std::uint64_t n45, ::std::uint64_t n46, ::std::uint64_t n47, ::std::uint64_t n48, ::std::uint64_t n49, ::std::uint64_t n50, ::std::uint64_t n51, ::std::uint64_t n52, ::std::uint64_t n53, ::std::uint64_t n54, ::std::uint64_t n55, ::std::uint64_t n56, ::std::uint64_t n57, ::std::uint64_t n58, ::std::uint64_t n59, ::std::uint64_t n60, ::std::uint64_t n61, ::std::uint64_t n62, ::std::uint64_t n63, ::std::uint64_t n64, ::std::uint64_t n65, ::std::uint64_t n66, ::std::uint64_t n67, ::std::uint64_t n68, ::std::uint64_t n69, ::std::uint64_t n70, ::std::uint64_t n71, ::std::uint64_t n72, ::std::uint64_t n73, ::std::uint64_t n74, ::std::uint64_t n75, ::std::uint64_t n76, ::std::uint64_t n77, ::std::uint64_t n78, ::std::uint64_t n79, ::std::uint64_t n80, ::std::uint64_t n81, ::std::uint64_t n82, ::std::uint64_t n83, ::std::uint64_t n84, ::std::uint64_t n85, ::std::uint64_t n86, ::std::uint64_t n87, ::std::uint64_t n88, ::std::uint64_t n89, ::std::uint64_t n90, ::std::uint64_t n91, ::std::uint64_t n92, ::std::uint64_t n93, ::std::uint64_t n94, ::std::uint64_t n95, ::std::uint64_t n96, ::std::uint64_t n97, ::std::uint64_t n98, ::std::uint64_t n99, ::std::uint64_t n100, ::std::uint64_t n101, ::std::uint64_t n102, ::std::uint64_t n103, ::std::uint64_t n104, ::std::uint64_t n105, ::std::uint64_t n106, ::std::uint64_t n107, ::std::uint64_t n108, ::std::uint64_t n109, ::std::uint64_t n110, ::std::uint64_t n111, ::std::uint64_t n112, ::std::uint64_t n113, ::std::uint64_t n114, ::std::uint64_t n115, ::std::uint64_t n116, ::std::uint64_t n117, ::std::uint64_t n118, ::std::uint64_t n119, ::std::uint64_t n120, ::std::uint64_t n121, ::std::uint64_t n122, ::std::uint64_t n123); @@ -2090,6 +2092,8 @@ namespace api { using byte_len_future = ::api::future; using parse_later_future = ::api::future; using either_later_future = ::api::future; + using unescaped_later_future = ::api::future; + using unescaped_maybe_future = ::api::future; using emit_later_future = ::api::future; using log_on_drop_future = ::api::future; } diff --git a/ffi/surface/api/dart.dart b/ffi/surface/api/dart.dart index cbce3d495..8e2bc0909 100644 --- a/ffi/surface/api/dart.dart +++ b/ffi/surface/api/dart.dart @@ -1743,6 +1743,8 @@ SocketAddrV4 sameSocketAddrV4(SocketAddrV4 v); SocketAddrV6 sameSocketAddrV6(SocketAddrV6 v); IpAddr sameIpAddr(IpAddr v); String unescaped(String text); +Cancelable unescapedLater(String text); +Cancelable unescapedMaybe(String? text); typed.Uint8List unzeroed(typed.Uint8List bytes); U64 crowded(Reading reading, Stamp a, Stamp b, U64 n0, U64 n1, U64 n2, U64 n3, U64 n4, U64 n5, U64 n6, U64 n7, U64 n8, U64 n9, U64 n10, U64 n11, U64 n12, U64 n13, U64 n14, U64 n15, U64 n16, U64 n17, U64 n18, U64 n19, U64 n20, U64 n21, U64 n22, U64 n23, U64 n24, U64 n25, U64 n26, U64 n27, U64 n28, U64 n29, U64 n30, U64 n31, U64 n32, U64 n33, U64 n34, U64 n35, U64 n36, U64 n37, U64 n38, U64 n39, U64 n40, U64 n41, U64 n42, U64 n43, U64 n44, U64 n45, U64 n46, U64 n47, U64 n48, U64 n49, U64 n50, U64 n51, U64 n52, U64 n53, U64 n54, U64 n55, U64 n56, U64 n57, U64 n58, U64 n59, U64 n60, U64 n61, U64 n62, U64 n63, U64 n64, U64 n65, U64 n66, U64 n67, U64 n68, U64 n69, U64 n70, U64 n71, U64 n72, U64 n73, U64 n74, U64 n75, U64 n76, U64 n77, U64 n78, U64 n79, U64 n80, U64 n81, U64 n82, U64 n83, U64 n84, U64 n85, U64 n86, U64 n87, U64 n88, U64 n89, U64 n90, U64 n91, U64 n92, U64 n93, U64 n94, U64 n95, U64 n96, U64 n97, U64 n98, U64 n99, U64 n100, U64 n101, U64 n102, U64 n103, U64 n104, U64 n105, U64 n106, U64 n107, U64 n108, U64 n109, U64 n110, U64 n111, U64 n112, U64 n113, U64 n114, U64 n115, U64 n116, U64 n117, U64 n118); U64 crammed(Moment a, Moment b, U64 n0, U64 n1, U64 n2, U64 n3, U64 n4, U64 n5, U64 n6, U64 n7, U64 n8, U64 n9, U64 n10, U64 n11, U64 n12, U64 n13, U64 n14, U64 n15, U64 n16, U64 n17, U64 n18, U64 n19, U64 n20, U64 n21, U64 n22, U64 n23, U64 n24, U64 n25, U64 n26, U64 n27, U64 n28, U64 n29, U64 n30, U64 n31, U64 n32, U64 n33, U64 n34, U64 n35, U64 n36, U64 n37, U64 n38, U64 n39, U64 n40, U64 n41, U64 n42, U64 n43, U64 n44, U64 n45, U64 n46, U64 n47, U64 n48, U64 n49, U64 n50, U64 n51, U64 n52, U64 n53, U64 n54, U64 n55, U64 n56, U64 n57, U64 n58, U64 n59, U64 n60, U64 n61, U64 n62, U64 n63, U64 n64, U64 n65, U64 n66, U64 n67, U64 n68, U64 n69, U64 n70, U64 n71, U64 n72, U64 n73, U64 n74, U64 n75, U64 n76, U64 n77, U64 n78, U64 n79, U64 n80, U64 n81, U64 n82, U64 n83, U64 n84, U64 n85, U64 n86, U64 n87, U64 n88, U64 n89, U64 n90, U64 n91, U64 n92, U64 n93, U64 n94, U64 n95, U64 n96, U64 n97, U64 n98, U64 n99, U64 n100, U64 n101, U64 n102, U64 n103, U64 n104, U64 n105, U64 n106, U64 n107, U64 n108, U64 n109, U64 n110, U64 n111, U64 n112, U64 n113, U64 n114, U64 n115, U64 n116, U64 n117, U64 n118, U64 n119, U64 n120, U64 n121, U64 n122, U64 n123); diff --git a/ffi/surface/api/go.txt b/ffi/surface/api/go.txt index a2cabc3af..2d73dd4ce 100644 --- a/ffi/surface/api/go.txt +++ b/ffi/surface/api/go.txt @@ -231,6 +231,8 @@ func TokenBytes(id uint32, len_ uint32) p_rt.Bytes func TokenSlice(id uint32, len_ uint32, of uint32) p_rt.Bytes func Total(range_ p_rt.RangeU64) uint64 func Unescaped(text string) (string, error) +func UnescapedLater(ctx context.Context, text string) (string, error) +func UnescapedMaybe(ctx context.Context, text *string) (*string, error) func Unhook() error func Unzeroed(bytes p_rt.Bytes) p_rt.Bytes func Verify(cert *p_tls.Cert) (uint32, error) diff --git a/ffi/surface/api/kotlin.kt b/ffi/surface/api/kotlin.kt index 476c9d5b1..37300f8a1 100644 --- a/ffi/surface/api/kotlin.kt +++ b/ffi/surface/api/kotlin.kt @@ -1543,6 +1543,8 @@ fun sameSocketAddrV4(v: api.SocketAddrV4): api.SocketAddrV4 fun sameSocketAddrV6(v: api.SocketAddrV6): api.SocketAddrV6 fun sameIpAddr(v: api.IpAddr): api.IpAddr fun unescaped(text: kotlin.String): kotlin.String +suspend fun unescapedLater(text: kotlin.String): kotlin.String +suspend fun unescapedMaybe(text: kotlin.String?): kotlin.String? fun unzeroed(bytes: api.Bytes): api.Bytes fun crowded(reading: api.Reading, a: api.Stamp, b: api.Stamp, n0: kotlin.ULong, n1: kotlin.ULong, n2: kotlin.ULong, n3: kotlin.ULong, n4: kotlin.ULong, n5: kotlin.ULong, n6: kotlin.ULong, n7: kotlin.ULong, n8: kotlin.ULong, n9: kotlin.ULong, n10: kotlin.ULong, n11: kotlin.ULong, n12: kotlin.ULong, n13: kotlin.ULong, n14: kotlin.ULong, n15: kotlin.ULong, n16: kotlin.ULong, n17: kotlin.ULong, n18: kotlin.ULong, n19: kotlin.ULong, n20: kotlin.ULong, n21: kotlin.ULong, n22: kotlin.ULong, n23: kotlin.ULong, n24: kotlin.ULong, n25: kotlin.ULong, n26: kotlin.ULong, n27: kotlin.ULong, n28: kotlin.ULong, n29: kotlin.ULong, n30: kotlin.ULong, n31: kotlin.ULong, n32: kotlin.ULong, n33: kotlin.ULong, n34: kotlin.ULong, n35: kotlin.ULong, n36: kotlin.ULong, n37: kotlin.ULong, n38: kotlin.ULong, n39: kotlin.ULong, n40: kotlin.ULong, n41: kotlin.ULong, n42: kotlin.ULong, n43: kotlin.ULong, n44: kotlin.ULong, n45: kotlin.ULong, n46: kotlin.ULong, n47: kotlin.ULong, n48: kotlin.ULong, n49: kotlin.ULong, n50: kotlin.ULong, n51: kotlin.ULong, n52: kotlin.ULong, n53: kotlin.ULong, n54: kotlin.ULong, n55: kotlin.ULong, n56: kotlin.ULong, n57: kotlin.ULong, n58: kotlin.ULong, n59: kotlin.ULong, n60: kotlin.ULong, n61: kotlin.ULong, n62: kotlin.ULong, n63: kotlin.ULong, n64: kotlin.ULong, n65: kotlin.ULong, n66: kotlin.ULong, n67: kotlin.ULong, n68: kotlin.ULong, n69: kotlin.ULong, n70: kotlin.ULong, n71: kotlin.ULong, n72: kotlin.ULong, n73: kotlin.ULong, n74: kotlin.ULong, n75: kotlin.ULong, n76: kotlin.ULong, n77: kotlin.ULong, n78: kotlin.ULong, n79: kotlin.ULong, n80: kotlin.ULong, n81: kotlin.ULong, n82: kotlin.ULong, n83: kotlin.ULong, n84: kotlin.ULong, n85: kotlin.ULong, n86: kotlin.ULong, n87: kotlin.ULong, n88: kotlin.ULong, n89: kotlin.ULong, n90: kotlin.ULong, n91: kotlin.ULong, n92: kotlin.ULong, n93: kotlin.ULong, n94: kotlin.ULong, n95: kotlin.ULong, n96: kotlin.ULong, n97: kotlin.ULong, n98: kotlin.ULong, n99: kotlin.ULong, n100: kotlin.ULong, n101: kotlin.ULong, n102: kotlin.ULong, n103: kotlin.ULong, n104: kotlin.ULong, n105: kotlin.ULong, n106: kotlin.ULong, n107: kotlin.ULong, n108: kotlin.ULong, n109: kotlin.ULong, n110: kotlin.ULong, n111: kotlin.ULong, n112: kotlin.ULong, n113: kotlin.ULong, n114: kotlin.ULong, n115: kotlin.ULong, n116: kotlin.ULong, n117: kotlin.ULong, n118: kotlin.ULong): kotlin.ULong fun crammed(a: api.Moment, b: api.Moment, n0: kotlin.ULong, n1: kotlin.ULong, n2: kotlin.ULong, n3: kotlin.ULong, n4: kotlin.ULong, n5: kotlin.ULong, n6: kotlin.ULong, n7: kotlin.ULong, n8: kotlin.ULong, n9: kotlin.ULong, n10: kotlin.ULong, n11: kotlin.ULong, n12: kotlin.ULong, n13: kotlin.ULong, n14: kotlin.ULong, n15: kotlin.ULong, n16: kotlin.ULong, n17: kotlin.ULong, n18: kotlin.ULong, n19: kotlin.ULong, n20: kotlin.ULong, n21: kotlin.ULong, n22: kotlin.ULong, n23: kotlin.ULong, n24: kotlin.ULong, n25: kotlin.ULong, n26: kotlin.ULong, n27: kotlin.ULong, n28: kotlin.ULong, n29: kotlin.ULong, n30: kotlin.ULong, n31: kotlin.ULong, n32: kotlin.ULong, n33: kotlin.ULong, n34: kotlin.ULong, n35: kotlin.ULong, n36: kotlin.ULong, n37: kotlin.ULong, n38: kotlin.ULong, n39: kotlin.ULong, n40: kotlin.ULong, n41: kotlin.ULong, n42: kotlin.ULong, n43: kotlin.ULong, n44: kotlin.ULong, n45: kotlin.ULong, n46: kotlin.ULong, n47: kotlin.ULong, n48: kotlin.ULong, n49: kotlin.ULong, n50: kotlin.ULong, n51: kotlin.ULong, n52: kotlin.ULong, n53: kotlin.ULong, n54: kotlin.ULong, n55: kotlin.ULong, n56: kotlin.ULong, n57: kotlin.ULong, n58: kotlin.ULong, n59: kotlin.ULong, n60: kotlin.ULong, n61: kotlin.ULong, n62: kotlin.ULong, n63: kotlin.ULong, n64: kotlin.ULong, n65: kotlin.ULong, n66: kotlin.ULong, n67: kotlin.ULong, n68: kotlin.ULong, n69: kotlin.ULong, n70: kotlin.ULong, n71: kotlin.ULong, n72: kotlin.ULong, n73: kotlin.ULong, n74: kotlin.ULong, n75: kotlin.ULong, n76: kotlin.ULong, n77: kotlin.ULong, n78: kotlin.ULong, n79: kotlin.ULong, n80: kotlin.ULong, n81: kotlin.ULong, n82: kotlin.ULong, n83: kotlin.ULong, n84: kotlin.ULong, n85: kotlin.ULong, n86: kotlin.ULong, n87: kotlin.ULong, n88: kotlin.ULong, n89: kotlin.ULong, n90: kotlin.ULong, n91: kotlin.ULong, n92: kotlin.ULong, n93: kotlin.ULong, n94: kotlin.ULong, n95: kotlin.ULong, n96: kotlin.ULong, n97: kotlin.ULong, n98: kotlin.ULong, n99: kotlin.ULong, n100: kotlin.ULong, n101: kotlin.ULong, n102: kotlin.ULong, n103: kotlin.ULong, n104: kotlin.ULong, n105: kotlin.ULong, n106: kotlin.ULong, n107: kotlin.ULong, n108: kotlin.ULong, n109: kotlin.ULong, n110: kotlin.ULong, n111: kotlin.ULong, n112: kotlin.ULong, n113: kotlin.ULong, n114: kotlin.ULong, n115: kotlin.ULong, n116: kotlin.ULong, n117: kotlin.ULong, n118: kotlin.ULong, n119: kotlin.ULong, n120: kotlin.ULong, n121: kotlin.ULong, n122: kotlin.ULong, n123: kotlin.ULong): kotlin.ULong diff --git a/ffi/surface/api/python.pyi b/ffi/surface/api/python.pyi index 813ab9221..1637ecadb 100644 --- a/ffi/surface/api/python.pyi +++ b/ffi/surface/api/python.pyi @@ -1329,6 +1329,8 @@ async def local_later(n: _int) -> _int: ... async def poll_tripled(n: _int) -> _int: ... async def parse_later(text: _str) -> _int: ... async def either_later(text: _str | None) -> _int: ... +async def unescaped_later(text: _str) -> _str: ... +async def unescaped_maybe(text: _str | None) -> _str | None: ... def has_text(note: Note) -> _bool: ... def marked(api_marked: Mark) -> _int: ... def reading(n: _int) -> Reading | None: ... diff --git a/ffi/surface/api/swift.swift b/ffi/surface/api/swift.swift index 1c7cb01b3..7e7ef931e 100644 --- a/ffi/surface/api/swift.swift +++ b/ffi/surface/api/swift.swift @@ -1573,6 +1573,8 @@ public let FAR: Swift.Int64 @inlinable public func sameSocketAddrV6(_ v: SocketAddrV6) -> SocketAddrV6 @inlinable public func sameIpAddr(_ v: IpAddr) -> IpAddr @inlinable public func unescaped(_ text: Swift.String) -> Swift.String +@inlinable nonisolated(nonsending) public func unescapedLater(_ text: Swift.String) async throws -> Swift.String +@inlinable nonisolated(nonsending) public func unescapedMaybe(_ text: Swift.String?) async throws -> Swift.String? @inlinable public func unzeroed(_ bytes: Bytes) -> Bytes @inlinable public func crowded(_ reading: Reading, _ a: Stamp, _ b: Stamp, _ n0: Swift.UInt64, _ n1: Swift.UInt64, _ n2: Swift.UInt64, _ n3: Swift.UInt64, _ n4: Swift.UInt64, _ n5: Swift.UInt64, _ n6: Swift.UInt64, _ n7: Swift.UInt64, _ n8: Swift.UInt64, _ n9: Swift.UInt64, _ n10: Swift.UInt64, _ n11: Swift.UInt64, _ n12: Swift.UInt64, _ n13: Swift.UInt64, _ n14: Swift.UInt64, _ n15: Swift.UInt64, _ n16: Swift.UInt64, _ n17: Swift.UInt64, _ n18: Swift.UInt64, _ n19: Swift.UInt64, _ n20: Swift.UInt64, _ n21: Swift.UInt64, _ n22: Swift.UInt64, _ n23: Swift.UInt64, _ n24: Swift.UInt64, _ n25: Swift.UInt64, _ n26: Swift.UInt64, _ n27: Swift.UInt64, _ n28: Swift.UInt64, _ n29: Swift.UInt64, _ n30: Swift.UInt64, _ n31: Swift.UInt64, _ n32: Swift.UInt64, _ n33: Swift.UInt64, _ n34: Swift.UInt64, _ n35: Swift.UInt64, _ n36: Swift.UInt64, _ n37: Swift.UInt64, _ n38: Swift.UInt64, _ n39: Swift.UInt64, _ n40: Swift.UInt64, _ n41: Swift.UInt64, _ n42: Swift.UInt64, _ n43: Swift.UInt64, _ n44: Swift.UInt64, _ n45: Swift.UInt64, _ n46: Swift.UInt64, _ n47: Swift.UInt64, _ n48: Swift.UInt64, _ n49: Swift.UInt64, _ n50: Swift.UInt64, _ n51: Swift.UInt64, _ n52: Swift.UInt64, _ n53: Swift.UInt64, _ n54: Swift.UInt64, _ n55: Swift.UInt64, _ n56: Swift.UInt64, _ n57: Swift.UInt64, _ n58: Swift.UInt64, _ n59: Swift.UInt64, _ n60: Swift.UInt64, _ n61: Swift.UInt64, _ n62: Swift.UInt64, _ n63: Swift.UInt64, _ n64: Swift.UInt64, _ n65: Swift.UInt64, _ n66: Swift.UInt64, _ n67: Swift.UInt64, _ n68: Swift.UInt64, _ n69: Swift.UInt64, _ n70: Swift.UInt64, _ n71: Swift.UInt64, _ n72: Swift.UInt64, _ n73: Swift.UInt64, _ n74: Swift.UInt64, _ n75: Swift.UInt64, _ n76: Swift.UInt64, _ n77: Swift.UInt64, _ n78: Swift.UInt64, _ n79: Swift.UInt64, _ n80: Swift.UInt64, _ n81: Swift.UInt64, _ n82: Swift.UInt64, _ n83: Swift.UInt64, _ n84: Swift.UInt64, _ n85: Swift.UInt64, _ n86: Swift.UInt64, _ n87: Swift.UInt64, _ n88: Swift.UInt64, _ n89: Swift.UInt64, _ n90: Swift.UInt64, _ n91: Swift.UInt64, _ n92: Swift.UInt64, _ n93: Swift.UInt64, _ n94: Swift.UInt64, _ n95: Swift.UInt64, _ n96: Swift.UInt64, _ n97: Swift.UInt64, _ n98: Swift.UInt64, _ n99: Swift.UInt64, _ n100: Swift.UInt64, _ n101: Swift.UInt64, _ n102: Swift.UInt64, _ n103: Swift.UInt64, _ n104: Swift.UInt64, _ n105: Swift.UInt64, _ n106: Swift.UInt64, _ n107: Swift.UInt64, _ n108: Swift.UInt64, _ n109: Swift.UInt64, _ n110: Swift.UInt64, _ n111: Swift.UInt64, _ n112: Swift.UInt64, _ n113: Swift.UInt64, _ n114: Swift.UInt64, _ n115: Swift.UInt64, _ n116: Swift.UInt64, _ n117: Swift.UInt64, _ n118: Swift.UInt64) -> Swift.UInt64 @inlinable public func crammed(_ a: Moment, _ b: Moment, _ n0: Swift.UInt64, _ n1: Swift.UInt64, _ n2: Swift.UInt64, _ n3: Swift.UInt64, _ n4: Swift.UInt64, _ n5: Swift.UInt64, _ n6: Swift.UInt64, _ n7: Swift.UInt64, _ n8: Swift.UInt64, _ n9: Swift.UInt64, _ n10: Swift.UInt64, _ n11: Swift.UInt64, _ n12: Swift.UInt64, _ n13: Swift.UInt64, _ n14: Swift.UInt64, _ n15: Swift.UInt64, _ n16: Swift.UInt64, _ n17: Swift.UInt64, _ n18: Swift.UInt64, _ n19: Swift.UInt64, _ n20: Swift.UInt64, _ n21: Swift.UInt64, _ n22: Swift.UInt64, _ n23: Swift.UInt64, _ n24: Swift.UInt64, _ n25: Swift.UInt64, _ n26: Swift.UInt64, _ n27: Swift.UInt64, _ n28: Swift.UInt64, _ n29: Swift.UInt64, _ n30: Swift.UInt64, _ n31: Swift.UInt64, _ n32: Swift.UInt64, _ n33: Swift.UInt64, _ n34: Swift.UInt64, _ n35: Swift.UInt64, _ n36: Swift.UInt64, _ n37: Swift.UInt64, _ n38: Swift.UInt64, _ n39: Swift.UInt64, _ n40: Swift.UInt64, _ n41: Swift.UInt64, _ n42: Swift.UInt64, _ n43: Swift.UInt64, _ n44: Swift.UInt64, _ n45: Swift.UInt64, _ n46: Swift.UInt64, _ n47: Swift.UInt64, _ n48: Swift.UInt64, _ n49: Swift.UInt64, _ n50: Swift.UInt64, _ n51: Swift.UInt64, _ n52: Swift.UInt64, _ n53: Swift.UInt64, _ n54: Swift.UInt64, _ n55: Swift.UInt64, _ n56: Swift.UInt64, _ n57: Swift.UInt64, _ n58: Swift.UInt64, _ n59: Swift.UInt64, _ n60: Swift.UInt64, _ n61: Swift.UInt64, _ n62: Swift.UInt64, _ n63: Swift.UInt64, _ n64: Swift.UInt64, _ n65: Swift.UInt64, _ n66: Swift.UInt64, _ n67: Swift.UInt64, _ n68: Swift.UInt64, _ n69: Swift.UInt64, _ n70: Swift.UInt64, _ n71: Swift.UInt64, _ n72: Swift.UInt64, _ n73: Swift.UInt64, _ n74: Swift.UInt64, _ n75: Swift.UInt64, _ n76: Swift.UInt64, _ n77: Swift.UInt64, _ n78: Swift.UInt64, _ n79: Swift.UInt64, _ n80: Swift.UInt64, _ n81: Swift.UInt64, _ n82: Swift.UInt64, _ n83: Swift.UInt64, _ n84: Swift.UInt64, _ n85: Swift.UInt64, _ n86: Swift.UInt64, _ n87: Swift.UInt64, _ n88: Swift.UInt64, _ n89: Swift.UInt64, _ n90: Swift.UInt64, _ n91: Swift.UInt64, _ n92: Swift.UInt64, _ n93: Swift.UInt64, _ n94: Swift.UInt64, _ n95: Swift.UInt64, _ n96: Swift.UInt64, _ n97: Swift.UInt64, _ n98: Swift.UInt64, _ n99: Swift.UInt64, _ n100: Swift.UInt64, _ n101: Swift.UInt64, _ n102: Swift.UInt64, _ n103: Swift.UInt64, _ n104: Swift.UInt64, _ n105: Swift.UInt64, _ n106: Swift.UInt64, _ n107: Swift.UInt64, _ n108: Swift.UInt64, _ n109: Swift.UInt64, _ n110: Swift.UInt64, _ n111: Swift.UInt64, _ n112: Swift.UInt64, _ n113: Swift.UInt64, _ n114: Swift.UInt64, _ n115: Swift.UInt64, _ n116: Swift.UInt64, _ n117: Swift.UInt64, _ n118: Swift.UInt64, _ n119: Swift.UInt64, _ n120: Swift.UInt64, _ n121: Swift.UInt64, _ n122: Swift.UInt64, _ n123: Swift.UInt64) -> Swift.UInt64 diff --git a/ffi/surface/api/web.d.ts b/ffi/surface/api/web.d.ts index 2a24e8041..6e14635f1 100644 --- a/ffi/surface/api/web.d.ts +++ b/ffi/surface/api/web.d.ts @@ -1742,6 +1742,8 @@ export declare function p_local_or_new_later(f: number, w$: number): [boolean, L export declare function p_log_later(f: number, w$: number): [boolean, boolean]; export declare function p_parse_later(f: number, w$: number): [boolean, rt.Result]; export declare function p_poll_tripled(f: number, w$: number): [boolean, number]; +export declare function p_unescaped_later(f: number, w$: number): [boolean, string]; +export declare function p_unescaped_maybe(f: number, w$: number): [boolean, string | undefined]; export declare function p_within(f: number, w$: number): [boolean, rt.Result]; export declare function p_yielded(f: number, w$: number): [boolean, number]; export declare function r_Atlas(p: number, o: boolean): Atlas; @@ -2513,6 +2515,8 @@ export declare function sameSocketAddrV4(v: rt.SocketAddrV4): rt.SocketAddrV4; export declare function sameSocketAddrV6(v: rt.SocketAddrV6): rt.SocketAddrV6; export declare function sameIpAddr(v: rt.IpAddr): rt.IpAddr; export declare function unescaped(text: string): string; +export declare function unescapedLater(text: string): rt.Call; +export declare function unescapedMaybe(text: string | undefined): rt.Call; export declare function unzeroed(bytes: Uint8Array | rt.Bytes): rt.Bytes; export declare function crowded(reading: Reading, a: Stamp, b: Stamp, n0: rt.u64, n1: rt.u64, n2: rt.u64, n3: rt.u64, n4: rt.u64, n5: rt.u64, n6: rt.u64, n7: rt.u64, n8: rt.u64, n9: rt.u64, n10: rt.u64, n11: rt.u64, n12: rt.u64, n13: rt.u64, n14: rt.u64, n15: rt.u64, n16: rt.u64, n17: rt.u64, n18: rt.u64, n19: rt.u64, n20: rt.u64, n21: rt.u64, n22: rt.u64, n23: rt.u64, n24: rt.u64, n25: rt.u64, n26: rt.u64, n27: rt.u64, n28: rt.u64, n29: rt.u64, n30: rt.u64, n31: rt.u64, n32: rt.u64, n33: rt.u64, n34: rt.u64, n35: rt.u64, n36: rt.u64, n37: rt.u64, n38: rt.u64, n39: rt.u64, n40: rt.u64, n41: rt.u64, n42: rt.u64, n43: rt.u64, n44: rt.u64, n45: rt.u64, n46: rt.u64, n47: rt.u64, n48: rt.u64, n49: rt.u64, n50: rt.u64, n51: rt.u64, n52: rt.u64, n53: rt.u64, n54: rt.u64, n55: rt.u64, n56: rt.u64, n57: rt.u64, n58: rt.u64, n59: rt.u64, n60: rt.u64, n61: rt.u64, n62: rt.u64, n63: rt.u64, n64: rt.u64, n65: rt.u64, n66: rt.u64, n67: rt.u64, n68: rt.u64, n69: rt.u64, n70: rt.u64, n71: rt.u64, n72: rt.u64, n73: rt.u64, n74: rt.u64, n75: rt.u64, n76: rt.u64, n77: rt.u64, n78: rt.u64, n79: rt.u64, n80: rt.u64, n81: rt.u64, n82: rt.u64, n83: rt.u64, n84: rt.u64, n85: rt.u64, n86: rt.u64, n87: rt.u64, n88: rt.u64, n89: rt.u64, n90: rt.u64, n91: rt.u64, n92: rt.u64, n93: rt.u64, n94: rt.u64, n95: rt.u64, n96: rt.u64, n97: rt.u64, n98: rt.u64, n99: rt.u64, n100: rt.u64, n101: rt.u64, n102: rt.u64, n103: rt.u64, n104: rt.u64, n105: rt.u64, n106: rt.u64, n107: rt.u64, n108: rt.u64, n109: rt.u64, n110: rt.u64, n111: rt.u64, n112: rt.u64, n113: rt.u64, n114: rt.u64, n115: rt.u64, n116: rt.u64, n117: rt.u64, n118: rt.u64): rt.u64; export declare function crammed(a: Moment, b: Moment, n0: rt.u64, n1: rt.u64, n2: rt.u64, n3: rt.u64, n4: rt.u64, n5: rt.u64, n6: rt.u64, n7: rt.u64, n8: rt.u64, n9: rt.u64, n10: rt.u64, n11: rt.u64, n12: rt.u64, n13: rt.u64, n14: rt.u64, n15: rt.u64, n16: rt.u64, n17: rt.u64, n18: rt.u64, n19: rt.u64, n20: rt.u64, n21: rt.u64, n22: rt.u64, n23: rt.u64, n24: rt.u64, n25: rt.u64, n26: rt.u64, n27: rt.u64, n28: rt.u64, n29: rt.u64, n30: rt.u64, n31: rt.u64, n32: rt.u64, n33: rt.u64, n34: rt.u64, n35: rt.u64, n36: rt.u64, n37: rt.u64, n38: rt.u64, n39: rt.u64, n40: rt.u64, n41: rt.u64, n42: rt.u64, n43: rt.u64, n44: rt.u64, n45: rt.u64, n46: rt.u64, n47: rt.u64, n48: rt.u64, n49: rt.u64, n50: rt.u64, n51: rt.u64, n52: rt.u64, n53: rt.u64, n54: rt.u64, n55: rt.u64, n56: rt.u64, n57: rt.u64, n58: rt.u64, n59: rt.u64, n60: rt.u64, n61: rt.u64, n62: rt.u64, n63: rt.u64, n64: rt.u64, n65: rt.u64, n66: rt.u64, n67: rt.u64, n68: rt.u64, n69: rt.u64, n70: rt.u64, n71: rt.u64, n72: rt.u64, n73: rt.u64, n74: rt.u64, n75: rt.u64, n76: rt.u64, n77: rt.u64, n78: rt.u64, n79: rt.u64, n80: rt.u64, n81: rt.u64, n82: rt.u64, n83: rt.u64, n84: rt.u64, n85: rt.u64, n86: rt.u64, n87: rt.u64, n88: rt.u64, n89: rt.u64, n90: rt.u64, n91: rt.u64, n92: rt.u64, n93: rt.u64, n94: rt.u64, n95: rt.u64, n96: rt.u64, n97: rt.u64, n98: rt.u64, n99: rt.u64, n100: rt.u64, n101: rt.u64, n102: rt.u64, n103: rt.u64, n104: rt.u64, n105: rt.u64, n106: rt.u64, n107: rt.u64, n108: rt.u64, n109: rt.u64, n110: rt.u64, n111: rt.u64, n112: rt.u64, n113: rt.u64, n114: rt.u64, n115: rt.u64, n116: rt.u64, n117: rt.u64, n118: rt.u64, n119: rt.u64, n120: rt.u64, n121: rt.u64, n122: rt.u64, n123: rt.u64): rt.u64; diff --git a/ffi/tests/api.py b/ffi/tests/api.py index 716e201cc..b80de11cd 100644 --- a/ffi/tests/api.py +++ b/ffi/tests/api.py @@ -426,6 +426,11 @@ async def recv(): check(False, "a future's borrowing error raises") except api.StringException as e: check(e.error == "malformed: ", "a future's borrowing error is its message") + # A future returning a `Cow` that borrows its text owns it before the future ends. + check(loop.run_until_complete(api.unescaped_later("a\\b")) == "ab", "a future's owned Cow crosses") + check(loop.run_until_complete(api.unescaped_later("plain")) == "plain", "a future's borrowed Cow crosses") + check(loop.run_until_complete(api.unescaped_maybe("c\\d")) == "cd", "a future's optional Cow crosses") + check(loop.run_until_complete(api.unescaped_maybe(None)) is None, "a future's absent Cow crosses") # A value that is not Send stays on the thread that made it: a use elsewhere raises, and # its future polls on its thread alone. Freed elsewhere, it drops there at its next call. From 77c6b3243910f7b1b61c398c8e894683a60f2476 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 22:57:10 -0800 Subject: [PATCH 09/10] ffi: refuse a Cow a future returns where its glue cannot own it Co-Authored-By: Claude Opus 5.5 --- ffi/README.md | 4 +++- ffi/fixtures/reject/expected.txt | 3 +++ ffi/fixtures/reject/src/lib.rs | 17 +++++++++++++++++ ffi/src/collect.rs | 28 ++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/ffi/README.md b/ffi/README.md index 501abda1f..f2d30448f 100644 --- a/ffi/README.md +++ b/ffi/README.md @@ -159,7 +159,9 @@ A field holding a reference, as `&'a mut ClientConfig` in rustls's `DangerousClientConfig` is, is read through it, lent where it is not `Clone`, and has no setter, since no borrow C holds outlives a call. A returned `Cow<'_, str>` or `Cow<'_, [u8]>` crosses as the string or bytes it owns, a copy C would make of a borrow -anyway; a `Cow` anywhere else is refused, as C would hand Rust its form. Another crate's +anyway; a `Cow` anywhere else is refused, as C would hand Rust its form. A future owns +its output before it ends, so it may return a `Cow` only on its own, in an `Option`, or +as a tuple's element, and an error's only as `Cow`, whose message crosses. Another crate's type that only refused items name, as `std::net::TcpListener` in moq-tokio's `server::Streams` is, is one no export returns, so those items are left out with it. diff --git a/ffi/fixtures/reject/expected.txt b/ffi/fixtures/reject/expected.txt index 62040f3c7..e683f8526 100644 --- a/ffi/fixtures/reject/expected.txt +++ b/ffi/fixtures/reject/expected.txt @@ -74,6 +74,9 @@ fixtures/reject/src/lib.rs:1529:1: rust2-ffi: cannot export instance `Bits` fixtures/reject/src/lib.rs:1535:1: rust2-ffi: cannot export fn `bits`: refused type `reject::Bits` fixtures/reject/src/lib.rs:1541:1: rust2-ffi: cannot export instance `Tail`: unsized type fixtures/reject/src/lib.rs:1544:1: rust2-ffi: cannot export fn `tail`: 'static borrow `&'static Tail`; refused type `reject::Tail` +fixtures/reject/src/lib.rs:1550:1: rust2-ffi: cannot export fn `cows_later`: Cow a future returns inside a collection `std::vec::Vec>` +fixtures/reject/src/lib.rs:1556:1: rust2-ffi: cannot export fn `cow_error_later`: Cow a future returns in its error `std::borrow::Cow<'_, [u8]>` +fixtures/reject/src/lib.rs:1561:1: rust2-ffi: cannot export fn `cow_param`: Cow other than a returned string or bytes `std::borrow::Cow<'_, str>` fixtures/reject/src/lib.rs:162:1: rust2-ffi: cannot export fn `measure`: foreign type `tls::held::Local` fixtures/reject/src/lib.rs:167:1: rust2-ffi: cannot export instance `Cell>`: type argument `std::vec::Vec` fixtures/reject/src/lib.rs:167:1: rust2-ffi: cannot export instance `Cell`: type argument `tls::held::Cert` diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index 84b221d7f..a8c1f3803 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -1544,3 +1544,20 @@ pub struct Tail(T, [u8]); pub fn tail(bytes: &'static Tail) -> u8 { bytes.0 } + +/// Refused: a `Cow` a future returns inside a list would borrow what the future held, as +/// only its own, its `Option`'s, or a tuple's is owned before the future ends. +pub async fn cows_later(text: &str) -> Vec> { + vec![std::borrow::Cow::Borrowed(text)] +} + +/// Refused: a future's error as bytes a `Cow` may borrow, which only a `Cow`'s +/// message escapes. +pub async fn cow_error_later(bytes: &[u8]) -> Result> { + Err(std::borrow::Cow::Borrowed(bytes)) +} + +/// Refused: a `Cow` C would hand Rust, which would need its form. +pub fn cow_param(text: std::borrow::Cow<'_, str>) -> usize { + text.len() +} diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 56f2f6355..9efb2e198 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -3694,6 +3694,21 @@ impl<'tcx> Collector<'tcx> { ty::Adt(adt, args) if tcx.is_diagnostic_item(sym::Result, adt.did()) => args.type_at(0), _ => output, }; + // A future's output is owned before the future ends, as a `Cow` may borrow what the + // future holds: the glue owns one at its top, in its `Option`, or as a tuple's + // element, and an error's `Cow` becomes its message. + if future { + if !cow_owned(tcx, ok_ty, true) { + errs.push(why("Cow a future returns inside a collection", ok_ty.to_string())); + } + if let ty::Adt(adt, args) = output.kind() + && tcx.is_diagnostic_item(sym::Result, adt.did()) + && !matches!(args.type_at(1).kind(), ty::Adt(cow_adt, cow_args) if cow(tcx, cow_adt.did()) && cow_args.type_at(1).is_str()) + && names_cow(tcx, args.type_at(1)) + { + errs.push(why("Cow a future returns in its error", args.type_at(1).to_string())); + } + } // The glue cannot name an `impl Trait`'s hidden type, so one in a return that maps // crosses only as what the glue passes on whole: an object's handle, or a value's // bytes. A future and a collected iterator are taken apart instead, so it is what @@ -6299,6 +6314,19 @@ fn names_cow<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { (ty.walk().filter_map(|arg| arg.as_type())).any(|ty| matches!(ty.kind(), ty::Adt(adt, _) if cow(tcx, adt.did()))) } +/// Whether each `Cow` in `ty` is where a future's glue owns it: `ty` itself, its +/// `Option`'s, or, at the `top`, a tuple's element of those. +fn cow_owned<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, top: bool) -> bool { + match ty.kind() { + ty::Adt(adt, _) if cow(tcx, adt.did()) => true, + ty::Adt(adt, args) if tcx.is_diagnostic_item(sym::Option, adt.did()) => { + matches!(args.type_at(0).kind(), ty::Adt(inner, _) if cow(tcx, inner.did())) || !names_cow(tcx, ty) + } + ty::Tuple(elements) if top => elements.iter().all(|e| cow_owned(tcx, e, false)), + _ => !names_cow(tcx, ty), + } +} + /// Whether `tr` is serde's `Serialize`, `Deserialize`, `DeserializeOwned`, or /// `Deserializer`, which `serde_json::Value` meets as a document of any shape. fn serde(tcx: TyCtxt<'_>, tr: DefId) -> bool { From 242d044f40b7300dd2e36e9a6d75ef6039a7e8a2 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 23:48:11 -0800 Subject: [PATCH 10/10] ffi: answer review: hidden re-exports and fields, field refusals in shapes, trait counts, value lends, Swift field keys - A #[doc(hidden)] re-export or field is left out, as the README says. - Shapes drop a refused record field's pub instead of panicking. - The census's Traits row counts refused traits. - A value receiver lends no field; its non-Clone object field is refused. - Swift's census fixed point keys a field's accessors apart from a method of its name. - A flag given twice is an error. Co-Authored-By: Claude Opus 5.5 --- driver/src/cargo.rs | 3 + ffi/fixtures/reject/expected.txt | 172 ++++++++++++++++--------------- ffi/fixtures/reject/src/lib.rs | 41 ++++++++ ffi/src/census.rs | 2 +- ffi/src/collect.rs | 41 ++++++-- ffi/src/driver.rs | 34 +++--- ffi/src/help.rs | 4 +- ffi/tests/fixtures.rs | 58 ++++++++++- ffi/tests/fixtures/shapes.rs | 15 ++- 9 files changed, 257 insertions(+), 113 deletions(-) diff --git a/driver/src/cargo.rs b/driver/src/cargo.rs index 940aa4097..e9a1d84d1 100644 --- a/driver/src/cargo.rs +++ b/driver/src/cargo.rs @@ -84,6 +84,9 @@ fn parse(args: &[String], usage: &str, configured: bool) -> Result &mut census, _ => &mut manifest, }; + if slot.is_some() { + return Err(format!("{arg} is given twice\n\n{usage}")); + } *slot = Some(absolute(Path::new(value))?); } "--" => { diff --git a/ffi/fixtures/reject/expected.txt b/ffi/fixtures/reject/expected.txt index e5514af49..9f799e67d 100644 --- a/ffi/fixtures/reject/expected.txt +++ b/ffi/fixtures/reject/expected.txt @@ -1,154 +1,156 @@ -fixtures/reject/src/lib.rs:1001:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value +fixtures/reject/src/lib.rs:1029:2: rust2-ffi: cannot export field `Moored::lone`: borrowed return that is not Clone `Lone` + help: return an owned value or a `Clone` type, since a borrowed return crosses as a clone +fixtures/reject/src/lib.rs:1042:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value help: take `&self`, or return the changed value instead of mutating it, or make the type an object by giving it a private field -fixtures/reject/src/lib.rs:1019:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn +fixtures/reject/src/lib.rs:1060:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn help: make it safe, or export a safe function that checks the preconditions and calls it -fixtures/reject/src/lib.rs:1025:1: rust2-ffi: cannot export fn `poll_risky`: Poll with no Context or waiter parameter `std::task::Poll<()>` +fixtures/reject/src/lib.rs:1066:1: rust2-ffi: cannot export fn `poll_risky`: Poll with no Context or waiter parameter `std::task::Poll<()>` help: take a `&mut Context`, or a waiter, which a poll registers its wake through -fixtures/reject/src/lib.rs:1041:1: rust2-ffi: cannot export fn `poll_loose`: Poll with no Context or waiter parameter `std::task::Poll<()>` +fixtures/reject/src/lib.rs:106:1: rust2-ffi: cannot export fn `forever_mut`: 'static borrow `&'static mut [u8]`; &mut of a slice `[u8]` + help: take an owned value, such as a `String` or an `Arc`, where the handle keeps it; only `&str` and `&[u8]` may be kept + help: take `&[u8]` and return the changed `Vec`, or hold the buffer in an object; C lends no buffer mutably +fixtures/reject/src/lib.rs:1082:1: rust2-ffi: cannot export fn `poll_loose`: Poll with no Context or waiter parameter `std::task::Poll<()>` help: take a `&mut Context`, or a waiter, which a poll registers its wake through -fixtures/reject/src/lib.rs:1048:1: rust2-ffi: cannot export fn `among`: 3 optional borrowed objects, past the 2 Swift takes, which overloads each with and without it since its optional holds an object only by consuming it +fixtures/reject/src/lib.rs:1089:1: rust2-ffi: cannot export fn `among`: 3 optional borrowed objects, past the 2 Swift takes, which overloads each with and without it since its optional holds an object only by consuming it help: take at most two optional borrowed objects, or split the function, or group them into a record -fixtures/reject/src/lib.rs:1054:1: rust2-ffi: cannot export fn `wrapped`: error holding an object Swift cannot copy, as `Swift.Error` requires +fixtures/reject/src/lib.rs:1095:1: rust2-ffi: cannot export fn `wrapped`: error holding an object Swift cannot copy, as `Swift.Error` requires help: hold values, a `String`, or a `Copy` handle in the error, since `Swift.Error` must be copyable -fixtures/reject/src/lib.rs:1059:1: rust2-ffi: cannot export fn `sum_pair`: array of an element other than u8 `[u16; 2]` +fixtures/reject/src/lib.rs:1100:1: rust2-ffi: cannot export fn `sum_pair`: array of an element other than u8 `[u16; 2]` help: take `&[T]` or `Vec`; an array of other elements only returns -fixtures/reject/src/lib.rs:1064:1: rust2-ffi: cannot export fn `empty`: empty array `[u8; 0]` +fixtures/reject/src/lib.rs:1105:1: rust2-ffi: cannot export fn `empty`: empty array `[u8; 0]` help: remove the zero-length array, which C cannot hold -fixtures/reject/src/lib.rs:106:1: rust2-ffi: cannot export fn `forever_mut`: 'static borrow `&'static mut [u8]`; &mut of a slice `[u8]` - help: take an owned value, such as a `String` or an `Arc`, where the handle keeps it; only `&str` and `&[u8]` may be kept - help: take `&[u8]` and return the changed `Vec`, or hold the buffer in an object; C lends no buffer mutably -fixtures/reject/src/lib.rs:1070:1: rust2-ffi: cannot export enum `Wide`: discriminant outside `i32` `Large = 1099511627776` - fixtures/reject/src/lib.rs:1072:2: note: has this discriminant +fixtures/reject/src/lib.rs:1111:1: rust2-ffi: cannot export enum `Wide`: discriminant outside `i32` `Large = 1099511627776` + fixtures/reject/src/lib.rs:1113:2: note: has this discriminant help: give each variant a discriminant within `i32`, as a C enum holds -fixtures/reject/src/lib.rs:1077:1: rust2-ffi: cannot export enum `Huge`: discriminant outside `i32` `Large = 18446744073709551616` - fixtures/reject/src/lib.rs:1079:2: note: has this discriminant +fixtures/reject/src/lib.rs:1118:1: rust2-ffi: cannot export enum `Huge`: discriminant outside `i32` `Large = 18446744073709551616` + fixtures/reject/src/lib.rs:1120:2: note: has this discriminant help: give each variant a discriminant within `i32`, as a C enum holds -fixtures/reject/src/lib.rs:1084:1: rust2-ffi: cannot export enum `Top`: discriminant outside `i32` `Large = 340282366920938463463374607431768211455` - fixtures/reject/src/lib.rs:1086:2: note: has this discriminant +fixtures/reject/src/lib.rs:1125:1: rust2-ffi: cannot export enum `Top`: discriminant outside `i32` `Large = 340282366920938463463374607431768211455` + fixtures/reject/src/lib.rs:1127:2: note: has this discriminant help: give each variant a discriminant within `i32`, as a C enum holds -fixtures/reject/src/lib.rs:1090:1: rust2-ffi: cannot export fn `raw`: unsafe fn +fixtures/reject/src/lib.rs:112:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>` + help: take the reference as the whole parameter, or as `Some` of an `Option`, and an owned value inside a `Box` or a struct +fixtures/reject/src/lib.rs:1131:1: rust2-ffi: cannot export fn `raw`: unsafe fn help: make it safe, or export a safe function that checks the preconditions and calls it -fixtures/reject/src/lib.rs:1095:1: rust2-ffi: cannot export fn `sum`: C-variadic function +fixtures/reject/src/lib.rs:1136:1: rust2-ffi: cannot export fn `sum`: C-variadic function help: make it safe, or export a safe function that checks the preconditions and calls it -fixtures/reject/src/lib.rs:1101:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"` +fixtures/reject/src/lib.rs:1142:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"` help: make it safe, or export a safe function that checks the preconditions and calls it -fixtures/reject/src/lib.rs:1115:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn +fixtures/reject/src/lib.rs:1156:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn help: make it safe, or export a safe function that checks the preconditions and calls it -fixtures/reject/src/lib.rs:1121:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait +fixtures/reject/src/lib.rs:1162:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait help: make the trait safe, or take an exported type instead of the trait -fixtures/reject/src/lib.rs:1126:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk` +fixtures/reject/src/lib.rs:1167:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk` help: make it safe, or export a safe function that checks the preconditions and calls it -fixtures/reject/src/lib.rs:112:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>` - help: take the reference as the whole parameter, or as `Some` of an `Option`, and an owned value inside a `Box` or a struct -fixtures/reject/src/lib.rs:1131:1: rust2-ffi: cannot export fn `trust`: trait object `dyn Trusted` - fixtures/reject/src/lib.rs:1121:1: note: C cannot implement `Trusted`: unsafe trait +fixtures/reject/src/lib.rs:1172:1: rust2-ffi: cannot export fn `trust`: trait object `dyn Trusted` + fixtures/reject/src/lib.rs:1162:1: note: C cannot implement `Trusted`: unsafe trait help: take a generic `impl Trait` or an `Arc` of one of the crate's traits C can implement, or a closure `impl Fn(..)` -fixtures/reject/src/lib.rs:1136:1: rust2-ffi: cannot export fn `hazard`: trait object `dyn Hazard` - fixtures/reject/src/lib.rs:1126:1: note: C cannot implement `Hazard`: unsafe fn `risk` +fixtures/reject/src/lib.rs:1177:1: rust2-ffi: cannot export fn `hazard`: trait object `dyn Hazard` + fixtures/reject/src/lib.rs:1167:1: note: C cannot implement `Hazard`: unsafe fn `risk` help: take a generic `impl Trait` or an `Arc` of one of the crate's traits C can implement, or a closure `impl Fn(..)` -fixtures/reject/src/lib.rs:1141:1: rust2-ffi: cannot export fn `wide_non_zero`: NonZero `u128` +fixtures/reject/src/lib.rs:1182:1: rust2-ffi: cannot export fn `wide_non_zero`: NonZero `u128` help: use `NonZero` of an integer of 64 bits or fewer -fixtures/reject/src/lib.rs:1163:1: rust2-ffi: cannot export fn `wrap`: returned object that borrows `View<'_>` +fixtures/reject/src/lib.rs:11:1: rust2-ffi: cannot export fn `map`: foreign type `std::collections::HashMap` + help: use a type that maps, such as `BTreeMap` for a `HashMap` and `Vec` for an iterator, or wrap it in a type of your own whose methods take and return mapped types +fixtures/reject/src/lib.rs:1204:1: rust2-ffi: cannot export fn `wrap`: returned object that borrows `View<'_>` help: return an owned object that borrows nothing, or a guard of a `&mut self` method borrowing the receiver alone -fixtures/reject/src/lib.rs:1168:1: rust2-ffi: cannot export fn `hidden_wrap`: returned object that borrows `impl std::clone::Clone + '_` +fixtures/reject/src/lib.rs:1209:1: rust2-ffi: cannot export fn `hidden_wrap`: returned object that borrows `impl std::clone::Clone + '_` help: return an owned object that borrows nothing, or a guard of a `&mut self` method borrowing the receiver alone -fixtures/reject/src/lib.rs:1184:1: rust2-ffi: cannot export fn `picked`: closure signature `&'static Mark` +fixtures/reject/src/lib.rs:1225:1: rust2-ffi: cannot export fn `picked`: closure signature `&'static Mark` help: take a `bool`, integer, `String`, opaque value, or object by reference (parameters only), and return an owned `bool`, integer, `String`, opaque value, or an `Option` of one, or a `Result` of one with a `String` error: a callback returns no reference -fixtures/reject/src/lib.rs:1189:1: rust2-ffi: cannot export fn `maybe_picked`: closure signature `std::option::Option<&'static Mark>` +fixtures/reject/src/lib.rs:1230:1: rust2-ffi: cannot export fn `maybe_picked`: closure signature `std::option::Option<&'static Mark>` help: take a `bool`, integer, `String`, opaque value, or object by reference (parameters only), and return an owned `bool`, integer, `String`, opaque value, or an `Option` of one, or a `Result` of one with a `String` error: a callback returns no reference -fixtures/reject/src/lib.rs:1194:1: rust2-ffi: cannot export fn `hidden_answer`: opaque type `impl std::marker::Copy` +fixtures/reject/src/lib.rs:1235:1: rust2-ffi: cannot export fn `hidden_answer`: opaque type `impl std::marker::Copy` help: return a named type, or an `impl Trait` hiding an exported object that captures no borrow, as `+ use<>` ensures -fixtures/reject/src/lib.rs:1199:1: rust2-ffi: cannot export fn `hidden_items`: opaque type `impl std::marker::Copy` +fixtures/reject/src/lib.rs:1240:1: rust2-ffi: cannot export fn `hidden_items`: opaque type `impl std::marker::Copy` help: return a named type, or an `impl Trait` hiding an exported object that captures no borrow, as `+ use<>` ensures -fixtures/reject/src/lib.rs:11:1: rust2-ffi: cannot export fn `map`: foreign type `std::collections::HashMap` - help: use a type that maps, such as `BTreeMap` for a `HashMap` and `Vec` for an iterator, or wrap it in a type of your own whose methods take and return mapped types -fixtures/reject/src/lib.rs:1204:1: rust2-ffi: cannot export fn `hidden_option`: opaque type `impl std::clone::Clone` +fixtures/reject/src/lib.rs:1245:1: rust2-ffi: cannot export fn `hidden_option`: opaque type `impl std::clone::Clone` help: return a named type, or an `impl Trait` hiding an exported object that captures no borrow, as `+ use<>` ensures -fixtures/reject/src/lib.rs:1209:1: rust2-ffi: cannot export fn `boxed_bytes`: boxed slice of bytes `std::boxed::Box<[u8]>` +fixtures/reject/src/lib.rs:1250:1: rust2-ffi: cannot export fn `boxed_bytes`: boxed slice of bytes `std::boxed::Box<[u8]>` help: use `Vec` or `bytes::Bytes` instead of `Box<[u8]>` -fixtures/reject/src/lib.rs:1214:1: rust2-ffi: cannot export fn `count_later`: iterator of borrows in a future or callback +fixtures/reject/src/lib.rs:1255:1: rust2-ffi: cannot export fn `count_later`: iterator of borrows in a future or callback help: take `Vec` or `impl IntoIterator` of owned items, which the future or callback may keep -fixtures/reject/src/lib.rs:1219:1: rust2-ffi: cannot export fn `count_opaques`: generic parameter `std::iter::Iterator` +fixtures/reject/src/lib.rs:1260:1: rust2-ffi: cannot export fn `count_opaques`: generic parameter `std::iter::Iterator` help: bound it by a trait the exporter maps, such as `Into`, `AsRef`, `Fn(..)`, or `IntoIterator`, or one of the crate's own traits, or take a concrete type -fixtures/reject/src/lib.rs:1224:1: rust2-ffi: cannot export fn `unpin_resolver`: trait object `dyn tls::held::Resolver + std::marker::Unpin` +fixtures/reject/src/lib.rs:1265:1: rust2-ffi: cannot export fn `unpin_resolver`: trait object `dyn tls::held::Resolver + std::marker::Unpin` help: take a generic `impl Trait` or an `Arc` of one of the crate's traits C can implement, or a closure `impl Fn(..)` -fixtures/reject/src/lib.rs:1229:1: rust2-ffi: cannot export fn `borrowed_resolver`: returned object that borrows `std::sync::Arc<(dyn tls::held::Resolver + 'a)>` +fixtures/reject/src/lib.rs:1270:1: rust2-ffi: cannot export fn `borrowed_resolver`: returned object that borrows `std::sync::Arc<(dyn tls::held::Resolver + 'a)>` help: return an owned object that borrows nothing, or a guard of a `&mut self` method borrowing the receiver alone -fixtures/reject/src/lib.rs:1234:1: rust2-ffi: cannot export fn `peek_resolver`: reference to a handle inside a value `std::option::Option>` +fixtures/reject/src/lib.rs:1275:1: rust2-ffi: cannot export fn `peek_resolver`: reference to a handle inside a value `std::option::Option>` help: take the object as `&T` itself, not inside an `Option` or a `Box`, which move it out of the caller's handle -fixtures/reject/src/lib.rs:1239:1: rust2-ffi: cannot export fn `peek_codec`: trait object `dyn tls::held::Codec` +fixtures/reject/src/lib.rs:1280:1: rust2-ffi: cannot export fn `peek_codec`: trait object `dyn tls::held::Codec` help: take a generic `impl Trait` or an `Arc` of one of the crate's traits C can implement, or a closure `impl Fn(..)` -fixtures/reject/src/lib.rs:1254:1: rust2-ffi: cannot export fn `pump_pipe`: generic parameter `tls::held::Stream` +fixtures/reject/src/lib.rs:128:1: rust2-ffi: cannot export fn `poll_ready`: Poll with no Context or waiter parameter `std::task::Poll` + help: take a `&mut Context`, or a waiter, which a poll registers its wake through +fixtures/reject/src/lib.rs:1295:1: rust2-ffi: cannot export fn `pump_pipe`: generic parameter `tls::held::Stream` help: bound it by a trait the exporter maps, such as `Into`, `AsRef`, `Fn(..)`, or `IntoIterator`, or one of the crate's own traits, or take a concrete type -fixtures/reject/src/lib.rs:1259:1: rust2-ffi: cannot export fn `pump_sink`: generic parameter `tls::held::Sink` +fixtures/reject/src/lib.rs:1300:1: rust2-ffi: cannot export fn `pump_sink`: generic parameter `tls::held::Sink` help: bound it by a trait the exporter maps, such as `Into`, `AsRef`, `Fn(..)`, or `IntoIterator`, or one of the crate's own traits, or take a concrete type -fixtures/reject/src/lib.rs:1264:1: rust2-ffi: cannot export fn `widen`: generic parameter `tls::held::Width` +fixtures/reject/src/lib.rs:1305:1: rust2-ffi: cannot export fn `widen`: generic parameter `tls::held::Width` help: bound it by a trait the exporter maps, such as `Into`, `AsRef`, `Fn(..)`, or `IntoIterator`, or one of the crate's own traits, or take a concrete type -fixtures/reject/src/lib.rs:1280:2: rust2-ffi: cannot export method `Counter::try_bump`: `&mut self` of a value returning a Result +fixtures/reject/src/lib.rs:1321:2: rust2-ffi: cannot export method `Counter::try_bump`: `&mut self` of a value returning a Result help: return the changed value with the result, or make the type an object by giving it a private field, since a failure would lose the change -fixtures/reject/src/lib.rs:1285:2: rust2-ffi: cannot export method `Counter::bump_later`: `&mut self` of a value in a future +fixtures/reject/src/lib.rs:1326:2: rust2-ffi: cannot export method `Counter::bump_later`: `&mut self` of a value in a future help: take `&self`, or return the changed value instead of mutating it, or make the type an object by giving it a private field -fixtures/reject/src/lib.rs:128:1: rust2-ffi: cannot export fn `poll_ready`: Poll with no Context or waiter parameter `std::task::Poll` - help: take a `&mut Context`, or a waiter, which a poll registers its wake through -fixtures/reject/src/lib.rs:1290:2: rust2-ffi: cannot export method `Counter::bump_ref`: returned borrow of a value written back `&u8` +fixtures/reject/src/lib.rs:1331:2: rust2-ffi: cannot export method `Counter::bump_ref`: returned borrow of a value written back `&u8` help: return an owned value, or make the type an object by giving it a private field, so `&mut self` writes nothing back -fixtures/reject/src/lib.rs:1297:1: rust2-ffi: cannot export fn `object_alone`: JObject with no &mut jni::Env +fixtures/reject/src/lib.rs:1338:1: rust2-ffi: cannot export fn `object_alone`: JObject with no &mut jni::Env help: take a `&mut jni::Env` beside the `JObject` -fixtures/reject/src/lib.rs:1302:1: rust2-ffi: cannot export fn `two_envs`: several JNI envs +fixtures/reject/src/lib.rs:1343:1: rust2-ffi: cannot export fn `two_envs`: several JNI envs help: take one `&mut jni::Env` -fixtures/reject/src/lib.rs:1307:1: rust2-ffi: cannot export fn `env_later`: JNI value lent to a future +fixtures/reject/src/lib.rs:1348:1: rust2-ffi: cannot export fn `env_later`: JNI value lent to a future help: take JNI's `&mut Env` and `JObject` in a plain function, which Kotlin calls, not in a callback or a future -fixtures/reject/src/lib.rs:1312:1: rust2-ffi: cannot export fn `env_counted`: &mut of a value beside a JNI value +fixtures/reject/src/lib.rs:1353:1: rust2-ffi: cannot export fn `env_counted`: &mut of a value beside a JNI value help: take the value by value and return the changed one, or drop the JNI value -fixtures/reject/src/lib.rs:1318:1: rust2-ffi: cannot export fn `shared_env`: JNI type other than a parameter's &mut Env or JObject `jni::Env<'_>` +fixtures/reject/src/lib.rs:1359:1: rust2-ffi: cannot export fn `shared_env`: JNI type other than a parameter's &mut Env or JObject `jni::Env<'_>` help: take only `&mut jni::Env` or `JObject` of jni's types, and as a parameter -fixtures/reject/src/lib.rs:1323:1: rust2-ffi: cannot export fn `java_string`: JNI type other than a parameter's &mut Env or JObject `jni::objects::JString<'_>` +fixtures/reject/src/lib.rs:1364:1: rust2-ffi: cannot export fn `java_string`: JNI type other than a parameter's &mut Env or JObject `jni::objects::JString<'_>` help: take only `&mut jni::Env` or `JObject` of jni's types, and as a parameter -fixtures/reject/src/lib.rs:1332:1: rust2-ffi: cannot export fn `visit`: trait object `dyn Visit` - fixtures/reject/src/lib.rs:1328:1: note: C cannot implement `Visit`: JNI value in a callback `&mut jni::Env<'_>` +fixtures/reject/src/lib.rs:1373:1: rust2-ffi: cannot export fn `visit`: trait object `dyn Visit` + fixtures/reject/src/lib.rs:1369:1: note: C cannot implement `Visit`: JNI value in a callback `&mut jni::Env<'_>` help: take a generic `impl Trait` or an `Arc` of one of the crate's traits C can implement, or a closure `impl Fn(..)` -fixtures/reject/src/lib.rs:1338:1: rust2-ffi: cannot export fn `keep_object`: 'static borrow `jni::objects::JObject<'static>` +fixtures/reject/src/lib.rs:1379:1: rust2-ffi: cannot export fn `keep_object`: 'static borrow `jni::objects::JObject<'static>` help: take an owned value, such as a `String` or an `Arc`, where the handle keeps it; only `&str` and `&[u8]` may be kept -fixtures/reject/src/lib.rs:1343:1: rust2-ffi: cannot export fn `bound_object`: 'static borrow `&mut jni::Env<'a>`; 'static borrow `jni::objects::JObject<'a>` - fixtures/reject/src/lib.rs:1343:21: note: `'a` is `'static`, as a handle outlives every call - fixtures/reject/src/lib.rs:1343:21: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:1384:1: rust2-ffi: cannot export fn `bound_object`: 'static borrow `&mut jni::Env<'a>`; 'static borrow `jni::objects::JObject<'a>` + fixtures/reject/src/lib.rs:1384:21: note: `'a` is `'static`, as a handle outlives every call + fixtures/reject/src/lib.rs:1384:21: note: `'a` is `'static`, as a handle outlives every call help: take an owned value, such as a `String` or an `Arc`, where the handle keeps it; only `&str` and `&[u8]` may be kept -fixtures/reject/src/lib.rs:1367:2: rust2-ffi: cannot export method `Slot::view`: returned object that borrows `SlotView<'_, u8>` +fixtures/reject/src/lib.rs:1408:2: rust2-ffi: cannot export method `Slot::view`: returned object that borrows `SlotView<'_, u8>` help: return an owned object that borrows nothing, or a guard of a `&mut self` method borrowing the receiver alone -fixtures/reject/src/lib.rs:1373:2: rust2-ffi: cannot export method `Slot::peek`: returned object that borrows `SlotView<'_, u8>` +fixtures/reject/src/lib.rs:1414:2: rust2-ffi: cannot export method `Slot::peek`: returned object that borrows `SlotView<'_, u8>` help: return an owned object that borrows nothing, or a guard of a `&mut self` method borrowing the receiver alone -fixtures/reject/src/lib.rs:1425:2: rust2-ffi: cannot export method `Slot::hold`: returned object that borrows `SlotHold<'a>` +fixtures/reject/src/lib.rs:145:2: rust2-ffi: cannot export method `Link::session`: borrowed return that is not Clone `tls::held::Handoff` + help: return an owned value or a `Clone` type, since a borrowed return crosses as a clone +fixtures/reject/src/lib.rs:1466:2: rust2-ffi: cannot export method `Slot::hold`: returned object that borrows `SlotHold<'a>` help: return an owned object that borrows nothing, or a guard of a `&mut self` method borrowing the receiver alone -fixtures/reject/src/lib.rs:1433:2: rust2-ffi: cannot export method `Slot::tag`: returned object that borrows `SlotTag<'_>` +fixtures/reject/src/lib.rs:1474:2: rust2-ffi: cannot export method `Slot::tag`: returned object that borrows `SlotTag<'_>` help: return an owned object that borrows nothing, or a guard of a `&mut self` method borrowing the receiver alone -fixtures/reject/src/lib.rs:1438:2: rust2-ffi: cannot export method `Slot::lens`: returned object that borrows `SlotLens<'_>` +fixtures/reject/src/lib.rs:1479:2: rust2-ffi: cannot export method `Slot::lens`: returned object that borrows `SlotLens<'_>` help: return an owned object that borrows nothing, or a guard of a `&mut self` method borrowing the receiver alone -fixtures/reject/src/lib.rs:1443:2: rust2-ffi: cannot export method `Slot::peer`: returned object that borrows `SlotPeer<'_>` +fixtures/reject/src/lib.rs:1484:2: rust2-ffi: cannot export method `Slot::peer`: returned object that borrows `SlotPeer<'_>` help: return an owned object that borrows nothing, or a guard of a `&mut self` method borrowing the receiver alone -fixtures/reject/src/lib.rs:145:2: rust2-ffi: cannot export method `Link::session`: borrowed return that is not Clone `tls::held::Handoff` - help: return an owned value or a `Clone` type, since a borrowed return crosses as a clone -fixtures/reject/src/lib.rs:1479:1: rust2-ffi: cannot export fn `unit_error`: unit error `std::result::Result<(), ()>` +fixtures/reject/src/lib.rs:1520:1: rust2-ffi: cannot export fn `unit_error`: unit error `std::result::Result<(), ()>` help: return a `bool` for `Result<(), ()>` or an `Option` for `Result`, or give the error a value, such as a `String` or an error type of yours -fixtures/reject/src/lib.rs:1484:1: rust2-ffi: cannot export fn `unit_error_later`: unit error `std::result::Result` +fixtures/reject/src/lib.rs:1525:1: rust2-ffi: cannot export fn `unit_error_later`: unit error `std::result::Result` help: return a `bool` for `Result<(), ()>` or an `Option` for `Result`, or give the error a value, such as a `String` or an error type of yours -fixtures/reject/src/lib.rs:1515:1: rust2-ffi: cannot export fn `race`: instance holding a foreign future `reject::Either<((), std::pin::Pin + std::marker::Send>>), ((), std::pin::Pin + std::marker::Send>>)>` +fixtures/reject/src/lib.rs:1556:1: rust2-ffi: cannot export fn `race`: instance holding a foreign future `reject::Either<((), std::pin::Pin + std::marker::Send>>), ((), std::pin::Pin + std::marker::Send>>)>` help: name a future of `()` C implements, or make the instance own no future -fixtures/reject/src/lib.rs:1523:1: rust2-ffi: cannot export fn `park`: instance holding a foreign future `reject::Parked + std::marker::Send>>>` +fixtures/reject/src/lib.rs:1564:1: rust2-ffi: cannot export fn `park`: instance holding a foreign future `reject::Parked + std::marker::Send>>>` help: name a future of `()` C implements, or make the instance own no future -fixtures/reject/src/lib.rs:1529:1: rust2-ffi: cannot export instance `Bits`: union +fixtures/reject/src/lib.rs:1570:1: rust2-ffi: cannot export instance `Bits`: union help: use a struct or an enum -fixtures/reject/src/lib.rs:1535:1: rust2-ffi: cannot export fn `bits`: refused type `reject::Bits` +fixtures/reject/src/lib.rs:1576:1: rust2-ffi: cannot export fn `bits`: refused type `reject::Bits` help: fix the refusal of the type it names first, or use a type that exports -fixtures/reject/src/lib.rs:1541:1: rust2-ffi: cannot export instance `Tail`: unsized type +fixtures/reject/src/lib.rs:1582:1: rust2-ffi: cannot export instance `Tail`: unsized type help: pass `&str` or `&[T]` instead, or return an owned `String` or `Vec`; a struct whose last field is unsized needs a sized form -fixtures/reject/src/lib.rs:1544:1: rust2-ffi: cannot export fn `tail`: 'static borrow `&'static Tail`; refused type `reject::Tail` +fixtures/reject/src/lib.rs:1585:1: rust2-ffi: cannot export fn `tail`: 'static borrow `&'static Tail`; refused type `reject::Tail` help: take an owned value, such as a `String` or an `Arc`, where the handle keeps it; only `&str` and `&[u8]` may be kept help: fix the refusal of the type it names first, or use a type that exports -fixtures/reject/src/lib.rs:1550:1: rust2-ffi: cannot export fn `cows_later`: Cow a future returns inside a collection `std::vec::Vec>` +fixtures/reject/src/lib.rs:1591:1: rust2-ffi: cannot export fn `cows_later`: Cow a future returns inside a collection `std::vec::Vec>` help: return the `Cow` itself, in an `Option`, or in a tuple, or collect owned `String`s or `Vec`s instead -fixtures/reject/src/lib.rs:1556:1: rust2-ffi: cannot export fn `cow_error_later`: Cow a future returns in its error `std::borrow::Cow<'_, [u8]>` +fixtures/reject/src/lib.rs:1597:1: rust2-ffi: cannot export fn `cow_error_later`: Cow a future returns in its error `std::borrow::Cow<'_, [u8]>` help: make the future's error `Cow`, which crosses as its message, or an owned value -fixtures/reject/src/lib.rs:1561:1: rust2-ffi: cannot export fn `cow_param`: Cow other than a returned string or bytes `std::borrow::Cow<'_, str>` +fixtures/reject/src/lib.rs:1602:1: rust2-ffi: cannot export fn `cow_param`: Cow other than a returned string or bytes `std::borrow::Cow<'_, str>` help: take `&str`, `&[u8]`, or an owned value instead, and return `Cow` only as a whole `Cow` or `Cow<[u8]>` fixtures/reject/src/lib.rs:162:1: rust2-ffi: cannot export fn `measure`: foreign type `tls::held::Local` help: use a type that maps, such as `BTreeMap` for a `HashMap` and `Vec` for an iterator, or wrap it in a type of your own whose methods take and return mapped types diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index a8c1f3803..3617827d5 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -992,6 +992,47 @@ pub use dep; /// The same crate whole, by another name. pub use ::dep as renamed; +/// The same crate whole, and the standard library's item, each re-exported hidden, which +/// leaves out the path rather than refuse it. +#[doc(hidden)] +pub use ::dep as hidden_dep; +#[doc(hidden)] +pub use std::collections::BTreeSet as HiddenSet; + +/// A hidden field is no part of the API, so its pointer is not refused, and the struct, which +/// C cannot build without it, is an object. +pub struct Peeked { + pub len: u32, + #[doc(hidden)] + pub raw: *const u8, +} + +pub fn peeked() -> Peeked { + Peeked { + len: 0, + raw: std::ptr::null(), + } +} + +/// An object that is not `Clone`, which a value's reference field holds. +pub struct Lone(u32); + +pub fn lone() -> Lone { + Lone(1) +} + +static LONE: Lone = Lone(7); + +/// A value C copies, so it has no handle to lend its field from, and the field is refused. +#[derive(Clone, Copy)] +pub struct Moored { + pub lone: &'static Lone, +} + +pub fn moored() -> Moored { + Moored { lone: &LONE } +} + /// A value whose poll changes it, which C passes as a copy. pub struct Tally { pub count: u8, diff --git a/ffi/src/census.rs b/ffi/src/census.rs index 9e63b5415..6368ca663 100644 --- a/ffi/src/census.rs +++ b/ffi/src/census.rs @@ -52,7 +52,7 @@ pub(crate) fn render(api: &Api, collected: &Report, clashes: &[Clash], at: &dyn methods, refused(&["method", "field"]), ); - row("Traits", callbacks, 0); + row("Traits", callbacks, refused(&["trait"])); row("Constants", constants, refused(&["const"])); row("Other items", 0, refused(&["use", "macro", "static", "item"])); let _ = writeln!( diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 25cf564a3..9e1fec7cc 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -1109,8 +1109,8 @@ impl<'tcx> Collector<'tcx> { ); for site in sites { let adt = tcx.adt_def(site.key.def_id); - // An object's private fields are no part of its API. - for field in adt.all_fields().filter(|field| field.vis.is_public()) { + // An object's private and hidden fields are no part of its API. + for field in adt.all_fields().filter(|field| in_api(tcx, field)) { named.push(field.ty(tcx, site.args).skip_norm_wip()); } for (item, parent, _, hidden) in self.members(&site) { @@ -1366,6 +1366,15 @@ impl<'tcx> Collector<'tcx> { } let mut path = path.clone(); path.push(child.ident.to_string()); + // A `#[doc(hidden)]` re-export leaves out this path alone, not the item, which + // another path may still export. + if (child.reexport_chain.first().and_then(|reexport| reexport.id())) + .is_some_and(|id| tcx.is_doc_hidden(id)) + { + let (report, rest) = self.report(&path); + report.hidden.push(rest); + continue; + } // A crate re-exported whole makes its every release part of the facade's // semver, so each such `pub use` is refused once, and the crate not walked. // A glob of its root re-exports its items instead, which export. The span is @@ -2121,7 +2130,7 @@ impl<'tcx> Collector<'tcx> { DefKind::Struct => { let variant = tcx.adt_def(def_id).non_enum_variant(); let record = !variant.fields.is_empty() - && variant.fields.iter().all(|f| f.vis.is_public()) + && variant.fields.iter().all(|f| in_api(tcx, f)) && !variant.is_field_list_non_exhaustive(); match record { true => Decl::Record(0), @@ -2479,7 +2488,7 @@ impl<'tcx> Collector<'tcx> { Some(Decl::Value(index)) => { let (mut methods, traits) = self.methods(&site); if kind == DefKind::Struct { - methods.splice(0..0, self.accessors(&site)); + methods.splice(0..0, self.accessors(&site, false)); } let methods = self.written_back(methods); let record = &mut self.api.records[index]; @@ -2490,7 +2499,7 @@ impl<'tcx> Collector<'tcx> { Some(Decl::Object(index)) => { let (mut methods, traits) = self.methods(&site); if kind == DefKind::Struct { - methods.splice(0..0, self.accessors(&site)); + methods.splice(0..0, self.accessors(&site, true)); } let self_ty = self.site_ty(&site); let chain = self.derefs(self_ty); @@ -2626,7 +2635,7 @@ impl<'tcx> Collector<'tcx> { // accessors of their own. Some(Decl::Record(u)) => { let mut members = match records.get(&u) { - Some(site) => self.accessors(site), + Some(site) => self.accessors(site, true), None => Vec::new(), }; members.extend(self.api.records[u].methods.iter().cloned()); @@ -2774,8 +2783,8 @@ impl<'tcx> Collector<'tcx> { /// A getter and a setter for each `pub` field of a struct exported as an object or an /// opaque value: the getter returns a copy, and the setter assigns in place, as - /// `x.field = value` does. - fn accessors(&mut self, site: &Site<'tcx>) -> Vec { + /// `x.field = value` does. A receiver with a `handle` also lends a field it cannot copy. + fn accessors(&mut self, site: &Site<'tcx>, handle: bool) -> Vec { let tcx = self.tcx; let mut accessors = Vec::new(); for field in &tcx.adt_def(site.key.def_id).non_enum_variant().fields { @@ -2784,6 +2793,11 @@ impl<'tcx> Collector<'tcx> { } let name = field.name.to_string(); let shown = [&site.shown[..], std::slice::from_ref(&name)].concat(); + if tcx.is_doc_hidden(field.did) { + let (report, rest) = self.report(&shown); + report.hidden.push(rest); + continue; + } let span = tcx.def_span(field.did); let ty = field.ty(tcx, site.args).skip_norm_wip(); // An instance's field of `()`, such as a default extension, holds nothing to read. @@ -2801,13 +2815,15 @@ impl<'tcx> Collector<'tcx> { // written with a value C gives up, as an owned parameter is. let read = Ty::new_imm_ref(tcx, tcx.lifetimes.re_erased, held); // A field that is an object but not `Clone` is lent from the receiver's handle, - // as a method's borrowed return of one is. + // as a method's borrowed return of one is, where the receiver has one: a value C + // copies has none. // So is an `Option` of one, as `Some` of the borrow, through a `Box` too. let object = match held.kind() { ty::Adt(adt, args) if tcx.is_diagnostic_item(sym::Option, adt.did()) => unboxed(args.type_at(0)), _ => held, }; - let lends = !self.is_clone(held) + let lends = handle + && !self.is_clone(held) && matches!(object.kind(), ty::Adt(adt, args) if matches!(self.decl(adt.did(), *args), Some(Decl::Object(_)))); let mapped = { self.lending.set(lends); @@ -6560,6 +6576,11 @@ fn borrows(ty: &Type) -> bool { } } +/// Whether `field` is part of its type's API: `pub`, and not `#[doc(hidden)]`. +fn in_api(tcx: TyCtxt<'_>, field: &ty::FieldDef) -> bool { + field.vis.is_public() && !tcx.is_doc_hidden(field.did) +} + /// Whether `ty` holds a reference inside it, such as `Option<&T>`. fn lends_inside(ty: &Type) -> bool { match ty { diff --git a/ffi/src/driver.rs b/ffi/src/driver.rs index 7a3ee5d7a..245bedc69 100644 --- a/ffi/src/driver.rs +++ b/ffi/src/driver.rs @@ -233,8 +233,8 @@ fn swift_refused(api: &Api, lib: &str) -> (Api, Vec) { let abi = Abi::new(&api, lib); let rest = api.without_jni(); // A function refused for each of several reasons is one refusal of them all, its - // reasons in a row. - let mut found: Vec = Vec::new(); + // reasons in a row. A field's accessors are apart from a method of its name. + let mut found: Vec<(bool, collect::Refusal)> = Vec::new(); for r in crate::swift::refusals(&abi.without_jni(&rest)) { let why = collect::Why { construct: r.construct, @@ -242,27 +242,35 @@ fn swift_refused(api: &Api, lib: &str) -> (Api, Vec) { note: None, }; let path = r.function.shown[1..].join("::"); + let field = matches!(r.function.access, ir::Access::Field { .. }); match found.last_mut() { - Some(last) if last.path == path => last.why.push(why), - _ => found.push(collect::Refusal { - path, - kind: r.kind, - span: r.function.span, - why: vec![why], - }), + Some((was, last)) if *was == field && last.path == path => last.why.push(why), + _ => found.push(( + field, + collect::Refusal { + path, + kind: r.kind, + span: r.function.span, + why: vec![why], + }, + )), } } if found.is_empty() { return (api, refused); } - let gone: FxHashSet<&str> = found.iter().map(|r| r.path.as_str()).collect(); - let keep = - |methods: &mut Vec| methods.retain(|f| !gone.contains(f.shown[1..].join("::").as_str())); + let gone: FxHashSet<(bool, &str)> = found.iter().map(|(field, r)| (*field, r.path.as_str())).collect(); + let keep = |methods: &mut Vec| { + methods.retain(|f| { + let field = matches!(f.access, ir::Access::Field { .. }); + !gone.contains(&(field, f.shown[1..].join("::").as_str())) + }) + }; api.records.iter_mut().for_each(|r| keep(&mut r.methods)); api.enums.iter_mut().for_each(|e| keep(&mut e.methods)); api.objects.iter_mut().for_each(|o| keep(&mut o.methods)); keep(&mut api.functions); - refused.extend(found); + refused.extend(found.into_iter().map(|(_, r)| r)); } } diff --git a/ffi/src/help.rs b/ffi/src/help.rs index b91c91664..5080b90cd 100644 --- a/ffi/src/help.rs +++ b/ffi/src/help.rs @@ -53,7 +53,9 @@ pub(crate) fn of(construct: &str) -> Option<&'static str> { "Cow a future returns inside a collection" => { "return the `Cow` itself, in an `Option`, or in a tuple, or collect owned `String`s or `Vec`s instead" } - "Cow a future returns in its error" => "make the future's error `Cow`, which crosses as its message, or an owned value", + "Cow a future returns in its error" => { + "make the future's error `Cow`, which crosses as its message, or an owned value" + } "128-bit integer" => "use `u128`, which exports, or an integer of 64 bits or fewer", "NonZero" => "use `NonZero` of an integer of 64 bits or fewer", "Range" | "Bound" => "use `Range` or `Bound` of an integer of 64 bits or fewer", diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index 90de16bd1..3f90120d7 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -4142,8 +4142,6 @@ fn no_std_links() { ); let out = package.join("out"); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) - .arg("--manifest-path") - .arg(package.join("Cargo.toml")) .arg("--manifest-path") .arg(package.join("Cargo.toml")) .arg("--out") @@ -4198,6 +4196,62 @@ fn census(manifest: &Path, cargo: &[&str]) -> Command { cmd } +/// A flag given twice is an error, not the last one silently winning. +#[test] +fn flag_twice() { + let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) + .args(["--census", "census", "--manifest-path", "a/Cargo.toml"]) + .args(["--manifest-path", "b/Cargo.toml"]) + .output() + .unwrap(); + assert!(!output.status.success()); + let stderr = String::from_utf8_lossy(&output.stderr); + assert!(stderr.contains("--manifest-path is given twice"), "{stderr}"); +} + +/// A refused trait counts in the census's table, so a census whose rows sum to no refusal +/// refuses nothing. +#[test] +fn census_counts_traits() { + let package = package( + "census_counts_traits", + &[("src/lib.rs", "pub unsafe trait Trusted {\n\tfn id(&self) -> u32;\n}\n")], + ); + let output = census(&package.join("Cargo.toml"), &[]).output().unwrap(); + assert!( + output.status.success(), + "the census failed:\n{}", + String::from_utf8_lossy(&output.stderr) + ); + let report = std::fs::read_to_string(package.join("census/census_counts_traits.md")).unwrap(); + assert!(report.contains("| Traits | 0 | 1 | 0% |"), "{report}"); +} + +/// A method Swift refuses leaves out only itself, not the accessors of a field of its name. +#[test] +fn census_swift_field() { + let lib = "pub struct Token(u8);\n\n\ + pub struct Gate {\n\tpub open: u8,\n\tshut: u8,\n}\n\n\ + pub fn gate() -> Gate {\n\tGate { open: 0, shut: 0 }\n}\n\n\ + impl Gate {\n\tpub fn open(&self, among: Option<&Token>, and: Option<&Token>, also: Option<&Token>) -> u8 {\n\t\t\ + [among, and, also].into_iter().flatten().map(|t| t.0).sum::() + self.shut\n\t}\n}\n\n\ + pub fn token() -> Token {\n\tToken(1)\n}\n"; + let package = package("census_swift_field", &[("src/lib.rs", lib)]); + let output = census(&package.join("Cargo.toml"), &[]).output().unwrap(); + assert!( + output.status.success(), + "the census failed:\n{}", + String::from_utf8_lossy(&output.stderr) + ); + let report = std::fs::read_to_string(package.join("census/census_swift_field.md")).unwrap(); + // The field, by its getter, exports; the method alone is refused. + assert!( + report.contains("| Methods and fields of exported types | 1 | 1 |"), + "{report}" + ); + assert!(report.contains("- method `Gate::open`"), "{report}"); +} + /// Finding the exports keeps to the check's `--locked`: it neither writes a lockfile the /// check then accepts, nor passes. #[test] diff --git a/ffi/tests/fixtures/shapes.rs b/ffi/tests/fixtures/shapes.rs index 28aef18b7..f0a93ba6d 100644 --- a/ffi/tests/fixtures/shapes.rs +++ b/ffi/tests/fixtures/shapes.rs @@ -293,6 +293,9 @@ fn gate() -> Vec { ]); } shapes.push(Shape::Map(Box::new(Shape::String), Box::new(Shape::Bytes))); + // An object record holding a record that is not Clone, a field the census refuses. + let object = || Shape::Object(Box::new(Shape::U128)); + shapes.push(Shape::Record(vec![object(), Shape::Record(vec![Shape::Int("u8")])])); shapes.push(Shape::Set(Box::new(Shape::Int("u64")))); shapes } @@ -1142,8 +1145,18 @@ struct Refused { } /// `lib` with the item at `path` configured out: a function or type, or a method by its -/// type's path. +/// type's path. A record's field loses its `pub` instead, which leaves its accessors out +/// while the crate's own literals still name it. fn cfg_out(lib: &str, path: &str) -> String { + if let Some((ty, field)) = path.split_once("::") + && let Some(start) = lib.find(&format!("pub struct {ty} {{")) + { + let end = start + lib[start..].find("\n}").expect("a record's body ends"); + let at = (lib[start..end].find(&format!("\tpub {field}: "))) + .unwrap_or_else(|| panic!("the census refuses `{path}`, which is no field of the crate's")); + let at = start + at + 1; + return format!("{}{}", &lib[..at], &lib[at + "pub ".len()..]); + } let (from, name) = match path.split_once("::") { Some((ty, method)) => { let from = lib