diff --git a/.github/workflows/bindings.yml b/.github/workflows/bindings.yml index b97772eef..706bf9e32 100644 --- a/.github/workflows/bindings.yml +++ b/.github/workflows/bindings.yml @@ -145,7 +145,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" @@ -210,7 +210,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: @@ -283,7 +283,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: @@ -448,7 +448,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-* @@ -632,7 +632,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: @@ -730,7 +730,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/bench/ffi/README.md b/bench/ffi/README.md index bb84d24e1..afe337262 100644 --- a/bench/ffi/README.md +++ b/bench/ffi/README.md @@ -706,7 +706,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/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/FACADE.md b/ffi/FACADE.md index b1adbfa05..8f8947a11 100644 --- a/ffi/FACADE.md +++ b/ffi/FACADE.md @@ -26,8 +26,7 @@ This guide goes from a crate you want in another language to a facade with no re 2. Count it with a census, which exports nothing: ```bash - echo 'exclude = []' > ffi.toml - rust2-ffi --config ffi.toml --census census --manifest-path Cargo.toml + rust2-ffi --census census --manifest-path Cargo.toml ``` 3. Read `census/.md`, as below, and fix the top construct. @@ -135,8 +134,6 @@ and every other method is a call a language can make. refused for `[u8]` points at one signature shape. - **Refused items**: each item, its span, and every reason, which is what the compile error prints. -- **The config that exports what maps**: the `exclude` that leaves the refused items out, - which the export accepts today. - **What exports another way, or is left out and listed**: a value exported as an object since a field does not map, a `#[doc(hidden)]` item, what C can never hold, such as an object no export returns, and a type alias. None of these is an error; they need no change diff --git a/ffi/README.md b/ffi/README.md index 616720470..3cfaaee62 100644 --- a/ffi/README.md +++ b/ffi/README.md @@ -11,7 +11,7 @@ be refused, and the census also lists API items left out by those rules. what each refusal asks you to change. ```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` @@ -58,18 +58,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 @@ -107,7 +98,7 @@ public path names, or an error taken by value, is held by value as an opaque han | a type parameter or `impl` taken by value and bounded by `Future` or `IntoFuture`, whose every bound `Pin + Send>>` meets, as kio's `clock::timeout` takes, or taken as `Pin<&mut F>` by a poll, as kio's `Waiter::poll_future` takes | `_foreign_future`: a future of `()` C implements, which Rust takes as that type, or which the future the poll makes owns and pins; a future of another output is refused | | a type parameter or `impl` bounded by `Read` and `Seek` alone, behind `&mut`, which no lifetime bound or return lets outlive the call, as moq-mux's `container::mp4::repair` takes | `_foreign_reader`: a `read` and a `seek` C implements and their data, lent for the call; any other reader is refused | | `fn` and inherent `pub` methods | functions named through their type | -| an object's `Deref` to an exported type, followed as far as the chain reaches | the target's `pub` methods and fields, a record's too, on the object, as auto-deref finds them: a method the object or a nearer target has, exported or not, hides a method, and a field a field; a `&mut self` method or a setter only while every `Deref` on the way is a `DerefMut`; and the config names each by the object's path | +| an object's `Deref` to an exported type, followed as far as the chain reaches | the target's `pub` methods and fields, a record's too, on the object, as auto-deref finds them: a method the object or a nearer target has, exported or not, hides a method, and a field a field; a `&mut self` method or a setter only while every `Deref` on the way is a `DerefMut`; and the census names each by the object's path | | a `()` parameter of a function, not of a callback's method | nothing: C passes no argument for it | | `Result` | `bool f(..., T *out, E *err)`; an `E` of another crate that implements `Display`, such as `anyhow::Error` or `io::Error`, is `String`, its message; a `()` error, as once_cell's `race::OnceBool::set` returns, is refused, having no value to raise | | a returned tuple `(A, B)` | one out pointer each: `void f(..., A *out0, B *out1)` | @@ -151,7 +142,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 | @@ -166,11 +157,21 @@ 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. 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. + 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 @@ -231,7 +232,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. @@ -260,7 +261,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 @@ -473,10 +474,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++ @@ -1384,13 +1382,9 @@ runtime package and each crate's include [`runtime/rt.go`](runtime/rt.go) and `--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, a binding's own refusals such as Swift's included, -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 +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) @@ -1621,7 +1615,7 @@ entry, and the nightly fails on an entry that matches no call of the fixed set. 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 bceb9fd20..af8022230 100644 --- a/ffi/fixtures/api/examples/transcript.rs +++ b/ffi/fixtures/api/examples/transcript.rs @@ -442,6 +442,10 @@ fn main() { let mut list = Node::new(1, None); list.push(2); println!("node {}", list.sum()); + match list.next.as_deref() { + Some(next) => println!("node next {}", next.value), + None => println!("node next none"), + } let tally = Tally::new(); tally.bump(); @@ -716,6 +720,10 @@ fn main() { drop(draft); println!("dropped {}", ledger.published()); println!("receipt {}", ledger.receipt().count()); + let tab = ledger.tab(); + println!("tab {}", tab.ledger.published()); + println!("tab label {}", tab.label); + drop(tab); // 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); @@ -836,7 +844,21 @@ fn main() { ); let doc: serde_json::Value = r#"{"b": [1, 2.5, null], "a": "\u00e9"}"#.parse().unwrap(); 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 pair: serde_json::Value = "[1, 2]".parse().unwrap(); + let spot = api::Spot::deserialize(pair).unwrap(); + println!("spot {} {}", spot.x, spot.y); + let text: serde_json::Value = "\"x\"".parse().unwrap(); + match api::Spot::deserialize(text) { + Ok(spot) => println!("spot {} {}", spot.x, spot.y), + Err(err) => println!("spot err {err}"), + } println!("tagged {}", api::tagged(doc, "t")); println!( "entries {}", diff --git a/ffi/fixtures/api/ffi.toml b/ffi/fixtures/api/ffi.toml deleted file mode 100644 index 8550166ab..000000000 --- a/ffi/fixtures/api/ffi.toml +++ /dev/null @@ -1,40 +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, as `Retry::spread` and `field@Retry::spread` do a method Swift alone -# refuses 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", - "Retry::spread", - "field@Pad::title", - "field@Retry::delay", - "field@Retry::jitter", - "field@Retry::spread", - "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 d8cca7ee3..083e2c25c 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -816,6 +816,15 @@ 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, + label: "ledger", + } + } + pub fn slip(&mut self) -> Slip<'_> { Slip { receipt: Receipt(&self.published), @@ -825,6 +834,14 @@ impl Ledger { } } +/// 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 { /// Implemented for a borrow of a ledger of any lifetime. pub trait Noted<'a> {} @@ -2869,22 +2886,11 @@ 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, - /// Its field exports, but Swift refuses the method of its name, so the config excludes - /// both, and the census lists only `field@Retry::spread` as excluding what exports. - pub spread: u64, } impl Retry { pub fn new(limit: Option) -> Self { - Self { - limit, - delay: None, - jitter: 0, - spread: 0, - } + Self { limit, delay: None } } pub fn limit(&self) -> u32 { @@ -2898,16 +2904,6 @@ impl Retry { pub fn set_limit(&mut self, limit: u32) { self.limit = Some(limit); } - - /// The spread plus three optional borrowed counters, past what Swift takes. - pub fn spread(&self, first: Option<&Counter>, second: Option<&Counter>, third: Option<&Counter>) -> u64 { - self.spread + among(first, second, third) - } - - /// 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 @@ -3066,7 +3062,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, @@ -3086,18 +3084,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); @@ -4974,11 +4960,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)] @@ -5131,6 +5112,47 @@ 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), + } +} + +/// [`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) { + 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 }) + } +} /// A type named as Kotlin's and Dart's deprecation annotation, which the bindings' own /// annotations must not resolve to. #[derive(Clone, Copy, Debug, Default, PartialEq)] 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 6ca115597..9f799e67d 100644 --- a/ffi/fixtures/reject/expected.txt +++ b/ffi/fixtures/reject/expected.txt @@ -1,365 +1,369 @@ -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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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 - 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: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: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: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: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:1088:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out +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: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: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: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: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: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: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:1119:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out +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: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: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: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: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: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 - 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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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`; exclude it in the config to leave it out - 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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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 - 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 `object_alone`: JObject with no &mut jni::Env; exclude it in the config to leave it out +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: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:1343:1: rust2-ffi: cannot export fn `two_envs`: several JNI envs help: take one `&mut jni::Env` -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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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`; exclude it in the config to leave it out - help: return an owned value or a `Clone` type, since a borrowed return crosses as a clone -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: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: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: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: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: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: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: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:1527:1: rust2-ffi: cannot export instance `Bits`: union; exclude it in the config to leave it out +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: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: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:1539:1: rust2-ffi: cannot export instance `Tail`: unsized type; exclude it in the config to leave it out +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: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: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: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: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: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: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 -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 `std::vec::Vec` help: instantiate it at types that map, such as integers, `String`, or an exported type; `&str`, `Cow`, and other borrows do not -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:167:1: rust2-ffi: cannot export instance `Cell`: type argument `tls::held::Cert` help: instantiate it at types that map, such as integers, `String`, or an exported type; `&str`, `Cow`, and other borrows do not -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:16:1: rust2-ffi: cannot export fn `generic`: generic parameter `std::marker::Copy` 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: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:170:1: rust2-ffi: cannot export fn `sealed`: refused type `reject::Cell` help: fix the refusal of the type it names first, or use a type that exports -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:199:1: rust2-ffi: cannot export fn `echo`: borrowing output of a future from a function that is not async `&str` help: make it an `async fn`, or return an output that borrows nothing -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:204:1: rust2-ffi: cannot export fn `blame`: borrowing output of a future from a function that is not async `std::result::Result>` help: make it an `async fn`, or return an output that borrows nothing -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:209:1: rust2-ffi: cannot export fn `relay`: borrowing output of a future from a function that is not async `&str` help: make it an `async fn`, or return an output that borrows nothing -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:214:1: rust2-ffi: cannot export fn `resolve`: borrowing output of a future from a function that is not async `&str` help: make it an `async fn`, or return an output that borrows nothing -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:219:1: rust2-ffi: cannot export fn `spend`: closure signature `tls::held::Token` 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: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:21:1: rust2-ffi: cannot export fn `nested`: nested Option `std::option::Option>>` help: use one `Option`, or wrap the inner one in an enum, since C has one `None` per option -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:224:1: rust2-ffi: cannot export fn `mint`: closure signature `tls::held::Token` 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: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:234:1: rust2-ffi: cannot export fn `spent`: reference to a handle inside a value `[tls::held::Token]` 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: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:244:1: rust2-ffi: cannot export fn `adopt`: generic parameter `std::convert::Into` 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: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:256:2: rust2-ffi: cannot export method `Cell::nest`: instance holding an instance of a type inside it `reject::Cell>` help: do not nest the generic type in itself at a deeper instance, as `Cell>` does -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:275:2: rust2-ffi: cannot export method `Pong>::ping`: instance holding an instance of a type inside it `reject::Ping>>` help: do not nest the generic type in itself at a deeper instance, as `Cell>` does -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:286:1: rust2-ffi: cannot export instance `Grow<(u32,)>`: type argument `(u32,)` help: instantiate it at types that map, such as integers, `String`, or an exported type; `&str`, `Cow`, and other borrows do not -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:289:2: rust2-ffi: cannot export method `Grow::grow`: refused type `reject::Grow<(u32,)>` help: fix the refusal of the type it names first, or use a type that exports -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:300:1: rust2-ffi: cannot export instance `Shell<(u32,)>`: type argument `(u32,)` help: instantiate it at types that map, such as integers, `String`, or an exported type; `&str`, `Cow`, and other borrows do not -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:309:1: rust2-ffi: cannot export fn `shell`: refused type `reject::Shell<(u32,)>` help: fix the refusal of the type it names first, or use a type that exports -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:30:1: rust2-ffi: cannot export fn `peek`: reference to a handle inside a value `std::boxed::Box` 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: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:320:1: rust2-ffi: cannot export fn `probe`: const generic `N` help: pass the const parameter to a generic type in the signature, so each instance an export names supplies its values -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 - help: the config leaves this type out, so leave out each item that names it too -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:325:1: rust2-ffi: cannot export fn `listed`: refused type `reject::Cell>` help: fix the refusal of the type it names first, or use a type that exports -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:330:1: rust2-ffi: cannot export instance `Fixed<'a'>`: const argument `'a'` help: use a `bool` or an integer below 128 bits for a const argument -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:333:1: rust2-ffi: cannot export fn `fixed`: refused type `reject::Fixed<'a'>` help: fix the refusal of the type it names first, or use a type that exports -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:338:9: rust2-ffi: cannot export use `HashSet`: re-export of the standard library's item `std` help: name the standard library's type in signatures, where it maps by role, instead of re-exporting it -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:341:1: rust2-ffi: cannot export fn `lend`: Waker outside a parameter or a return help: take or return a `Waker` only as a parameter or a return, not in a field or a collection -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 - 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:35:1: rust2-ffi: cannot export static `COUNT`: static; exclude it in the config to leave it out - help: export a function returning the value, or a `const` -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:359:1: rust2-ffi: cannot export fn `gather`: closure signature `std::vec::Vec` 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: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:35:1: rust2-ffi: cannot export static `COUNT`: static + help: export a function returning the value, or a `const` +fixtures/reject/src/lib.rs:364:1: rust2-ffi: cannot export fn `attempt`: closure signature `std::result::Result` 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: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:369:1: rust2-ffi: cannot export fn `consume`: reader not lent as &mut `impl std::io::Read + std::io::Seek` help: take the reader as `&mut R` -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:374:1: rust2-ffi: cannot export fn `retain`: reader kept past the call `R` help: do not return or keep the reader, which C lends only for the call -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:379:1: rust2-ffi: cannot export fn `rewrite`: reader bound `std::io::Write` help: bound the reader by `Read` and `Seek` alone -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:384:1: rust2-ffi: cannot export fn `read_later`: reader kept past the call `impl std::io::Read + std::io::Seek` help: do not return or keep the reader, which C lends only for the call -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:389:1: rust2-ffi: cannot export fn `twice`: closure bound `std::clone::Clone` help: bound the closure by `Fn`, `FnMut`, or `FnOnce` alone, besides `Send`, `Sync`, and a lifetime -fixtures/reject/src/lib.rs:39:1: rust2-ffi: cannot export macro `noop`: macro; exclude it in the config to leave it out - help: export a function that does what the macro does, or mark the macro `#[doc(hidden)]` -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:395:1: rust2-ffi: cannot export fn `both`: closure type taken twice `F` help: take the closure's type once, with a type parameter for each closure -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:39:1: rust2-ffi: cannot export macro `noop`: macro + help: export a function that does what the macro does, or mark the macro `#[doc(hidden)]` +fixtures/reject/src/lib.rs:401:1: rust2-ffi: cannot export fn `read`: lent object that borrows `&Text<'_>` help: name no lifetime on the lent type, or fix it to `'static`, since a handle holds it at `'static` -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:406:1: rust2-ffi: cannot export fn `count_words`: Vec of references `&str` help: take owned items, or only return the references: C lends nothing inside a collection, tuple, or iterator -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:411:1: rust2-ffi: cannot export fn `count_some`: Vec of references `std::option::Option<&str>` help: take owned items, or only return the references: C lends nothing inside a collection, tuple, or iterator -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:416:1: rust2-ffi: cannot export fn `count_slice`: slice of references `&str` help: take owned items, or only return the references: C lends nothing inside a collection, tuple, or iterator -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:421:1: rust2-ffi: cannot export fn `peek_all`: reference to a handle inside a value `[Opaque]` 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: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:426:1: rust2-ffi: cannot export fn `none_opaque`: borrowed return that is not Clone `[Opaque]` help: return an owned value or a `Clone` type, since a borrowed return crosses as a clone -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:438:1: rust2-ffi: cannot export fn `stash`: generic parameter `std::convert::Into` 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: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:454:1: rust2-ffi: cannot export fn `hold`: generic parameter `std::convert::Into` 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: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:459:1: rust2-ffi: cannot export fn `bound`: generic parameter `std::convert::Into` 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: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:464:1: rust2-ffi: cannot export fn `kept`: generic parameter `std::convert::Into` 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:47:1: rust2-ffi: cannot export fn `excluded`: excluded type `Excluded`; exclude it in the config to leave it out - help: the config leaves this type out, so leave out each item that names it too -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:479:1: rust2-ffi: cannot export fn `holder`: generic parameter `std::convert::Into` 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: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:47:1: rust2-ffi: cannot export fn `excluded`: doc(hidden) type `Excluded` + help: remove `#[doc(hidden)]` from the type, or mark this item `#[doc(hidden)]` too +fixtures/reject/src/lib.rs:494:1: rust2-ffi: cannot export fn `lender`: generic parameter `std::convert::Into` 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: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:510:1: rust2-ffi: cannot export fn `outlived`: generic parameter `std::convert::Into` 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: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:526:1: rust2-ffi: cannot export fn `paired`: generic parameter `std::convert::Into` 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:52:1: rust2-ffi: cannot export fn `letters`: Range `char`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:52:1: rust2-ffi: cannot export fn `letters`: Range `char` help: use `Range` or `Bound` of an integer of 64 bits or fewer -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:551:1: rust2-ffi: cannot export fn `pinner`: generic parameter `std::convert::Into` 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: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:567:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows` + fixtures/reject/src/lib.rs:559:1: note: applies past the recursion limit help: break the chain of `From` impls, which names ever more types -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 `call`: ambiguous conversion `std::vec::Vec` + fixtures/reject/src/lib.rs:575:1: note: `std::string::String` converts too, which C passes alike help: convert from one of the sources, as `&str` and `String` are one value, not both a `String` and a `Vec`, 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 `alphabet`: Range `char` help: use `Range` or `Bound` of an integer of 64 bits or fewer -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 `naturals`: foreign type `std::ops::RangeFrom` 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: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 `opaques`: borrowed return that is not Clone `Opaque` help: return an owned value or a `Clone` type, since a borrowed return crosses as a clone -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 `tried`: foreign type `std::vec::IntoIter` 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: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:624:1: rust2-ffi: cannot export fn `eventually`: foreign type `std::vec::IntoIter` 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: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 `tallied`: unmet bound `u32: std::convert::From` help: implement the bound for the type, or loosen it; an instance exports only where every bound holds -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 `drain`: trait object `dyn Source` + fixtures/reject/src/lib.rs:629:1: note: C cannot implement `Source`: callback signature `items` 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:655:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out - 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: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:660:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]` 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: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: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 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: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:66:2: rust2-ffi: cannot export method `Text::view`: returned object that borrows `Text<'_>` 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: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: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 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:683:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out - 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: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: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 + 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:688:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat` 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: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:694:1: rust2-ffi: cannot export fn `long_words`: foreign type `std::iter::Filter` 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: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:6:1: rust2-ffi: cannot export fn `pair`: tuple of references `(&str, u8)` help: take owned items, or only return the references: C lends nothing inside a collection, tuple, or iterator -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:700:1: rust2-ffi: cannot export fn `kept_in`: foreign type `std::iter::Filter` 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: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:717:1: rust2-ffi: cannot export fn `launched`: foreign type `std::iter::Chain` 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: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:734:1: rust2-ffi: cannot export fn `launches`: foreign type `std::iter::Flatten` 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: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:757:1: rust2-ffi: cannot export fn `pumped`: foreign type `std::iter::Flatten` 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: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:771:1: rust2-ffi: cannot export fn `skipped`: foreign type `std::iter::Skip` 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: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:776:1: rust2-ffi: cannot export fn `merged`: foreign type `std::iter::Copied` 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: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:77:1: rust2-ffi: cannot export fn `first`: borrowed return that is not Clone `Opaque` help: return an owned value or a `Clone` type, since a borrowed return crosses as a clone -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:783:1: rust2-ffi: cannot export fn `values`: foreign type `std::collections::btree_map::IntoValues` + 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:789:1: rust2-ffi: cannot export fn `floats`: collection not built from its items `std::collections::BTreeSet` help: the collection must build from its items, which a `BTreeSet` or `BTreeMap` of a type without `Ord`, such as `f64`, cannot: key it by an ordered type, or take a `Vec` and build the collection inside the facade -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 `zeros`: foreign type `std::iter::RepeatN` 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: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:799:1: rust2-ffi: cannot export fn `successes`: foreign type `std::iter::Flatten` 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: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:819:1: rust2-ffi: cannot export fn `allocated`: foreign type `std::vec::IntoIter` 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: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:826:1: rust2-ffi: cannot export fn `flattened`: foreign type `std::iter::Flatten` 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: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:850:1: rust2-ffi: cannot export fn `lent`: foreign type `std::vec::IntoIter` 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: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 `halves`: foreign type `std::str::Split` 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: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 `settled`: 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: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:878:1: rust2-ffi: cannot export fn `poll_named`: poll's parameter taken by value that is not Copy `std::string::String` help: take it by reference, or make it `Copy`, since each poll calls the function again -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:884:1: rust2-ffi: cannot export fn `poll_first`: borrowed Poll `&u8` help: return an owned `Poll` that borrows nothing from its arguments -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:890:1: rust2-ffi: cannot export fn `poll_until`: poll's parameter taken by value that is not Copy `impl Fn(u8) -> bool` help: take it by reference, or make it `Copy`, since each poll calls the function again -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:901:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future help: take a `Context` only in a function returning `Poll`; a function returning a future makes its own -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_ticket`: 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: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:925:1: rust2-ffi: cannot export fn `poll_both`: several task parameters help: take one `Context` or one waiter, not several -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:932:1: rust2-ffi: cannot export fn `poll_bump`: &mut of a value in a future help: take the value by value and return the changed one, or hold it in an object changed through `&self` -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 `peek_some`: reference to a handle inside a value `std::boxed::Box` 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: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:944:1: rust2-ffi: cannot export fn `bump_some`: &mut of a value inside an Option `std::option::Option<&mut u32>` help: take the `&mut` value directly, not inside an `Option` -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 `rest`: 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: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 `fill`: returned borrow of a value written back `impl std::future::Future`; &mut of a value in a future help: return an owned value, or make the type an object by giving it a private field, so `&mut self` writes nothing back help: take the value by value and return the changed one, or hold it in an object changed through `&self` -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 `zero`: &mut of a slice `[u8]` 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: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:966:1: rust2-ffi: cannot export fn `reseat`: &mut of another crate's Arc `std::sync::Arc` help: take `&Arc`, or the `Arc` by value, since an opaque handle cannot be replaced in place -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:979:2: rust2-ffi: cannot export method `Keeper::check`: borrowed return that is not Clone `Opaque` help: return an owned value or a `Clone` type, since a borrowed return crosses as a clone -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:990:9: rust2-ffi: cannot export use `dep`: re-export of a whole crate `dep` help: re-export the crate's items with `pub use dep::*;`, or wrap the few types a signature needs in types of your own -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:993:9: rust2-ffi: cannot export use `renamed`: re-export of a whole crate `dep` help: re-export the crate's items with `pub use dep::*;`, or wrap the few types a signature needs in types of your own -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 - 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: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:99:2: rust2-ffi: cannot export method `Text::later`: returned object that borrows `impl std::future::Future>` help: return an owned object that borrows nothing, or a guard of a `&mut self` method borrowing the receiver alone 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..3617827d5 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,8 +992,46 @@ 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; +/// 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 { @@ -1542,3 +1585,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/justfile b/ffi/justfile index e5aaecd5c..847e0ba52 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 8d88dd223..000000000 --- a/ffi/moq/ffi.toml +++ /dev/null @@ -1,16 +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::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", - "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 ed9a7604b..47b472d4a 100644 --- a/ffi/release/package.py +++ b/ffi/release/package.py @@ -1120,15 +1120,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/census.rs b/ffi/src/census.rs index a8ca436cf..6368ca663 100644 --- a/ffi/src/census.rs +++ b/ffi/src/census.rs @@ -10,17 +10,9 @@ 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. -pub(crate) fn render( - api: &Api, - collected: &Report, - config: &[String], - exporting: &[(String, Vec)], - clashes: &[Clash], - at: &dyn Fn(Span) -> String, -) -> String { +/// The census of the facade as Markdown, Swift's refusals among the rest; `at` locates a +/// span. +pub(crate) fn render(api: &Api, collected: &Report, clashes: &[Clash], at: &dyn Fn(Span) -> String) -> String { let records = &api.records; let enums = &api.enums; let objects: Vec<_> = api.objects.iter().filter(|o| !o.foreign).collect(); @@ -60,7 +52,7 @@ pub(crate) fn render( 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!( @@ -146,14 +138,6 @@ 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}\","); - } - let _ = writeln!(out, "]\n```"); - } if !clashes.is_empty() { let _ = writeln!(out, "\n## C names claimed twice\n"); for (name, (first, _), (second, span)) in clashes { @@ -184,18 +168,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 1d432b775..9e1fec7cc 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. @@ -335,7 +325,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 +424,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(), @@ -705,26 +693,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 +1087,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 +1109,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. - 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()); - } + // 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, 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 +1161,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 +1177,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 +1188,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 +1271,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 +1321,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, @@ -1415,14 +1366,20 @@ 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 // 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 +1391,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 +1457,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); @@ -2181,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), @@ -2539,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]; @@ -2550,12 +2499,12 @@ 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); 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]; @@ -2579,8 +2528,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); } } @@ -2628,29 +2577,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 @@ -2679,12 +2605,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>, ) { @@ -2710,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()); @@ -2746,26 +2671,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 @@ -2875,37 +2781,10 @@ 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. - 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 { @@ -2914,26 +2793,37 @@ 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 { + 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. 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() { - ty::Adt(adt, args) if tcx.is_diagnostic_item(sym::Option, adt.did()) => args.type_at(0), - _ => ty, + // 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(ty) + 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); @@ -2941,14 +2831,21 @@ 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)), + (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. @@ -2996,22 +2893,29 @@ impl<'tcx> Collector<'tcx> { lends_mut: false, derefs: 0, ties, - access: Access::Field { shared, set }, + access: Access::Field { + set, + through: !assigned, + }, 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); - let value = Param { - name: "value".to_string(), - ty: set, - interned: false, - }; - accessors.push(accessor(Receiver::Mut, vec![value], Type::Unit, true)); + 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(), + 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 @@ -3245,7 +3149,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. @@ -3264,9 +3168,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)); @@ -3344,7 +3245,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)) @@ -3397,16 +3301,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, @@ -3945,6 +3847,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 @@ -4866,6 +4783,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()) => { @@ -6056,12 +5977,17 @@ 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())))); @@ -6170,6 +6096,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) { @@ -6518,13 +6452,44 @@ 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. +/// 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) +} + +/// 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 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 { 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" ) } @@ -6611,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/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 be9e9f546..245bedc69 100644 --- a/ffi/src/driver.rs +++ b/ffi/src/driver.rs @@ -7,18 +7,14 @@ 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::config; use crate::ir::{self, Api}; use crate::{census, collect, glue, merge}; @@ -53,7 +49,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 +76,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 +132,6 @@ impl Export { .map(PathBuf::from); Ok(Some(Self { crates, - config, output, facade, patch, @@ -179,58 +172,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 mut collected = collect::collect(tcx, &facade); 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 a refusal and - // not exporting. + // What Swift refuses fails the export too, so the census lists it with the rest. let (api, swift) = swift_refused(&collected.api, &self.facade.lib); - let refused: FxHashSet<_> = swift.iter().map(|r| r.path.clone()).collect(); let report = &mut collected.report; - report.refusals.extend(swift.into_iter().map(|r| r.refusal)); - let exporting = exporting(&collected.api, &report.audited, &refused); - let config = census_config(tcx, &facade, &self.facade.lib, report); - let text = census::render(&api, report, &config, &exporting, &abi.clashes, &|span| at(tcx, span)); + report.refusals.extend(swift); + let text = census::render(&api, report, &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); } let report = &collected.report; 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 @@ -239,7 +204,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 { @@ -258,180 +222,56 @@ impl Callbacks for Export { } } -/// A function or method Swift refuses, by the path the config names it by, as a census -/// refusal. -struct SwiftRefused { - path: ir::Path, - refusal: collect::Refusal, -} - -/// `api` without what Swift refuses, and each it refuses, which the census adds to its -/// config: to a fixed point, since leaving out a function that throws an object bare can -/// make that object noncopyable, refusing another that throws it inside a value. Swift -/// exports the API without what takes a JNI value, as the export does. -fn swift_refused(api: &Api, lib: &str) -> (Api, Vec) { +/// `api` without what Swift refuses, and each it refuses as a census refusal: to a fixed +/// point, since leaving out a function that throws an object bare can make that object +/// noncopyable, refusing another that throws it inside a value. Swift exports the API +/// without what takes a JNI value, as the export does. +fn swift_refused(api: &Api, lib: &str) -> (Api, Vec) { let mut api = api.clone(); let mut refused = Vec::new(); loop { 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, detail: String::new(), note: None, }; - let path = configured(r.function); + 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.refusal.why.push(why), - _ => found.push(SwiftRefused { - refusal: collect::Refusal { - path: path[1..].join("::"), + 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], }, - path, - }), + )), } } if found.is_empty() { return (api, refused); } - let gone: FxHashSet<&ir::Path> = found.iter().map(|r| &r.path).collect(); - let keep = |methods: &mut Vec| methods.retain(|f| !gone.contains(&configured(f))); + 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); - } -} - -/// The path the config names `f` by: a field's getter and setter alike, by `field@` where -/// a method or constant of its type shares its path, so refusing that one keeps the other. -fn configured(f: &ir::Function) -> ir::Path { - let mut path = f.shown.clone(); - if let ir::Access::Field { shared: true, .. } = f.access { - path[1].insert_str(0, "field@"); + refused.extend(found.into_iter().map(|(_, r)| r)); } - path -} - -/// The `exclude` that exports what maps: each item `report` refuses, Swift's included, -/// 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 or Swift refuses besides is added, until the config -/// holds. -fn census_config(tcx: TyCtxt<'_>, facade: &collect::Facade, lib: &str, report: &collect::Report) -> Vec { - let mut config: Vec = report.refusals.iter().map(|r| r.path.clone()).collect(); - 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 (_, swift) = swift_refused(&checked.api, lib); - let more = (checked.report.refusals.iter().map(|r| r.path.clone())) - .chain(swift.into_iter().map(|r| r.refusal.path)) - .collect::>(); - 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 configured 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(&configured(f))) { - 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 { @@ -465,7 +305,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; @@ -603,7 +442,7 @@ impl Export { let mut err = tcx.dcx().struct_span_err( refusal.function.span, format!( - "rust2-ffi: cannot export {} `{}`: {}; exclude it in the config to leave it out", + "rust2-ffi: cannot export {} `{}`: {}", refusal.kind, refusal.function.shown[1..].join("::"), refusal.why @@ -656,9 +495,9 @@ fn stop_on_errors(tcx: TyCtxt<'_>) -> Compilation { } } -/// Emits `refusal` as an error at its span, with every reason, its notes, and how to change the -/// facade, then `advice`. -fn refuse(tcx: TyCtxt<'_>, refusal: &collect::Refusal, advice: &str) { +/// Emits `refusal` as an error at its span, with every reason, any `advice`, its notes, and how to +/// change the facade. +fn refuse(tcx: TyCtxt<'_>, refusal: &collect::Refusal, advice: Option<&str>) { let reasons: Vec = refusal .why .iter() @@ -670,10 +509,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()) { @@ -743,154 +583,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 bed53f3da..ff0563f7d 100644 --- a/ffi/src/glue.rs +++ b/ffi/src/glue.rs @@ -1203,9 +1203,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})"), @@ -2798,7 +2799,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!( @@ -3120,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/src/help.rs b/ffi/src/help.rs index a0a8f844e..5080b90cd 100644 --- a/ffi/src/help.rs +++ b/ffi/src/help.rs @@ -17,7 +17,6 @@ pub(crate) fn of(construct: &str) -> Option<&'static str> { "macro" => "export a function that does what the macro does, or mark the macro `#[doc(hidden)]`", "static" => "export a function returning the value, or a `const`", "item kind" => "export a function, type, trait, or constant that wraps it, or mark it `#[doc(hidden)]`", - "excluded type" => "the config leaves this type out, so leave out each item that names it too", "doc(hidden) type" => "remove `#[doc(hidden)]` from the type, or mark this item `#[doc(hidden)]` too", "discriminant outside `i32`" => "give each variant a discriminant within `i32`, as a C enum holds", "non-exhaustive variant" => "remove `#[non_exhaustive]` from the variant, since a binding lists every field", @@ -48,6 +47,15 @@ pub(crate) fn of(construct: &str) -> Option<&'static str> { "export a `bool` or an integer below 128 bits, a value that evaluates at compile time, or a function returning the value" } "type" => "use a type the README's rules table maps, or wrap it in one of your own", + "Cow other than a returned string or bytes" => { + "take `&str`, `&[u8]`, or an owned value instead, and return `Cow` only as a whole `Cow` or `Cow<[u8]>`" + } + "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" + } "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/src/ir.rs b/ffi/src/ir.rs index e2661a101..fed139c78 100644 --- a/ffi/src/ir.rs +++ b/ffi/src/ir.rs @@ -544,10 +544,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. `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; `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/src/lock.rs b/ffi/src/lock.rs index f3823c624..f734bfec4 100644 --- a/ffi/src/lock.rs +++ b/ffi/src/lock.rs @@ -825,12 +825,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 6fb94f73c..e28e59615 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 ), ); diff --git a/ffi/surface/api/c.h b/ffi/surface/api/c.h index 906322410..f9f324f56 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)0x745de2698940a417ULL) +#define API_CONTRACT ((uint64_t)0x4ef55d1d8a723c39ULL) 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; @@ -814,6 +815,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_Deprecated { bool on; uint32_t lower; @@ -1246,6 +1251,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); @@ -1323,6 +1329,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_Deprecated_free(api_Deprecated *self); bool api_Deprecated_eq(const api_Deprecated *a, const api_Deprecated *b); api_buf api_Deprecated_debug(const api_Deprecated *self); @@ -1437,6 +1447,10 @@ 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); +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); @@ -1458,6 +1472,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); @@ -1472,6 +1488,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); @@ -1544,6 +1562,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); @@ -1561,10 +1581,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); @@ -1691,6 +1717,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); @@ -1809,6 +1836,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); @@ -1888,6 +1917,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); @@ -2154,7 +2184,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); @@ -2324,6 +2353,18 @@ 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); +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); uint8_t api_deprecated(uint8_t note); api_Knob api_knob(api_Dial dial); typedef struct api_level_later_future api_level_later_future; diff --git a/ffi/surface/api/cpp.hpp b/ffi/surface/api/cpp.hpp index 88affd0d7..9d7c0140b 100644 --- a/ffi/surface/api/cpp.hpp +++ b/ffi/surface/api/cpp.hpp @@ -44,6 +44,12 @@ 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; + 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; Receipt &operator=(Receipt &&other) noexcept = default; @@ -73,6 +79,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 { @@ -95,6 +103,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; @@ -164,6 +174,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; @@ -191,11 +203,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; }; @@ -339,6 +355,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 { @@ -447,6 +464,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; @@ -533,6 +552,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; @@ -897,6 +917,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; @@ -1071,6 +1092,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 Deprecated { bool on; [[deprecated]] ::std::uint32_t lower; @@ -1309,6 +1338,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 Deprecated &a__, const Deprecated &b_); inline bool operator==(const Dial &a__, const Dial &b_); inline bool operator==(const Knob &a__, const Knob &b_); @@ -1469,7 +1499,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); @@ -1627,6 +1656,10 @@ 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::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::uint8_t deprecated(::std::uint8_t note); [[deprecated]] inline ::api::Knob knob(const ::api::Dial &dial); [[deprecated("read its `level`")]] inline ::api::level_later_future level_later(const ::api::Dial &dial); @@ -1989,6 +2022,7 @@ namespace api { struct NonZeros; struct a; struct Qualifiers; + struct Spot; struct Deprecated; struct Dial; struct Knob; @@ -2002,6 +2036,7 @@ namespace api { struct tls_policy_Lifetime; struct Core; class Board; + class Tab; class Receipt; class Draft; class Filed_Receipt; @@ -2169,6 +2204,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 level_later_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 0365d66d2..2fa438543 100644 --- a/ffi/surface/api/dart.dart +++ b/ffi/surface/api/dart.dart @@ -416,6 +416,7 @@ final class PairU8Size { String debug(); @override bool operator ==(Object other); @override int get hashCode; + PairSizeU8 swap(); } final class LeftRightU8 { final RightU8 value; @@ -614,6 +615,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 Deprecated_ { final bool on; @Deprecated('') final int lower; @@ -980,6 +990,10 @@ final class Board extends _Object { List<(String, Counter)> ranked(); Counter best(); } +final class Tab extends _Object { + Ledger get ledgerGet; + String get labelGet; +} final class Receipt extends _Object { Receipt clone(); int count(); @@ -1001,6 +1015,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 { @@ -1017,6 +1033,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; @@ -1069,6 +1087,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(); @@ -1088,9 +1108,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(); } @@ -1214,6 +1238,7 @@ final class Ledger extends _Object { Receipt receipt(); Receipt noted(); FiledReceipt fileReceipt(Receipt item); + Tab tab(); Slip slip(); } final class Slip extends _Object { @@ -1302,6 +1327,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(); @@ -1369,6 +1396,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(); @@ -1612,7 +1640,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); @@ -1770,6 +1797,10 @@ SocketAddr sameSocketAddr(SocketAddr v); 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); int deprecated(int note); @Deprecated('') Knob knob(Dial dial); @Deprecated('read its `level`') Cancelable levelLater(Dial dial); diff --git a/ffi/surface/api/go.txt b/ffi/surface/api/go.txt index b37426ad1..52d82c018 100644 --- a/ffi/surface/api/go.txt +++ b/ffi/surface/api/go.txt @@ -134,6 +134,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) @@ -231,13 +232,16 @@ 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 TurnerVtable_() unsafe.Pointer +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) func VisitChunks(payload p_rt.Bytes, size uint, visit func(*[]byte) uint64) []uint64 func VisitStray(visit func(string)) @@ -1037,6 +1041,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 @@ -1130,6 +1135,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) @@ -1205,6 +1211,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) @@ -1275,8 +1283,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_ } @@ -1324,6 +1334,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 @@ -1474,6 +1485,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 @@ -1564,12 +1577,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] @@ -1582,6 +1599,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_ } @@ -1591,6 +1615,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 @@ -1638,6 +1663,12 @@ 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) 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 365841d5a..0e7b7336c 100644 --- a/ffi/surface/api/kotlin.kt +++ b/ffi/surface/api/kotlin.kt @@ -275,6 +275,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 @@ -368,6 +369,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 { + @kotlin.jvm.JvmStatic @kotlin.jvm.Throws(StringException::class) fun deserialize(deserializer: api.Json): api.Spot + } +} data class Deprecated(val on: kotlin.Boolean, @kotlin.Deprecated("") val lower: kotlin.UInt, val deprecated: kotlin.Boolean) { fun debug(): kotlin.String companion object { @@ -571,6 +578,11 @@ class Board internal constructor(raw: Long, lent: Boolean = false) : AutoCloseab @kotlin.jvm.JvmStatic 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 + val labelGet: kotlin.String +} class Receipt internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { override fun close() fun clone(): api.Receipt @@ -595,6 +607,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 { @kotlin.jvm.JvmStatic fun wide(): api.PadU16 @@ -620,6 +634,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 @@ -627,6 +642,7 @@ class Marker internal constructor(raw: Long, lent: Boolean = false) : AutoClosea fun offset(dx: kotlin.Int, dy: kotlin.Int): api.Point companion object { @kotlin.jvm.JvmStatic fun new(label: kotlin.String, x: kotlin.Int, y: kotlin.Int): api.Marker + @kotlin.jvm.JvmStatic fun y(): kotlin.Int } } class Batch internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { @@ -697,6 +713,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) @@ -726,12 +744,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 { @kotlin.jvm.JvmStatic 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 { @kotlin.jvm.JvmStatic fun new(value: kotlin.UByte): api.SlotU8 @@ -899,6 +921,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 { @kotlin.jvm.JvmStatic fun default(): api.Ledger @@ -1014,6 +1037,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 { @@ -1103,6 +1128,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 { @kotlin.jvm.JvmStatic fun default(): api.Stack @kotlin.jvm.JvmStatic fun new(): api.Stack @@ -1408,7 +1434,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 @@ -1566,6 +1591,10 @@ 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 +suspend fun unescapedLater(text: kotlin.String): kotlin.String +suspend fun unescapedMaybe(text: kotlin.String?): kotlin.String? +fun unzeroed(bytes: api.Bytes): api.Bytes fun deprecated(note: kotlin.UByte): kotlin.UByte @kotlin.Deprecated("") fun knob(dial: api.Dial): api.Knob @kotlin.Deprecated("read its `level`") suspend fun levelLater(dial: api.Dial): kotlin.ULong diff --git a/ffi/surface/api/python.pyi b/ffi/surface/api/python.pyi index 984f26c74..baf9647c9 100644 --- a/ffi/surface/api/python.pyi +++ b/ffi/surface/api/python.pyi @@ -269,6 +269,7 @@ class PairU8Size(_Record): def __init__(self, left: _int, right: Size) -> None: ... def __eq__(self, other: _object) -> _bool: ... def __repr__(self) -> _str: ... + def swap(self) -> PairSizeU8: ... class LeftRightU8(_Record): value: RightU8 def __init__(self, value: RightU8) -> None: ... @@ -424,6 +425,14 @@ class Qualifiers(_Record): kotlin: _float def __init__(self, api: _float, kotlin: _float) -> None: ... def __eq__(self, other: _object) -> _bool: ... +class Spot(_Record): + x: _int + y: _int + def __init__(self, x: _int, y: _int) -> None: ... + def __eq__(self, other: _object) -> _bool: ... + def __repr__(self) -> _str: ... + @_staticmethod + def deserialize(deserializer: Json) -> Spot: ... class Deprecated(_Record): on: _bool lower: _int @@ -757,6 +766,11 @@ 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: ... + @_property + def label_get(self) -> _str: ... class Receipt(_n.Object): def clone(self) -> Receipt: ... def count(self) -> _int: ... @@ -777,6 +791,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 @@ -795,6 +812,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: ... @@ -852,6 +872,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: ... @@ -871,9 +894,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: ... @@ -1016,6 +1045,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: ... @@ -1108,6 +1138,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: ... @@ -1181,6 +1214,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: ... @@ -1349,6 +1383,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: ... @_deprecated('read its `level`') async def level_later(dial: Dial) -> _int: ... def has_text(note: Note) -> _bool: ... @@ -1439,7 +1475,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: ... @@ -1592,6 +1627,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 deprecated(note: _int) -> _int: ... @_deprecated('') def knob(dial: Dial) -> Knob: ... @@ -1702,7 +1739,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 @@ -1855,6 +1891,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 deprecated = _n.deprecated knob = _n.knob turned = _n.turned diff --git a/ffi/surface/api/swift.swift b/ffi/surface/api/swift.swift index 4aa35f22f..add1dac10 100644 --- a/ffi/surface/api/swift.swift +++ b/ffi/surface/api/swift.swift @@ -404,6 +404,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 @@ -579,6 +580,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 Deprecated: Sendable, CustomDebugStringConvertible, Equatable { public var on: Swift.Bool @available(*, deprecated) @inlinable public var lower: Swift.UInt32 { get set } @@ -800,6 +809,10 @@ 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 + @inlinable public var labelGet: Swift.String { get } +} public struct Receipt: ~Copyable, @unchecked Sendable { @inlinable public func clone() throws -> Receipt @inlinable public func count() throws -> Swift.UInt32 @@ -821,6 +834,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 { @@ -837,6 +852,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 } @@ -889,6 +906,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 @@ -908,11 +927,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 @@ -1039,6 +1062,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 { @@ -1124,6 +1148,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 @@ -1193,6 +1219,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 } @@ -1438,7 +1465,6 @@ public let URL: Swift.UInt64 @inlinable public func len(_ payload: borrowing Swift.Span) -> 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: borrowing Swift.Span) -> Swift.String @inlinable public func queuedHex(_ queued: Bytes) -> Swift.String @inlinable public func tickName(_ tick: Label) -> Swift.String @@ -1596,6 +1622,10 @@ public let URL: Swift.UInt64 @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 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: borrowing Swift.Span) -> Bytes @inlinable public func deprecated(_ note: Swift.UInt8) -> Swift.UInt8 @available(*, deprecated) @inlinable public func knob(_ dial: Dial) -> Knob @available(*, deprecated, message: "read its `level`") @inlinable nonisolated(nonsending) public func levelLater(_ dial: Dial) async throws -> Swift.UInt64 diff --git a/ffi/surface/api/web.d.ts b/ffi/surface/api/web.d.ts index fe5434dc0..1e4f4ce9f 100644 --- a/ffi/surface/api/web.d.ts +++ b/ffi/surface/api/web.d.ts @@ -670,6 +670,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; @@ -680,6 +681,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 }; @@ -789,6 +791,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; @@ -873,6 +877,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; @@ -959,6 +965,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 @@ -1014,6 +1022,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; @@ -1021,6 +1030,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"; @@ -1177,6 +1187,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; @@ -1290,12 +1302,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 }; @@ -1309,10 +1325,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">; @@ -1326,6 +1354,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 @@ -1373,6 +1402,13 @@ 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; +export declare function labelGet(self: Tab): string; + // Tallies.ts import * as rt from "./rt.ts"; import type { Tally } from "./Tally.ts"; @@ -1634,6 +1670,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"; @@ -1726,6 +1763,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; @@ -1779,6 +1817,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; @@ -1817,6 +1857,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; @@ -2011,6 +2052,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; @@ -2413,7 +2455,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; @@ -2571,6 +2612,10 @@ 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 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 deprecated(note: number): number; export declare function knob(dial: Dial): Knob; export declare function levelLater(dial: Dial): rt.Call; diff --git a/ffi/surface/moq-web/web.d.ts b/ffi/surface/moq-web/web.d.ts index 3fb5994c7..253ea1db4 100644 --- a/ffi/surface/moq-web/web.d.ts +++ b/ffi/surface/moq-web/web.d.ts @@ -6534,6 +6534,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"; @@ -6556,6 +6557,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 }; @@ -10468,6 +10470,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 38ccce14d..637508de6 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)0x81b0b3dbc434edaeULL) +#define MOQ_CONTRACT ((uint64_t)0x0ac854b23d858bf7ULL) uint64_t moq_contract(void); uint32_t moq_target(void); typedef int32_t moq_status; @@ -8403,6 +8403,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); @@ -9165,6 +9166,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); @@ -9293,6 +9295,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 13b3ef015..506d1989b 100644 --- a/ffi/surface/moq/cpp.hpp +++ b/ffi/surface/moq/cpp.hpp @@ -4201,6 +4201,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 { @@ -7288,6 +7289,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> { @@ -8527,6 +8530,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 0877483b2..362764bb0 100644 --- a/ffi/surface/moq/dart.dart +++ b/ffi/surface/moq/dart.dart @@ -6834,6 +6834,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 { @@ -7569,6 +7570,7 @@ final class MoqTokioListenForward extends _Object { } final class RustlsClientDangerDangerousClientConfig extends _Object { String debug(); + RustlsClientConfig get cfgGet; } final class RustlsClientResumption extends _Object { String debug(); @@ -7705,6 +7707,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 7b9124614..e3de7f0c5 100644 --- a/ffi/surface/moq/go.txt +++ b/ffi/surface/moq/go.txt @@ -4383,6 +4383,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) @@ -7464,6 +7465,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 ( @@ -7846,6 +7851,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 a8d95a454..4cab4edcb 100644 --- a/ffi/surface/moq/kotlin.kt +++ b/ffi/surface/moq/kotlin.kt @@ -6943,6 +6943,7 @@ class MuxContainerTsMpegts internal constructor(raw: Long, lent: Boolean = false fun isEmpty(): kotlin.Boolean companion object { @kotlin.jvm.JvmStatic fun default(): moq.MuxContainerTsMpegts + @kotlin.jvm.JvmStatic @kotlin.jvm.Throws(StringException::class) fun deserialize(deserializer: moq.Json): moq.MuxContainerTsMpegts } } class MuxContainerTsPassthroughTrack internal constructor(raw: Long, lent: Boolean = false) : AutoCloseable { @@ -7850,6 +7851,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() @@ -8204,6 +8206,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 1001d75da..4dd7c76ea 100644 --- a/ffi/surface/moq/python.pyi +++ b/ffi/surface/moq/python.pyi @@ -6975,6 +6975,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: ... @@ -7804,6 +7806,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: ... @@ -9283,6 +9287,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]: ... @@ -9317,6 +9323,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 6a4cdc17d..5c63789ae 100644 --- a/ffi/surface/moq/swift.swift +++ b/ffi/surface/moq/swift.swift @@ -6399,6 +6399,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 { @@ -7118,6 +7119,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 } @@ -7312,6 +7314,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.py b/ffi/tests/api.py index 72d3b6789..026c74951 100644 --- a/ffi/tests/api.py +++ b/ffi/tests/api.py @@ -428,6 +428,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. diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index 7122e6942..35d53fe40 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -103,8 +103,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])) @@ -116,30 +116,28 @@ 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(", - ] { - 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. @@ -3119,8 +3117,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")) @@ -3176,8 +3174,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")) @@ -3208,14 +3206,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", ), @@ -3223,11 +3217,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\ @@ -3235,7 +3229,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\ @@ -3283,8 +3277,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"))); @@ -3315,8 +3309,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"); @@ -3324,16 +3318,14 @@ 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"] { - 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("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("--config") - .arg(moved.join("ffi.toml")) + .arg("--manifest-path") + .arg(moved.join("Cargo.toml")) .arg("--out") .arg(moved.join("out")) .arg("--with") @@ -3345,13 +3337,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(); @@ -3372,8 +3365,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}"); } @@ -3396,7 +3389,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}"); @@ -3475,8 +3468,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"))) @@ -3575,47 +3568,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}" - ); - // Nor on a method Swift alone refuses, though not its field, which Swift keeps. - for exclude in ["jitter", "spread"] { - assert!( - errors.contains(&format!( - "error: rust2-ffi: exclude `field@Retry::{exclude}` in the config leaves out `field@Retry::{exclude}`, which exports" - ).as_str()), - "the census does not fail on `field@Retry::{exclude}`:\n{stderr}" - ); - assert!( - !errors - .iter() - .any(|error| error.contains(&format!("exclude `Retry::{exclude}`"))), - "the census fails on `Retry::{exclude}`:\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", @@ -3625,37 +3593,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`", - "- `field@Retry::spread`: `field@Retry::spread`", - "- `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`", - "- `Retry::spread`", - ] { - 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. @@ -4180,7 +4120,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() @@ -4204,8 +4143,6 @@ 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("--out") @@ -4238,7 +4175,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{}", @@ -4246,12 +4183,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("--") @@ -4260,13 +4197,69 @@ fn census(config: &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] 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"); } @@ -4281,7 +4274,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{}", @@ -4330,8 +4323,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")) @@ -4364,8 +4357,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"]) @@ -4416,8 +4409,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"]) @@ -4512,62 +4505,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() { @@ -4580,8 +4517,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"))); @@ -4656,8 +4593,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()) @@ -4717,8 +4654,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 @@ -4800,13 +4737,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") @@ -4864,8 +4801,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("--") @@ -5059,14 +4996,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!( @@ -5132,11 +5068,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\"]"]) @@ -5184,7 +5119,6 @@ fn profiled() { "[package]\nname = \"rust2-ffi-profiled-dev\"\nversion = \"0.0.0\"\nedition = \"2024\"\n", ), ("dev/src/lib.rs", ""), - ("ffi.toml", ""), ], ); }; @@ -5204,7 +5138,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!( @@ -5212,7 +5146,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 4bf988064..d11b20359 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 1ba155e2f..4587e6a04 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 } @@ -998,22 +1001,18 @@ fn emit(name: &str, shapes: &[Shape], drawn: Option<(usize, u64)>) -> Crate { [dependencies]\nbytes = \"1\"\nserde_json = \"1\"\nurl = \"2\"\n\n\ # Marks each call of the native script that digests a NaN of its own bits.\n[features]\ntranscript = []\n\n[workspace]\n" ); - super::write_all( - &dir, - &[("Cargo.toml", &manifest), ("src/lib.rs", &lib), ("ffi.toml", "")], - ); + 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")); + // 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| item.paths(n).iter().all(|path| !refused.absent.contains(path)); - let mut excludes: Vec<&String> = refused.exclude.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.refused { + kept = cfg_out(&kept, path); + } + super::write_all(&dir, &[("src/lib.rs", &kept)]); let mut calls = Vec::new(); for n in 0..shapes.len() { @@ -1106,54 +1105,86 @@ fn later(f: impl Future) -> T { fn main() { "; -/// What the census of the crate in `dir` says does not export: the config that exports -/// what maps, and what leaves itself out. +/// What the census of the crate in `dir` says does not export: what it refuses, Swift's +/// refusals included, and what leaves itself out. fn refused(dir: &Path) -> Refused { 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 exclude = match report.split_once("## The config that exports what maps") { - Some((_, config)) => 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(), - None => Vec::new(), + let section = |heading: &str| -> Vec { + let Some((_, list)) = report.split_once(heading) else { + return Vec::new(); + }; + (list.lines().skip(1)) + .take_while(|line| !line.starts_with("## ")) + .filter_map(|line| Some(line.split_once('`')?.1.split_once('`')?.0.to_string())) + .collect() }; + let mut refused = section("## Refused items"); + refused.sort(); + refused.dedup(); // The traits C cannot implement, and what C can never hold, leave themselves out. - let mut absent = exclude.clone(); - for section in [ - "## Traits left out, since C cannot implement them", - "## What C can never hold, left out", - ] { - let Some((_, list)) = report.split_once(section) else { - continue; - }; - absent.extend( - (list.lines().skip(1)) - .take_while(|line| !line.starts_with("## ")) - .filter_map(|line| Some(line.strip_prefix("- `")?.split_once('`')?.0.to_string())), - ); - } - Refused { exclude, absent } + let mut absent = refused.clone(); + absent.extend(section("## Traits left out, since C cannot implement them")); + absent.extend(section("## What C can never hold, left out")); + Refused { refused, absent } } /// What the census of the shapes' crate says does not export. struct Refused { - /// The paths its config leaves out. - exclude: Vec, + /// The paths it refuses, which the crate leaves out, as the export would fail on them. + refused: Vec, /// Those, and what leaves itself out. absent: Vec, } +/// `lib` with the item at `path` configured out: a function or type, or a method by its +/// 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 + .find(&format!("impl {ty} ")) + .unwrap_or_else(|| panic!("the census refuses `{path}`, which is no item of the crate's")); + (from, method) + } + None => (0, path), + }; + let at = ["pub fn ", "pub async fn ", "pub struct ", "pub enum "] + .iter() + .filter_map(|head| { + let rest = &lib[from..]; + [ + format!("{head}{name}("), + format!("{head}{name} "), + format!("{head}{name}<"), + ] + .iter() + .filter_map(|item| rest.find(item.as_str())) + .min() + }) + .min() + .unwrap_or_else(|| panic!("the census refuses `{path}`, which is no item of the crate's")); + let at = from + at; + format!("{}#[cfg(any())]\n{}", &lib[..at], &lib[at..]) +} + /// Each variant of the IR's `Type`, from its source. fn ir_variants() -> Vec { let ir = std::fs::read_to_string(manifest_dir().join("src").join("ir.rs")).unwrap(); @@ -1197,8 +1228,8 @@ fn build(name: &str, shapes: &[Shape], drawn: Option<(usize, u64)>) -> Built { let krate = emit(name, shapes, drawn); 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) // One binding for the host and the target the web binding serves, as the api diff --git a/ffi/tests/fixtures/transcript/ir.rs b/ffi/tests/fixtures/transcript/ir.rs index d455b1d76..cf2142e62 100644 --- a/ffi/tests/fixtures/transcript/ir.rs +++ b/ffi/tests/fixtures/transcript/ir.rs @@ -161,7 +161,11 @@ pub(crate) struct Instance { #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Deserialize)] pub(crate) enum Access { Call, - Field { shared: bool, set: bool }, + Field { + set: bool, + #[serde(default)] + through: bool, + }, Const, Parse, Text, 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 }} 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 c64e868b6..090867f63 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 36703d97f..fea62ae78 100644 --- a/quest/m1/ffi-export/ship.md +++ b/quest/m1/ffi-export/ship.md @@ -12,13 +12,12 @@ 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 - [Dart analysis](/quest/m1/ffi-export/dart-analyze.md) - lint fixes may rename generated Dart 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 3ee72cbd6..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`, [`ffi/FACADE.md`](/ffi/FACADE.md) (its loop and census steps), 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). 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.