From 4e8a7d647f8120bfb66a122b515fd20121c98c27 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 11:05:23 -0800 Subject: [PATCH 01/24] chore(quest): claim quest/m1/ffi-refusals/moq-pin.md Quest-Claim: 51e7f297c991d9cb From f21ae8728e8beec239d56e166495d537ad64217d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 11:10:27 -0800 Subject: [PATCH 02/24] feat(ffi): export a type the root does not reach by its public path in its crate Co-Authored-By: Claude Opus 5.5 --- ffi/src/collect.rs | 94 ++++++++++++++++++++++++++++++-- ffi/tests/fixtures.rs | 57 +++++++++++++++++++ quest/m1/ffi-refusals/moq-pin.md | 7 ++- 3 files changed, 153 insertions(+), 5 deletions(-) diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 8dcb4e8c5..e9176f3bf 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -208,6 +208,11 @@ struct Collector<'tcx> { range_bounds: Option, /// Objects no export returns, left out. orphans: rustc_data_structures::fx::FxHashSet>, + /// Types a signature names that the root does not reach, each exported by its public + /// path in its own crate. + reach: Vec, + /// Such types this pass met that `reach` lacks. + unreached: std::cell::RefCell>, api: Api, } @@ -284,7 +289,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected { }; keys.insert(krate, key); } - let pass = |orphans: &rustc_data_structures::fx::FxHashSet>| { + let pass = |orphans: &rustc_data_structures::fx::FxHashSet>, reach: &[DefId]| { let mut c = Collector { tcx, items: Vec::new(), @@ -318,6 +323,8 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected { bound, range_bounds, orphans: orphans.clone(), + reach: reach.to_vec(), + unreached: Default::default(), api: Api { records: Vec::new(), enums: Vec::new(), @@ -354,18 +361,23 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected { c }; // Leaving out an object no export returns leaves out what takes it, which may leave another - // object no export returns, so collection repeats until it refuses no more. + // object no export returns, so collection repeats until it refuses no more. A type the + // root does not reach is walked from its defining path in the next pass, whose + // signatures may name more. let mut orphans = rustc_data_structures::fx::FxHashSet::default(); + let mut reach = Vec::new(); loop { - let c = pass(&orphans); + let c = pass(&orphans, &reach); let more = c.orphans(); - if more.is_empty() { + let unreached = c.unreached.take(); + if more.is_empty() && unreached.is_empty() { return Collected { api: c.api, report: c.report, }; } orphans.extend(more); + reach.extend(unreached); } } @@ -1150,6 +1162,73 @@ impl<'tcx> Collector<'tcx> { } } } + self.walk_reach(&seen); + } + + /// Walk each type in `reach` the root did not, by its public path in its own crate, as if + /// a module of the facade re-exported that crate's root. + fn walk_reach(&mut self, seen: &rustc_data_structures::fx::FxHashSet) { + let tcx = self.tcx; + for def_id in self.reach.clone() { + if seen.contains(&def_id) { + continue; + } + let mut path = vec![self.report.root.clone()]; + if !def_id.is_local() { + path.push(tcx.crate_name(def_id.krate).to_string()); + } + 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); + self.left_out.insert(def_id, "doc(hidden) type"); + continue; + } + if !self.crates.contains(&def_id.krate) { + self.crates.push(def_id.krate); + } + self.outside.insert(def_id, outside); + self.items.push((def_id, path)); + } + } + + /// The shortest public path to `def_id` from its own crate's root, through that crate's + /// modules and re-exports, as `kio::Pending` names one defined in a private module. + fn crate_path(&self, def_id: DefId) -> Option> { + let tcx = self.tcx; + let root = def_id.krate.as_def_id(); + let mut seen = rustc_data_structures::fx::FxHashSet::default(); + let mut queue = VecDeque::from([(root, Vec::new())]); + while let Some((module, path)) = queue.pop_front() { + let children = match module.as_local() { + Some(local) => tcx.module_children_local(local), + None => tcx.module_children(module), + }; + for child in children { + let Res::Def(kind, id) = child.res else { + continue; + }; + if !child.vis.is_public() || child.ident.name == rustc_span::kw::Underscore || id.krate != def_id.krate + { + continue; + } + let mut path = path.clone(); + path.push(child.ident.to_string()); + if id == def_id { + return Some(path); + } + if kind == DefKind::Mod && seen.insert(id) { + queue.push_back((id, path)); + } + } + } + None } /// Decide how each type and trait is exported, before any signature names one. @@ -4352,6 +4431,13 @@ impl<'tcx> Collector<'tcx> { why.note = Some((tcx.def_span(did), note)); return Err(why); } + // One public in its own crate exports by that path, in the next pass. + if !self.reach.contains(&did) && self.crate_path(did).is_some() { + let mut unreached = self.unreached.borrow_mut(); + if !unreached.contains(&did) { + unreached.push(did); + } + } return Err(why("type not reachable from the crate root", name)); } } diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index 96cc7011d..6a4c2fd3f 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -1212,6 +1212,63 @@ fn go_package_names() { vet(&go); } +/// A type a signature names that the root does not reach, as moq-net's `kio::Pending`, +/// exports by its public path in its own crate, through a re-export or a module; one no public +/// path names stays refused. +#[test] +fn unreached_types() { + let package = package("unreached_types"); + write_all( + &package, + &[ + ( + "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\n[workspace]\nexclude = [\"kio\"]\n", + ), + ( + "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 sealed() -> u32 {\n\tkio::sealed().0\n}\n\npub fn seal() -> kio::Sealed {\n\tkio::sealed()\n}\n", + ), + ( + "kio/Cargo.toml", + "[package]\nname = \"unreached-kio\"\nversion = \"0.0.0\"\nedition = \"2024\"\n\n[lib]\nname = \"kio\"\n", + ), + ( + "kio/src/lib.rs", + "pub struct Ready;\n\nmod pollable {\n\tpub struct Pending(pub u32);\n\n\timpl Pending {\n\t\tpub fn id(&self) -> u32 {\n\t\t\tself.0\n\t\t}\n\t}\n}\n\npub use pollable::Pending;\n\n\ + pub mod version {\n\t#[derive(Clone, Copy)]\n\tpub struct Version {\n\t\tpub major: u32,\n\t}\n}\n\n\ + mod sealed {\n\tpub struct Sealed(pub u32);\n}\n\npub type Sealed = sealed::Sealed;\n\n\ + pub fn sealed() -> sealed::Sealed {\n\tsealed::Sealed(3)\n}\n", + ), + ], + ); + let census = package.join("census"); + let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) + .arg("--config") + .arg(package.join("ffi.toml")) + .arg("--census") + .arg(&census) + .env("CARGO_TARGET_DIR", package.join("build")) + .output() + .unwrap(); + assert!( + output.status.success(), + "the census failed:\n{}", + String::from_utf8_lossy(&output.stderr) + ); + let report = std::fs::read_to_string(census.join("unreached_types.md")).unwrap(); + // `Pending` and `Version` export; `Sealed` alone is refused, though an alias names it. + assert!(report.contains("| Types | 2 | 0 |"), "{report}"); + assert!( + report.contains("fn `seal` at src/lib.rs:15:1: type not reachable from the crate root `kio::sealed::Sealed`"), + "{report}" + ); + assert_eq!(report.matches("not reachable").count(), 3, "{report}"); +} + /// `go vet` over an export's `go/`, which the header beside it lets cgo check unlinked. fn vet(go: &Path) { run(Command::new("go") diff --git a/quest/m1/ffi-refusals/moq-pin.md b/quest/m1/ffi-refusals/moq-pin.md index 4c8df9538..160968e41 100644 --- a/quest/m1/ffi-refusals/moq-pin.md +++ b/quest/m1/ffi-refusals/moq-pin.md @@ -58,7 +58,12 @@ moq's `main` fails `just ts moq` and `just ffi moq-cpp`, so the bump waits on Wa Decided 2026-11-11 (maintainer, /quest-unblock): ✅ (a) rust2 exports a type the crate root does not reach by its defining path, such as `kio::Pending` and `lite::version::Version`; a type whose defining path is itself private stays refused (rejected: (b) moq makes both reachable). -This quest makes the exporter change, in `ffi/src/collect.rs`, before the bump. +[moq-dev/rust2#721](https://github.com/moq-dev/rust2/pull/721) made the exporter change: a +type a signature names that the root does not reach exports by its shortest public path in +its own crate, so `kio::Pending` (defined in kio's private `pollable`) and moq-tokio's +`cli::Deprecated` export. At moq `ba47ea3` the census then lists no such refusal; only +`lite::version::Version`, which no public path names, stays out, as an object no export +returns. Measured on 2026-11-12 at moq's `main` `6936f0a`: `just ffi moq-cpp` fails the export with 36 errors, which the bump fixes in `ffi/moq/ffi.toml` or the exporter: 15 on the foreign From 1b0108148c5a62cf9a03345c54e33d1c3c85a9fc Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 11:33:00 -0800 Subject: [PATCH 03/24] fix(ffi): name a reached crate's types through the glue's own dependency on it Co-Authored-By: Claude Opus 5.5 --- ffi/src/cli.rs | 62 ++++++++++++++++++++++++++++++++ ffi/src/collect.rs | 52 ++++++++++++++++++++++++--- ffi/src/config.rs | 3 ++ ffi/src/driver.rs | 14 ++++++++ ffi/src/glue.rs | 29 +++++++++++++-- ffi/src/ir.rs | 12 +++++++ ffi/src/merge.rs | 6 ++++ ffi/tests/fixtures.rs | 21 +++++++++-- quest/m1/ffi-refusals/moq-pin.md | 12 ++++--- 9 files changed, 197 insertions(+), 14 deletions(-) diff --git a/ffi/src/cli.rs b/ffi/src/cli.rs index 36b119d12..7ddad1964 100644 --- a/ffi/src/cli.rs +++ b/ffi/src/cli.rs @@ -63,6 +63,7 @@ fn try_run(args: &[String]) -> Result { let dir = args.manifest.parent().expect("a manifest path has a parent"); let picks = Picks::parse(&args.cargo, dir)?; let (facade, patch, checked) = facade(&args.manifest, &targets[0], &picks)?; + let crates = crates(&checked.metadata, &checked.top)?; let line = facade.line(); // A staged API's spans are relative to the workspace and cargo's home, which hold the // same files at other paths on another host. @@ -85,6 +86,7 @@ fn try_run(args: &[String]) -> Result { (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()), (config::env::MERGE, merge), (config::env::ROOTS, roots.as_ref()), output, @@ -286,6 +288,66 @@ fn facade(manifest: &Path, target: &str, picks: &Picks<'_>) -> Result<(config::P Ok((facade, patch, checked)) } +/// Each crate the facade builds with, by its library's crate name, as the glue would depend +/// on the very package: by its directory, its exact crates.io version, or its git commit. +/// A name two packages share, or one from another registry, is left out, so a type of its +/// crate the facade does not re-export stays refused. +fn crates(metadata: &Metadata, top: &str) -> Result { + let packages: BTreeMap<&str, &Package> = metadata.packages.iter().map(|p| (p.id.as_str(), p)).collect(); + let nodes: BTreeMap<&str, &Node> = metadata.resolve.nodes.iter().map(|n| (n.id.as_str(), n)).collect(); + let mut named: BTreeMap> = BTreeMap::new(); + let mut seen = BTreeSet::new(); + let mut queue = vec![top]; + while let Some(id) = queue.pop() { + let (true, Some(package), Some(node)) = (seen.insert(id), packages.get(id), nodes.get(id)) else { + continue; + }; + if id != top + && let Some(lib) = (package.targets.iter()).find(|t| t.kind.iter().any(|k| k.contains("lib"))) + { + let keys = dependency(package); + let lib = lib.name.replace('-', "_"); + match named.get(&lib) { + Some(other) if *other != keys => { + named.insert(lib, None); + } + Some(_) => {} + None => { + named.insert(lib, keys); + } + } + } + let built = |kind: &Option| kind.as_deref() != Some("dev"); + for dep in node.deps.iter().filter(|d| d.dep_kinds.iter().any(|k| built(&k.kind))) { + queue.push(&dep.pkg); + } + } + let table: toml::Table = (named.into_iter()) + .filter_map(|(lib, keys)| Some((lib, toml::Value::String(keys?)))) + .collect(); + toml::to_string(&table).map_err(|err| format!("writing the crates: {err}")) +} + +/// The TOML keys of a dependency on exactly `package`, if the glue can name it. +fn dependency(package: &Package) -> Option { + let name = &package.name; + match package.source.as_deref() { + None => { + let dir = package.manifest_path.parent().expect("a manifest path has a parent"); + Some(format!("package = {name:?}, path = {:?}", dir.display().to_string())) + } + Some("registry+https://github.com/rust-lang/crates.io-index" | "sparse+https://index.crates.io/") => { + Some(format!("package = {name:?}, version = \"={}\"", package.version)) + } + Some(git) if git.starts_with("git+") => { + let (url, rev) = git["git+".len()..].split_once('#')?; + let url = url.split('?').next().unwrap_or(url); + Some(format!("package = {name:?}, git = {url:?}, rev = {rev:?}")) + } + Some(_) => None, + } +} + /// The `[patch]` the glue's workspace resolves the exports by as the check did, wherever /// it builds, as TOML with each path absolute. fn overrides(metadata: &Metadata, top: &Package) -> Result { diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index e9176f3bf..89e107e74 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -95,6 +95,8 @@ pub struct Facade<'a> { pub package: &'a str, /// Paths from its root the config leaves out. pub exclude: &'a [String], + /// The dependency the glue names each crate it builds with by, by its crate name. + pub crates: &'a std::collections::BTreeMap, } /// What collection found in the facade, by paths from its root. @@ -211,6 +213,8 @@ struct Collector<'tcx> { /// Types a signature names that the root does not reach, each exported by its public /// path in its own crate. reach: Vec, + /// The glue's dependency on each crate, as [`Facade::crates`]. + dependencies: std::collections::BTreeMap, /// Such types this pass met that `reach` lacks. unreached: std::cell::RefCell>, api: Api, @@ -324,6 +328,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected { range_bounds, orphans: orphans.clone(), reach: reach.to_vec(), + dependencies: facade.crates.clone(), unreached: Default::default(), api: Api { records: Vec::new(), @@ -333,6 +338,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected { functions: Vec::new(), constants: Vec::new(), crates: Vec::new(), + reached: Vec::new(), targets: vec![tcx.sess.opts.target_triple.tuple().to_string()], }, }; @@ -376,8 +382,13 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected { report: c.report, }; } - orphans.extend(more); - reach.extend(unreached); + // A newly reached type may return an object marked an orphan, so those start over. + if unreached.is_empty() { + orphans.extend(more); + } else { + reach.extend(unreached); + orphans.clear(); + } } } @@ -1179,6 +1190,13 @@ 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(); + if !def_id.is_local() && !self.api.reached.iter().any(|r| r.krate == path[1]) { + let dependency = self.dependency(def_id.krate).expect("a reached crate has a dependency"); + self.api.reached.push(crate::ir::Reached { + krate: path[1].clone(), + dependency, + }); + } path.extend(own); if self.exclude(&path) { self.left_out.insert(def_id, "excluded type"); @@ -1198,6 +1216,29 @@ impl<'tcx> Collector<'tcx> { } } + /// Whether `def_id` exports by its public path in its own crate. Another crate's must be + /// the only crate of its name, named by none of the facade's root items, and one the glue + /// can depend on, so its path names it there. + fn reachable(&self, def_id: DefId) -> bool { + let tcx = self.tcx; + if self.crate_path(def_id).is_none() { + return false; + } + if def_id.is_local() { + return true; + } + let name = tcx.crate_name(def_id.krate); + let root = tcx.module_children_local(LOCAL_CRATE.as_def_id().expect_local()); + self.keys[&def_id.krate] == name.as_str() + && !root.iter().any(|child| child.ident.name == name) + && self.dependency(def_id.krate).is_some() + } + + /// The TOML keys of the glue's dependency on `krate`, as the facade resolves it. + fn dependency(&self, krate: CrateNum) -> Option { + self.dependencies.get(self.tcx.crate_name(krate).as_str()).cloned() + } + /// The shortest public path to `def_id` from its own crate's root, through that crate's /// modules and re-exports, as `kio::Pending` names one defined in a private module. fn crate_path(&self, def_id: DefId) -> Option> { @@ -1214,7 +1255,10 @@ impl<'tcx> Collector<'tcx> { let Res::Def(kind, id) = child.res else { continue; }; - if !child.vis.is_public() || child.ident.name == rustc_span::kw::Underscore || id.krate != def_id.krate + if !child.vis.is_public() + || child.ident.name == rustc_span::kw::Underscore + || id.krate != def_id.krate + || (kind == DefKind::Mod && tcx.is_doc_hidden(id)) { continue; } @@ -4432,7 +4476,7 @@ impl<'tcx> Collector<'tcx> { return Err(why); } // One public in its own crate exports by that path, in the next pass. - if !self.reach.contains(&did) && self.crate_path(did).is_some() { + if !self.reach.contains(&did) && self.reachable(did) { let mut unreached = self.unreached.borrow_mut(); if !unreached.contains(&did) { unreached.push(did); diff --git a/ffi/src/config.rs b/ffi/src/config.rs index bc274c43a..a7e70e9c9 100644 --- a/ffi/src/config.rs +++ b/ffi/src/config.rs @@ -92,4 +92,7 @@ pub mod env { pub const PACKAGE: &str = "RUST2_FFI_PACKAGE"; /// The `[patch]` resolving the facade as cargo did, as TOML with each path absolute. pub const PATCH: &str = "RUST2_FFI_PATCH"; + /// The dependency the glue would name each crate the facade builds with by, as a TOML + /// table from its library's crate name to its keys. + pub const CRATES: &str = "RUST2_FFI_CRATES"; } diff --git a/ffi/src/driver.rs b/ffi/src/driver.rs index 27c89442d..acbff2a7d 100644 --- a/ffi/src/driver.rs +++ b/ffi/src/driver.rs @@ -44,6 +44,8 @@ pub fn run(args: Vec) -> ExitCode { /// Compiles the facade, exporting its API after analysis. 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. @@ -112,7 +114,18 @@ impl Export { .map(str::to_string) .collect(); let patch = std::env::var(config::env::PATCH).map_err(|_| format!("{} is unset", config::env::PATCH))?; + let crates = std::env::var(config::env::CRATES).map_err(|_| format!("{} is unset", config::env::CRATES))?; + let crates: toml::Table = crates + .parse() + .map_err(|err| format!("{} is malformed: {err}", config::env::CRATES))?; + let crates = (crates.into_iter()) + .map(|(lib, keys)| match keys { + toml::Value::String(keys) => Ok((lib, keys)), + _ => Err(format!("{} is malformed: {lib}", config::env::CRATES)), + }) + .collect::>()?; Ok(Some(Self { + crates, config, output, facade, @@ -132,6 +145,7 @@ impl Callbacks for Export { 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, diff --git a/ffi/src/glue.rs b/ffi/src/glue.rs index 974cff9d7..9f72bbe09 100644 --- a/ffi/src/glue.rs +++ b/ffi/src/glue.rs @@ -46,6 +46,12 @@ fn dependency(krate: &str) -> String { format!("{krate}_export") } +/// The name the crate depends on a crate the facade does not re-export by, apart from the +/// facade's even when they share a name. +fn reached(krate: &str) -> String { + format!("{krate}_reached") +} + /// The name the crate depends on a foreign type's crate by, apart from the facade's even /// when the facade shares that crate's name. fn foreign(krate: &str) -> String { @@ -158,7 +164,18 @@ impl Crate<'_> { ) }) .collect(); - let dependencies = format!("{dependencies}{foreign}"); + // A crate the facade does not re-export, whose types an export names, as the facade + // resolves it, so they are the facade's types. + let reached: String = (api.reached.iter()) + .map(|r| { + format!( + "{} = {{ {}, default-features = false }}\n", + reached(&r.krate), + r.dependency + ) + }) + .collect(); + let dependencies = format!("{dependencies}{foreign}{reached}"); // The facade's oldest toolchain is the crate's, which cargo sets as rustc compiles it, // though no older than the crate's edition needs; cargo checks the value's form. let rust_version = match std::env::var("CARGO_PKG_RUST_VERSION") { @@ -394,9 +411,15 @@ impl Gen<'_> { .unwrap_or_default() } - /// A Rust path of the facade's, through the crate's dependency on it. + /// A Rust path of the facade's, through the crate's dependency on it, or on the crate + /// its second segment names, where the facade does not re-export that crate. fn path(&self, path: &[String]) -> String { - format!("::{}", self.dependency) + &path[1..].iter().map(|s| format!("::{s}")).collect::() + match self.abi.api.reached.iter().find(|r| path.get(1) == Some(&r.krate)) { + Some(r) => { + format!("::{}", reached(&r.krate)) + &path[2..].iter().map(|s| format!("::{s}")).collect::() + } + None => format!("::{}", self.dependency) + &path[1..].iter().map(|s| format!("::{s}")).collect::(), + } } /// An object's Rust type: its lifetimes `'static`, as the handle holds it. diff --git a/ffi/src/ir.rs b/ffi/src/ir.rs index cfb83ff32..2b6ac4df7 100644 --- a/ffi/src/ir.rs +++ b/ffi/src/ir.rs @@ -17,10 +17,22 @@ pub struct Api { pub constants: Vec, /// The crates items belong to, each after every crate it depends on. pub crates: Vec, + /// The crates the facade does not re-export whose types an export names, which the + /// glue depends on directly. + pub reached: Vec, /// The targets it serves, sorted: one for a single target's, several merged. pub targets: Vec, } +/// A crate the glue depends on beside the facade, as the facade resolves it. +#[derive(Clone, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct Reached { + /// Its crate name, its items' second path segment. + pub krate: String, + /// Its dependency's TOML keys, which name the facade's package of it. + pub dependency: String, +} + impl Api { /// Whether an item on `on` is on every target the API serves. pub fn everywhere(&self, on: On) -> bool { diff --git a/ffi/src/merge.rs b/ffi/src/merge.rs index 0905cec95..3ee4b0f03 100644 --- a/ffi/src/merge.rs +++ b/ffi/src/merge.rs @@ -342,6 +342,11 @@ impl Merged { .unwrap_or(self.api.crates.len()); self.api.crates.insert(at, krate.clone()); } + for reached in api.reached { + if !self.api.reached.iter().any(|r| r.krate == reached.krate) { + self.api.reached.push(reached); + } + } for (record, at) in api.records.into_iter().zip(maps.records) { let Some(ours) = self.api.records.get(at) else { self.api.records.push(record); @@ -738,6 +743,7 @@ mod tests { functions: Vec::new(), constants: Vec::new(), crates: ["a", "c"].map(String::from).to_vec(), + reached: Vec::new(), targets: ["x", "y"].map(String::from).to_vec(), }; let Err(cycle) = order_crates(&api) else { diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index 6a4c2fd3f..dc9b1affc 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -1230,7 +1230,7 @@ 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 sealed() -> u32 {\n\tkio::sealed().0\n}\n\npub fn seal() -> kio::Sealed {\n\tkio::sealed()\n}\n", + pub fn seal() -> kio::Sealed {\n\tkio::sealed()\n}\n", ), ( "kio/Cargo.toml", @@ -1245,6 +1245,23 @@ fn unreached_types() { ), ], ); + // The export builds, naming `kio`'s types through its own dependency on `kio`. + std::fs::write(package.join("ffi.toml"), "exclude = [\"seal\"]\n").unwrap(); + let out = package.join("out"); + run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) + .arg("--config") + .arg(package.join("ffi.toml")) + .arg("--out") + .arg(&out) + .env("CARGO_TARGET_DIR", package.join("build"))); + let glue = std::fs::read_to_string(out.join("src/lib.rs")).unwrap(); + assert!(glue.contains("::kio_reached::Pending"), "{glue}"); + run(cargo() + .arg("build") + .arg("--manifest-path") + .arg(out.join("Cargo.toml")) + .env("CARGO_TARGET_DIR", package.join("build"))); + std::fs::write(package.join("ffi.toml"), "").unwrap(); let census = package.join("census"); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) .arg("--config") @@ -1263,7 +1280,7 @@ fn unreached_types() { // `Pending` and `Version` export; `Sealed` alone is refused, though an alias names it. assert!(report.contains("| Types | 2 | 0 |"), "{report}"); assert!( - report.contains("fn `seal` at src/lib.rs:15:1: type not reachable from the crate root `kio::sealed::Sealed`"), + report.contains("fn `seal` at src/lib.rs:11:1: type not reachable from the crate root `kio::sealed::Sealed`"), "{report}" ); assert_eq!(report.matches("not reachable").count(), 3, "{report}"); diff --git a/quest/m1/ffi-refusals/moq-pin.md b/quest/m1/ffi-refusals/moq-pin.md index 160968e41..afe1dfba9 100644 --- a/quest/m1/ffi-refusals/moq-pin.md +++ b/quest/m1/ffi-refusals/moq-pin.md @@ -4,8 +4,8 @@ The moq pin moves to moq's current `main`, whose crates re-export no whole crate, moq's own included. `just ffi census` there lists no whole-crate re-export refusal. Its "type not -reachable from the crate root" refusals are `kio::Pending` and `lite::version::Version`, -which the exporter change below exports, and moq-quic's stats and varint types under moq-tokio's `quic::driver`, +reachable from the crate root" refusals were `kio::Pending` and moq-tokio's `cli::Deprecated`, +which the exporter change below exports, `lite::version::Version`, which no public path names, and moq-quic's stats and varint types under moq-tokio's `quic::driver`, which [moq-dev/rust2#683](https://github.com/moq-dev/rust2/pull/683) drops. At `ffcb7cd9` there were 20 such refusals (18 Guard and Side, and `Version`), and 9 at moq's head on 2026-11-09, measured in [#676](https://github.com/moq-dev/rust2/pull/676). @@ -61,9 +61,11 @@ whose defining path is itself private stays refused (rejected: (b) moq makes bot [moq-dev/rust2#721](https://github.com/moq-dev/rust2/pull/721) made the exporter change: a type a signature names that the root does not reach exports by its shortest public path in its own crate, so `kio::Pending` (defined in kio's private `pollable`) and moq-tokio's -`cli::Deprecated` export. At moq `ba47ea3` the census then lists no such refusal; only -`lite::version::Version`, which no public path names, stays out, as an object no export -returns. +`cli::Deprecated` export, the glue naming them through its own dependency on their crate's +package. At moq `ba47ea3` the census, which ignores `ffi/moq/ffi.toml`'s excludes, then lists +no such refusal; only `lite::version::Version`, which no public path names, stays out, as an +object no export returns. The bump drops the stale `kio` exclude, which would otherwise leave +`kio::Pending` out of the export. Measured on 2026-11-12 at moq's `main` `6936f0a`: `just ffi moq-cpp` fails the export with 36 errors, which the bump fixes in `ffi/moq/ffi.toml` or the exporter: 15 on the foreign From 11d8c73e71d2fd7ee045031752be41af3b94d5d7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 11:46:02 -0800 Subject: [PATCH 04/24] fix(ffi): keep a reached git dependency's reference, its targets, and this host's keys Co-Authored-By: Claude Opus 5.5 --- ffi/src/cli.rs | 14 +++++++++++--- ffi/src/collect.rs | 10 ++-------- ffi/src/driver.rs | 1 + ffi/src/glue.rs | 32 +++++++++++++++++++++++--------- ffi/src/ir.rs | 4 ++-- ffi/src/merge.rs | 9 +++++++-- 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/ffi/src/cli.rs b/ffi/src/cli.rs index 7ddad1964..7761d6afe 100644 --- a/ffi/src/cli.rs +++ b/ffi/src/cli.rs @@ -339,10 +339,18 @@ fn dependency(package: &Package) -> Option { Some("registry+https://github.com/rust-lang/crates.io-index" | "sparse+https://index.crates.io/") => { Some(format!("package = {name:?}, version = \"={}\"", package.version)) } + // By the reference the facade names it by, which is part of its source's identity: + // `?branch=`, `?tag=`, or `?rev=`, or none for the default branch. The lockfile + // pins the commit as the facade's does. Some(git) if git.starts_with("git+") => { - let (url, rev) = git["git+".len()..].split_once('#')?; - let url = url.split('?').next().unwrap_or(url); - Some(format!("package = {name:?}, git = {url:?}, rev = {rev:?}")) + let url = git["git+".len()..].split('#').next().unwrap_or(git); + let (url, reference) = url.split_once('?').unwrap_or((url, "")); + let reference = match reference.split_once('=') { + Some((key @ ("branch" | "tag" | "rev"), value)) => format!(", {key} = {value:?}"), + Some(_) => return None, + None => String::new(), + }; + Some(format!("package = {name:?}, git = {url:?}{reference}")) } Some(_) => None, } diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 89e107e74..e5ad8a9d1 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -1191,10 +1191,9 @@ 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(); if !def_id.is_local() && !self.api.reached.iter().any(|r| r.krate == path[1]) { - let dependency = self.dependency(def_id.krate).expect("a reached crate has a dependency"); self.api.reached.push(crate::ir::Reached { krate: path[1].clone(), - dependency, + targets: self.api.targets.clone(), }); } path.extend(own); @@ -1231,12 +1230,7 @@ impl<'tcx> Collector<'tcx> { let root = tcx.module_children_local(LOCAL_CRATE.as_def_id().expect_local()); self.keys[&def_id.krate] == name.as_str() && !root.iter().any(|child| child.ident.name == name) - && self.dependency(def_id.krate).is_some() - } - - /// The TOML keys of the glue's dependency on `krate`, as the facade resolves it. - fn dependency(&self, krate: CrateNum) -> Option { - self.dependencies.get(self.tcx.crate_name(krate).as_str()).cloned() + && self.dependencies.contains_key(name.as_str()) } /// The shortest public path to `def_id` from its own crate's root, through that crate's diff --git a/ffi/src/driver.rs b/ffi/src/driver.rs index acbff2a7d..93c8f5149 100644 --- a/ffi/src/driver.rs +++ b/ffi/src/driver.rs @@ -302,6 +302,7 @@ impl Export { abi: &abi, facade: &self.facade, patch: &self.patch, + crates: &self.crates, }; glue.write(out) } diff --git a/ffi/src/glue.rs b/ffi/src/glue.rs index 9f72bbe09..1319afaca 100644 --- a/ffi/src/glue.rs +++ b/ffi/src/glue.rs @@ -118,6 +118,9 @@ pub struct Crate<'a> { /// The `[patch]` table the crate's own workspace resolves the exports with, as the /// check did. pub patch: &'a str, + /// The dependency on each crate the facade builds with, by its crate name, as this + /// host resolves it, which a staged API's crates are named by too. + pub crates: &'a std::collections::BTreeMap, } impl Crate<'_> { @@ -166,16 +169,26 @@ impl Crate<'_> { .collect(); // A crate the facade does not re-export, whose types an export names, as the facade // resolves it, so they are the facade's types. - let reached: String = (api.reached.iter()) - .map(|r| { - format!( - "{} = {{ {}, default-features = false }}\n", - reached(&r.krate), - r.dependency - ) - }) + // One only some targets' APIs name builds on those alone, as the facade's does. + let mut every = String::new(); + let mut targeted: std::collections::BTreeMap<&str, String> = Default::default(); + for r in &api.reached { + let Some(keys) = self.crates.get(&r.krate) else { + return Err(format!( + "the facade builds with no crate `{}` here, which the API names", + r.krate + )); + }; + let line = format!("{} = {{ {keys}, default-features = false }}\n", reached(&r.krate)); + match r.targets == api.targets { + true => every.push_str(&line), + false => (r.targets.iter()).for_each(|t| targeted.entry(t).or_default().push_str(&line)), + } + } + let targeted: String = (targeted.into_iter()) + .map(|(target, lines)| format!("[target.{target:?}.dependencies]\n{lines}\n")) .collect(); - let dependencies = format!("{dependencies}{foreign}{reached}"); + let dependencies = format!("{dependencies}{foreign}{every}"); // The facade's oldest toolchain is the crate's, which cargo sets as rustc compiles it, // though no older than the crate's edition needs; cargo checks the value's form. let rust_version = match std::env::var("CARGO_PKG_RUST_VERSION") { @@ -217,6 +230,7 @@ impl Crate<'_> { # What dart/{lib}.dart calls that `dart:ffi` lacks.\n\ dart = []\n\ \n\ + {targeted}\ [workspace]\n\ {patch}", patch = self.patch, diff --git a/ffi/src/ir.rs b/ffi/src/ir.rs index 2b6ac4df7..e9ab45453 100644 --- a/ffi/src/ir.rs +++ b/ffi/src/ir.rs @@ -29,8 +29,8 @@ pub struct Api { pub struct Reached { /// Its crate name, its items' second path segment. pub krate: String, - /// Its dependency's TOML keys, which name the facade's package of it. - pub dependency: String, + /// The targets whose API names its types, sorted. + pub targets: Vec, } impl Api { diff --git a/ffi/src/merge.rs b/ffi/src/merge.rs index 3ee4b0f03..e484262d3 100644 --- a/ffi/src/merge.rs +++ b/ffi/src/merge.rs @@ -343,8 +343,13 @@ impl Merged { self.api.crates.insert(at, krate.clone()); } for reached in api.reached { - if !self.api.reached.iter().any(|r| r.krate == reached.krate) { - self.api.reached.push(reached); + match self.api.reached.iter_mut().find(|r| r.krate == reached.krate) { + Some(ours) => { + ours.targets.extend(reached.targets); + ours.targets.sort(); + ours.targets.dedup(); + } + None => self.api.reached.push(reached), } } for (record, at) in api.records.into_iter().zip(maps.records) { From ab877c5c89d77df88b60081ce462436c0b20c27d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 15:07:37 -0800 Subject: [PATCH 05/24] test(ffi): merge a staged API whose reached crate only the exporting host resolves Co-Authored-By: Claude Opus 5.5 --- ffi/tests/fixtures.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index dc9b1affc..948ced829 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -1261,6 +1261,41 @@ fn unreached_types() { .arg("--manifest-path") .arg(out.join("Cargo.toml")) .env("CARGO_TARGET_DIR", package.join("build"))); + // Staged on another host, with the checkout elsewhere, the merged export depends on the + // 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")) + .args(["--api", staged.to_str().unwrap(), "--target", WASM]) + .env("CARGO_TARGET_DIR", package.join("build"))); + let moved = scratch().join("unreached_types-moved"); + let _ = std::fs::remove_dir_all(&moved); + for dir in ["src", "kio"] { + copy_dir(&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::write( + moved.join("src/lib.rs"), + "pub use kio::Ready;\n\npub fn seal() -> kio::Sealed {\n\tkio::sealed()\n}\n", + ) + .unwrap(); + run(Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) + .arg("--config") + .arg(moved.join("ffi.toml")) + .arg("--out") + .arg(moved.join("out")) + .arg("--with") + .arg(&staged) + .env("CARGO_TARGET_DIR", moved.join("build"))); + let manifest = std::fs::read_to_string(moved.join("out/Cargo.toml")).unwrap(); + assert!( + manifest.contains(&format!("path = \"{}\"", moved.join("kio").display())) + && !manifest.contains(&package.join("kio").display().to_string()), + "{manifest}" + ); std::fs::write(package.join("ffi.toml"), "").unwrap(); let census = package.join("census"); let output = Command::new(env!("CARGO_BIN_EXE_rust2-ffi")) From 9f78c9bfa99c5d6040dc13d49b97daf60cc14570 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 15:54:56 -0800 Subject: [PATCH 06/24] test(ffi): compare the reached path as the manifest escapes it Co-Authored-By: Claude Opus 5.5 --- ffi/tests/fixtures.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index 948ced829..24c0d46e5 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -1292,8 +1292,8 @@ fn unreached_types() { .env("CARGO_TARGET_DIR", moved.join("build"))); let manifest = std::fs::read_to_string(moved.join("out/Cargo.toml")).unwrap(); assert!( - manifest.contains(&format!("path = \"{}\"", moved.join("kio").display())) - && !manifest.contains(&package.join("kio").display().to_string()), + manifest.contains(&format!("path = {:?}", moved.join("kio").display().to_string())) + && !manifest.contains(&format!("{:?}", package.join("kio").display().to_string())), "{manifest}" ); std::fs::write(package.join("ffi.toml"), "").unwrap(); From 19bb1a8f5a6ad47651e297dc24c73c1957e6019f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 17:17:04 -0800 Subject: [PATCH 07/24] chore(quest): claim quest/m1/ffi-refusals/moq-main.md Quest-Claim: 787d5c20b6867bfe From b0feab785aa024ced357ff6a34e67434d1e7fd98 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 19:42:48 -0800 Subject: [PATCH 08/24] wip(ffi): opaque by-value handles, held borrows of eager futures, lent object fields Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/api/src/lib.rs | 40 ++++++- ffi/fixtures/dep/src/lib.rs | 9 ++ ffi/fixtures/reject/src/lib.rs | 13 +-- ffi/fixtures/tls/Cargo.toml | 2 +- ffi/fixtures/tls/src/lib.rs | 28 ++++- ffi/runtime/rt.rs | 74 +++++++++++++ ffi/src/collect.rs | 194 +++++++++++++++++++++++++++------ ffi/src/glue.rs | 72 +++++++++--- ffi/src/ir.rs | 18 ++- 9 files changed, 383 insertions(+), 67 deletions(-) diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index bc0211779..337d7a19f 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -387,10 +387,11 @@ impl Meter { } } -/// Owns a meter it lends. +/// Owns a meter it lends, and one in a field, lent as the method's is. #[derive(Default)] pub struct Meters { first: Meter, + pub last: Meter, } impl Meters { @@ -805,6 +806,16 @@ impl Channel { std::future::ready(()) } + /// Sends `tag` at once, as a function that is not `async` runs when called, and returns a + /// future that borrows this channel and `tag`: what it next receives, after `tag`. + pub fn tagged<'a>(&'a self, tag: &'a str) -> impl Future + 'a { + self.send(Bytes::copy_from_slice(tag.as_bytes())); + async move { + let payload = self.recv().await; + format!("{tag} {}", String::from_utf8_lossy(&payload)) + } + } + /// `recv`'s poll, which does not map: left out, since `recv` exports as a future. pub fn poll_recv(&self, cx: &mut std::task::Context<'_>) -> Poll { let mut state = self.state.lock().unwrap(); @@ -2169,6 +2180,33 @@ pub fn alpn_lent(config: &Arc) -> String { config.alpn().to_string() } +/// A certificate of a crate no export is, by value, as moq-tokio takes rustls's: an opaque +/// handle, which Rust takes back or borrows. +pub fn certify(der: &[u8]) -> tls::Cert { + tls::Cert::new(der) +} + +/// The length of a certificate [`certify`] made, lent. +pub fn cert_len(cert: &tls::Cert) -> usize { + cert.der().len() +} + +/// The bytes of a certificate [`certify`] made, taken back by value. +pub fn cert_der(cert: tls::Cert) -> Vec { + cert.der().to_vec() +} + +/// The total length of a chain of certificates, each taken back by value. +pub fn chain_len(chain: Vec) -> usize { + chain.iter().map(|cert| cert.der().len()).sum() +} + +/// A session of a crate no export is, which no export returns: left out, since C can never +/// hold one. +pub fn handover(session: tls::Session) -> u32 { + session.id +} + /// `text`'s length, or 0 for none: an optional borrow, lent as the borrow alone is. pub fn either(text: Option<&str>) -> usize { text.map_or(0, str::len) diff --git a/ffi/fixtures/dep/src/lib.rs b/ffi/fixtures/dep/src/lib.rs index 8f89b6bf6..2b6dc8902 100644 --- a/ffi/fixtures/dep/src/lib.rs +++ b/ffi/fixtures/dep/src/lib.rs @@ -37,6 +37,15 @@ impl Area { } } +/// A count of this crate that is not `Send`, which the reject fixture takes by value. +pub struct Local(std::rc::Rc); + +impl Local { + pub fn get(&self) -> u32 { + *self.0 + } +} + /// What no build compiles, which a config still names, as it does what one platform builds. #[cfg(any())] pub mod gone {} diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index 71dee9e46..de5078298 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -17,13 +17,6 @@ pub fn generic(value: T) -> T { value } -/// A future that borrows its argument, from a function that runs when called: the export -/// would have to keep the argument alive past the call. -#[allow(clippy::manual_async_fn, reason = "the construct under test")] -pub fn borrowing(name: &str) -> impl Future + '_ { - async move { name.len() } -} - /// An option inside an option, through a `Box`: C has one `None` per option. pub fn nested(value: Option>>) -> bool { value.is_some() @@ -124,9 +117,9 @@ pub struct Size { pub bytes: u64, } -/// Another crate's types, which the facade does not re-export. -pub fn measure(size: dep::Size) -> dep::Area { - dep::Area::new(size) +/// Another crate's type that is not `Send`, which no handle may hold. +pub fn measure(local: dep::Local) -> u32 { + local.get() } /// A generic type, which exports at the instances its exports name. diff --git a/ffi/fixtures/tls/Cargo.toml b/ffi/fixtures/tls/Cargo.toml index c9bfe1869..eca5feda2 100644 --- a/ffi/fixtures/tls/Cargo.toml +++ b/ffi/fixtures/tls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tls-fixture" -description = "A crate the api fixture names behind an Arc but does not re-export, as moq-tokio names rustls" +description = "A crate the api fixture names behind an Arc or by value but does not re-export, as moq-tokio names rustls" version = "0.0.0" edition = "2024" license = "MIT OR Apache-2.0" diff --git a/ffi/fixtures/tls/src/lib.rs b/ffi/fixtures/tls/src/lib.rs index a951ec613..4144cc5ce 100644 --- a/ffi/fixtures/tls/src/lib.rs +++ b/ffi/fixtures/tls/src/lib.rs @@ -1,5 +1,5 @@ -//! A crate the api fixture names behind an `Arc` but does not re-export, as moq-tokio's -//! listener names rustls's server config. +//! A crate the api fixture names behind an `Arc` or by value but does not re-export, as +//! moq-tokio's listener names rustls's server config and certificates. /// A config: an opaque handle wherever the api fixture returns or takes an `Arc` of it. #[derive(Debug)] @@ -16,3 +16,27 @@ impl Config { &self.alpn } } + +/// A certificate: an opaque handle wherever the api fixture takes or returns one by value, +/// as moq-tokio takes rustls's certificates. +#[derive(Clone, Debug)] +pub struct Cert { + der: Vec, +} + +impl Cert { + pub fn new(der: &[u8]) -> Self { + Self { der: der.to_vec() } + } + + pub fn der(&self) -> &[u8] { + &self.der + } +} + +/// A session established elsewhere, which no export of the api fixture returns, as +/// moq-tokio takes a qmux session: C can never hold one. +#[derive(Debug)] +pub struct Session { + pub id: u32, +} diff --git a/ffi/runtime/rt.rs b/ffi/runtime/rt.rs index 4c52657ad..d206d0622 100644 --- a/ffi/runtime/rt.rs +++ b/ffi/runtime/rt.rs @@ -81,6 +81,80 @@ impl Opaque { } } +/// An argument a future borrows, kept in place on the heap until the future is dropped. +pub struct Pinned(std::ptr::NonNull); + +// It owns its `T`, as a `Box` does. +unsafe impl Send for Pinned {} +unsafe impl Sync for Pinned {} + +impl Pinned { + pub fn new(value: T) -> Self { + Self(std::ptr::NonNull::from(Box::leak(Box::new(value)))) + } + + /// The value, lent past this borrow of its holder. + /// + /// # Safety + /// + /// Called once, and the borrow ends before the holder drops, as [`Holding`] ensures. + pub unsafe fn get(&self) -> &'static mut T { + unsafe { &mut *self.0.as_ptr() } + } +} + +impl Drop for Pinned { + fn drop(&mut self) { + drop(unsafe { Box::from_raw(self.0.as_ptr()) }); + } +} + +/// A future and the arguments it borrows, which drop after it: fields drop in order. +pub struct Holding { + future: F, + _held: H, +} + +impl Holding { + pub fn new(future: F, held: H) -> Self { + Self { future, _held: held } + } +} + +impl std::future::Future for Holding { + type Output = F::Output; + + fn poll(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll { + // The future is pinned with its holder and never moves out; the held values are + // never pinned. + unsafe { self.map_unchecked_mut(|holding| &mut holding.future) }.poll(cx) + } +} + +/// Another crate's value, held erased by its handle, which the glue never names. +pub struct Owned(Box); + +impl Owned { + pub fn new(value: T) -> Self { + Self(Box::new(value)) + } + + /// The value it holds, lent. + pub fn get(&self, what: &str) -> &T { + (self.0.downcast_ref()).unwrap_or_else(|| fail(what, "an opaque handle holds another type")) + } + + /// The value it holds, lent exclusively. + pub fn get_mut(&mut self, what: &str) -> &mut T { + (self.0.downcast_mut()).unwrap_or_else(|| fail(what, "an opaque handle holds another type")) + } + + /// The value it holds, taken back. + pub fn take(self, what: &str) -> T { + *(self.0.downcast()).unwrap_or_else(|_| fail(what, "an opaque handle holds another type")) + } +} + /// Bytes across the ABI. Passed in, a view Rust copies or borrows for the call and never /// frees. Returned, an owned buffer the caller frees once. A null `ptr` is `None`. #[repr(C)] diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 9b40f7065..c6041d383 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -29,7 +29,7 @@ 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, Home, Int, Literal, + Access, Api, Callback, Closure, Collection, Constant, Dyn, Enum, Family, Field, Function, Held, Home, Int, Literal, Mutability, Object, On, Param, Path, Receiver, Record, Task, TaskKind, Traits, Type, Variant, }; @@ -53,6 +53,10 @@ const FOREIGN: [(&str, &str, &str); 3] = [ ("std", "Instant", "Instant"), ]; +/// The construct of another crate's type named both by value and in an `Arc`, whose handle +/// holds the `Arc`. +const BOTH: &str = "another crate's type both by value and in an Arc"; + /// The construct of an instance inference missed: a bug in the exporter, not the crate. pub const NOT_INFERRED: &str = "instance not inferred"; @@ -200,9 +204,15 @@ struct Collector<'tcx> { /// The standard library's crates, `core`, `alloc`, and `std`, known by what each /// defines, since the facade or another crate may share their names. sysroot: Vec, - /// Each type in [`FOREIGN`] that some crate builds with and no export is, and the - /// object it exports as. + /// Each type in [`FOREIGN`] that some crate builds with and no export is, and each other + /// crate's type a signature names behind an `Arc` or by value, and the object it exports as. foreign: Vec<(DefId, usize)>, + /// The types of [`Self::foreign`] signatures name by value, which their handles hold + /// rather than an `Arc` of them. + owned: Vec, + /// Types signatures name both by value and behind an `Arc`: their handles hold the `Arc`, + /// so the value is refused. + both: Vec, /// `tracing::Level`, where some crate builds with it and no export is it. level: Option, /// `std::ops::Bound`, and `std::ops::RangeBounds`, which names it. @@ -323,6 +333,8 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx>, facade: &Facade<'_>) -> Collected { json_map, sysroot: sysroot.clone(), foreign: Vec::new(), + owned: Vec::new(), + both: Vec::new(), level: None, bound, range_bounds, @@ -757,12 +769,10 @@ impl<'tcx> Collector<'tcx> { .filter_map(|arg| arg.as_type()) .filter(|&ty| seen.insert(ty)) .collect(); + for ty in candidates.iter().chain(&named) { + self.held_forms(*ty); + } for ty in types { - if let Some(inner) = self.opaque_arc(ty) - && !self.foreign.iter().any(|&(other, _)| other == inner) - { - self.foreign.push((inner, 0)); - } match self.admit(ty) { Some((key, Ok(site))) if !self.instances.iter().any(|other| other.key == key) => { self.instances.push(site) @@ -801,6 +811,58 @@ impl<'tcx> Collector<'tcx> { .then_some(did) } + /// The type a handle holds by value, if it exports as an opaque handle: as + /// [`Self::opaque_arc`]'s, a type of a crate no export is, taking no type parameters, and + /// `Send` and `Sync`, but not an iterator. Its lifetimes are `'static`, as an object's are. + fn opaque_value(&self, ty: Ty<'tcx>) -> Option { + let ty::Adt(adt, args) = ty.kind() else { return None }; + let did = adt.did(); + let mapped = Some(did) == self.bytes || Some(did) == self.json_map || !self.opaque(did); + let held = !self.exported(did.krate) && !self.sysroot.contains(&did.krate) && !mapped; + // Each lifetime is `'static` in the export, as an object's is. + let erasable = args.iter().all(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(_))); + // Asked of a signature's type, whose lifetimes may be bound by it. + let ty = ty::fold_regions(self.tcx, ty, |_, _| self.tcx.lifetimes.re_erased); + // An iterator crosses as the array of its items instead. + let iterator = implements(self.tcx, ty, did, sym::Iterator); + (held && erasable && !iterator && self.is_send(ty, TypingEnv::fully_monomorphized()) && self.is_sync(ty)) + .then_some(did) + } + + /// Whether `ty` is another crate's type that an opaque handle holds, by value or behind + /// an `Arc`. + fn is_opaque(&self, ty: Ty<'tcx>) -> bool { + self.opaque_arc(ty).is_some() || self.opaque_value(ty).is_some() + } + + /// Record each other crate's type `ty` names behind an `Arc` or by value, which an + /// opaque handle holds: an `Arc`'s type is not also by value. + fn held_forms(&mut self, ty: Ty<'tcx>) { + let mut walker = ty.walk(); + while let Some(arg) = walker.next() { + let Some(ty) = arg.as_type() else { continue }; + let (did, owned) = match (self.opaque_arc(ty), self.opaque_value(ty)) { + (Some(did), _) => (did, false), + (None, Some(did)) => (did, true), + (None, None) => continue, + }; + walker.skip_current_subtree(); + match self.foreign.iter().any(|&(other, _)| other == did) { + false => { + self.foreign.push((did, 0)); + if owned { + self.owned.push(did); + } + } + true if self.owned.contains(&did) != owned && !self.both.contains(&did) => { + self.owned.retain(|&other| other != did); + self.both.push(did); + } + true => {} + } + } + } + /// Whether a foreign type exports as an opaque handle rather than by its role in /// [`FOREIGN`]. fn opaque(&self, did: DefId) -> bool { @@ -928,8 +990,8 @@ impl<'tcx> Collector<'tcx> { Some(shown) } - /// Each type a function's signature names at `args`, normalized, with what a returned - /// future resolves to. A type holding a foreign future names no instance: the future + /// Each type a function's signature names at `args`, normalized, a returned future's + /// being what it resolves to. A type holding a foreign future names no instance: the future /// that holds it, as `Timeout` does, is polled, never a handle. fn spelled(&self, def_id: DefId, args: ty::GenericArgsRef<'tcx>) -> Vec> { let tcx = self.tcx; @@ -940,8 +1002,10 @@ impl<'tcx> Collector<'tcx> { }; let sig = tcx.fn_sig(def_id).instantiate(tcx, args).skip_norm_wip(); let sig = tcx.instantiate_bound_regions_with_erased(sig); - let output = self.future_output(normalize(sig.output()), env); - (sig.inputs_and_output.iter().chain(output)) + // A returned future exports as what it resolves to, never as a handle, so the type + // of the future itself, such as a closure's, names nothing. + let output = self.future_output(normalize(sig.output()), env).unwrap_or(sig.output()); + (sig.inputs().iter().copied().chain([output])) .map(normalize) .flat_map(|ty| ty.walk()) .filter_map(|arg| arg.as_type()) @@ -1378,7 +1442,7 @@ impl<'tcx> Collector<'tcx> { methods: Vec::new(), traits: Traits::default(), foreign: false, - opaque: false, + opaque: None, }); } Decl::Callback(i) => { @@ -1455,6 +1519,17 @@ impl<'tcx> Collector<'tcx> { let krate = tcx.crate_name(def_id.krate); let name = tcx.item_name(def_id); if self.opaque(def_id) { + let owned = self.owned.contains(&def_id); + let docs = match owned { + true => format!( + "`{}`: a handle to another crate's value, which Rust takes back or borrows, with none of its API.", + tcx.def_path_str(def_id) + ), + false => format!( + "`Arc<{}>`: a handle to another crate's value, which Rust takes back, with none of its API.", + tcx.def_path_str(def_id) + ), + }; return Object { path: vec![krate.to_string(), name.to_string()], home: Home { @@ -1465,21 +1540,23 @@ impl<'tcx> Collector<'tcx> { args: Vec::new(), span, on: On::ALL, - docs: format!( - "`Arc<{}>`: a handle to another crate's value, which Rust takes back, with none of its API.", - tcx.def_path_str(def_id) - ), + docs, sync: true, copy: false, - shared: true, + // A held value is moved out of its handle, as an object of the crate's is, and + // its clone is no part of the API. + shared: !owned, lifetimes: 0, methods: Vec::new(), traits: Traits { - clone: true, + clone: !owned, ..Traits::default() }, foreign: true, - opaque: true, + opaque: Some(match owned { + true => Held::Value, + false => Held::Arc, + }), }; } let role = (FOREIGN.iter()) @@ -1514,6 +1591,7 @@ impl<'tcx> Collector<'tcx> { err: Some(Type::String), future: false, eager: false, + holds: false, task: None, collect: false, lends: false, @@ -1562,6 +1640,7 @@ impl<'tcx> Collector<'tcx> { err: None, future: false, eager: false, + holds: false, task: None, collect: false, lends: false, @@ -1597,7 +1676,7 @@ impl<'tcx> Collector<'tcx> { methods, traits, foreign: true, - opaque: false, + opaque: None, } } @@ -1736,12 +1815,16 @@ impl<'tcx> Collector<'tcx> { held[i] = true; } } - self.decls - .iter() + // Another crate's type an opaque handle holds, as each object of the crate's. + let opaque = (self.foreign.iter()) + .filter(|&&(_, i)| api.objects[i].opaque.is_some() && !held[i]) + .map(|&(def_id, _)| Key { def_id, args: None }); + (self.decls.iter()) .filter_map(|(&key, decl)| match decl { Decl::Object(i) if !held[*i] => Some(key), _ => None, }) + .chain(opaque) .collect() } @@ -2084,8 +2167,14 @@ impl<'tcx> Collector<'tcx> { // 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); + // 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. + let lends = !self.is_clone(ty) + && matches!(ty.kind(), ty::Adt(adt, args) if matches!(self.decl(adt.did(), args), Some(Decl::Object(_)))); let mapped = { + self.lending.set(lends); let get = self.ty(read, Pos::Return); + 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) { @@ -2124,6 +2213,7 @@ impl<'tcx> Collector<'tcx> { err: None, future: false, eager: false, + holds: false, task: None, collect: false, lends: false, @@ -2131,7 +2221,11 @@ impl<'tcx> Collector<'tcx> { instance: None, home: Home::default(), }; - accessors.push(accessor(Receiver::Ref, Vec::new(), get, false)); + let lent = lends + && matches!(&get, Type::Ref(Mutability::Not, inner) if matches!(**inner, Type::Object(_))); + 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, @@ -2381,11 +2475,13 @@ impl<'tcx> Collector<'tcx> { Err(why) => return vec![(Err(why), shown.clone(), false)], }; let mut functions = Vec::new(); + if shown.iter().any(|s| s.contains("connect_with")) { eprintln!("DEBUG {shown:?} instances {}", instances.len()); } for instance in &instances { let Some(shown) = self.shown(shown, instance) else { continue; }; let function = self.function(def_id, path.clone(), shown.clone(), self_ty, instance); + if shown.iter().any(|s| s.contains("connect_with")) { eprintln!("DEBUG fn {:?} {:?}", function.as_ref().err().map(|w| w.len()), function.as_ref().ok().map(|f| (f.params.iter().map(|p| format!("{:?}", p.ty)).collect::>(), f.on.clone()))); } functions.push((function, shown, !instance.named.is_empty())); } functions @@ -2679,10 +2775,6 @@ impl<'tcx> Collector<'tcx> { if !self.is_send(output, kept) { errs.push(why("future not Send", "")); } - // Called at once, the future must outlive the arguments the call borrowed. - if eager && borrows { - errs.push(why("borrowing future from a function that is not async", "")); - } output = normalize(inner); future = true; } @@ -2722,11 +2814,12 @@ impl<'tcx> Collector<'tcx> { let error = args.type_at(1); // Another crate's error, such as `anyhow::Error` or `io::Error`, crosses as // its message, as an exported error's `Display` already reads. + let foreign = |mapped: &Result| match mapped { + Err(why) => why.construct == "foreign type" || why.construct == BOTH, + Ok(_) => self.opaque_value(error).is_some(), + }; let err = match self.ty(error, Pos::Return) { - Err(why) - if why.construct == "foreign type" - && implements(tcx, error, def_id, rustc_span::sym::Display) => - { + err if foreign(&err) && implements(tcx, error, def_id, rustc_span::sym::Display) => { Ok(Type::String) } err => err, @@ -2764,6 +2857,7 @@ impl<'tcx> Collector<'tcx> { err, future, eager: future && eager, + holds: future && eager && borrows, task, collect, lends, @@ -3490,12 +3584,12 @@ impl<'tcx> Collector<'tcx> { } match self.ty(input, Pos::Param) { // An object is lent as a handle for the call, but an opaque one, whose - // handle holds no `Arc` to lend; so is a `Copy` one taken by value, which C + // handle holds its value erased, has none to lend; so is a `Copy` one taken by value, which C // copies to keep. Ok(ty) if foreign_arg(&ty) || matches!(&ty, Type::Ref(_, inner) if matches!(**inner, Type::Object(_))) - && !matches!(input.kind(), ty::Ref(_, inner, _) if self.opaque_arc(*inner).is_some()) + && !matches!(input.kind(), ty::Ref(_, inner, _) if self.is_opaque(*inner)) || copied(input, &ty) => { params.push(ty) @@ -3985,7 +4079,10 @@ impl<'tcx> Collector<'tcx> { for ty in ty.walk().filter_map(|arg| arg.as_type()) { match ty.kind() { ty::Ref(region, ..) => lent.push(*region), - ty::Adt(adt, args) if matches!(self.decl(adt.did(), args), Some(Decl::Object(_))) => { + ty::Adt(adt, args) + if matches!(self.decl(adt.did(), args), Some(Decl::Object(_))) + || self.opaque_value(ty).is_some() => + { held.extend(args.regions()) } // An `impl Future` holds what its bounds name, as an `async fn` its output. @@ -4265,6 +4362,7 @@ impl<'tcx> Collector<'tcx> { err: None, future: false, eager: false, + holds: false, task: None, collect: false, lends: false, @@ -4542,6 +4640,14 @@ impl<'tcx> Collector<'tcx> { _ => match (self.opaque_arc(ty)) .and_then(|inner| self.foreign.iter().find(|&&(other, _)| other == inner)) { + Some(&(did, _)) + if self.orphans.contains(&Key { + def_id: did, + args: None, + }) => + { + return Err(why("type C never holds", inner.to_string())); + } Some(_) if pos == Pos::Field => { return Err(why("object in a value", inner.to_string())); } @@ -4549,6 +4655,24 @@ impl<'tcx> Collector<'tcx> { None => return Err(why("Arc", strip_args(tcx, did))), }, } + } else if let Some(did) = self.opaque_value(ty) + && let Some(&(_, i)) = self.foreign.iter().find(|&&(other, _)| other == did) + { + // Held by value, as a handle with none of its API, which Rust takes back + // or borrows. + if self.both.contains(&did) { + return Err(why(BOTH, strip_args(tcx, did))); + } + if self.orphans.contains(&Key { + def_id: did, + args: None, + }) { + return Err(why("type C never holds", strip_args(tcx, did))); + } + match pos { + Pos::Field => return Err(why("object in a value", strip_args(tcx, did))), + _ => Type::Object(i), + } } else if !self.exported(did.krate) { return Err(why("foreign type", strip_args(tcx, did))); } else { diff --git a/ffi/src/glue.rs b/ffi/src/glue.rs index a392e00ee..f2e0d41fa 100644 --- a/ffi/src/glue.rs +++ b/ffi/src/glue.rs @@ -11,7 +11,8 @@ use std::path::Path; use crate::abi::{self, Abi, CFG, Ty}; use crate::config::Package; use crate::ir::{ - Access, Closure, Collection, Family, Function, Literal, Mutability, On, Receiver, Task, TaskKind, Traits, Type, + Access, Closure, Collection, Family, Function, Held, Literal, Mutability, On, Receiver, Task, TaskKind, Traits, + Type, }; const RUNTIME: &str = include_str!("../runtime/rt.rs"); @@ -488,7 +489,10 @@ impl Gen<'_> { Type::Record(i) => generic(&api.records[*i].path, 0, &api.records[*i].args), Type::Enum(i) if api.enums[*i].foreign => foreign_path(&api.enums[*i].path), Type::Enum(i) => generic(&api.enums[*i].path, 0, &api.enums[*i].args), - Type::Object(i) if api.objects[*i].opaque => "rt::Opaque".to_string(), + Type::Object(i) if let Some(held) = api.objects[*i].opaque => match held { + Held::Arc => "rt::Opaque".to_string(), + Held::Value => "rt::Owned".to_string(), + }, Type::Object(i) if api.objects[*i].foreign => foreign_path(&api.objects[*i].path), Type::Object(i) => generic(&api.objects[*i].path, api.objects[*i].lifetimes, &api.objects[*i].args), // A negative argument is an expression, which Rust takes only in braces. @@ -547,9 +551,10 @@ impl Gen<'_> { true => format!("lift_{}({e}, w)", self.abi.enumeration(*i)), false => format!("lift_{}(&{e}, w)", self.abi.enumeration(*i)), }, - Type::Object(i) if self.abi.api.objects[*i].opaque => { - format!("unsafe {{ rt::Object::::take({e}, w) }}.arc(w)") - } + Type::Object(i) if let Some(held) = self.abi.api.objects[*i].opaque => match held { + Held::Arc => format!("unsafe {{ rt::Object::::take({e}, w) }}.arc(w)"), + Held::Value => format!("unsafe {{ rt::Object::::take({e}, w) }}.take(w)"), + }, Type::Object(i) => match self.abi.api.objects[*i].copy { true => format!( "*unsafe {{ rt::Object::<{}>::{}({e}, w) }}", @@ -731,7 +736,10 @@ impl Gen<'_> { }, Type::Record(i) => format!("lower_{}({e})", self.abi.record(*i)), Type::Enum(i) => format!("lower_{}({e})", self.abi.enumeration(*i)), - Type::Object(i) if self.abi.api.objects[*i].opaque => format!("rt::Object::new(rt::Opaque::new({e}))"), + Type::Object(i) if let Some(held) = self.abi.api.objects[*i].opaque => match held { + Held::Arc => format!("rt::Object::new(rt::Opaque::new({e}))"), + Held::Value => format!("rt::Object::new(rt::Owned::new({e}))"), + }, Type::Object(_) => format!("rt::Object::new({e})"), Type::Callback(..) | Type::Closure(..) => unreachable!("a callback is never returned"), Type::Waker => format!("rt::Waker::lower({e})"), @@ -1336,9 +1344,10 @@ impl Gen<'_> { (Type::Object(i), _, _) => { let (binding, borrow) = self.borrow(*i, *m, c, future); let pass = match (m, self.abi.api.objects[*i].opaque) { - (Mutability::Not, true) => format!("{local}.get(w)"), - (Mutability::Mut, _) => format!("&mut *{local}"), - (Mutability::Not, false) => format!("&*{local}"), + (Mutability::Not, Some(_)) => format!("{local}.get(w)"), + (Mutability::Mut, Some(_)) => format!("{local}.get_mut(w)"), + (Mutability::Mut, None) => format!("&mut *{local}"), + (Mutability::Not, None) => format!("&*{local}"), }; (format!("{binding} {local} = {borrow};"), pass) } @@ -1364,9 +1373,10 @@ impl Gen<'_> { (Type::Object(i), _) => { let (binding, borrow) = self.borrow(*i, *m, c, future); let pass = match (m, self.abi.api.objects[*i].opaque) { - (Mutability::Not, true) => format!("{local}.as_deref().map(|v| v.get(w))"), - (Mutability::Mut, _) => format!("{local}.as_deref_mut()"), - (Mutability::Not, false) => format!("{local}.as_deref()"), + (Mutability::Not, Some(_)) => format!("{local}.as_deref().map(|v| v.get(w))"), + (Mutability::Mut, Some(_)) => format!("{local}.as_deref_mut().map(|v| v.get_mut(w))"), + (Mutability::Mut, None) => format!("{local}.as_deref_mut()"), + (Mutability::Not, None) => format!("{local}.as_deref()"), }; ( format!("{binding} {local} = if {c}.is_null() {{ None }} else {{ Some({borrow}) }};"), @@ -1489,8 +1499,11 @@ impl Gen<'_> { fn function_on(&mut self, function: &Function, owner: Option<(&Ty, Type)>) { let export = self.abi.export(function, owner.as_ref().map(|(ty, _)| *ty)); let name = export.call.name.clone(); - // An eager call borrows its arguments only for the call, as a synchronous one does. - let future = function.future && !function.eager; + // An eager call borrows its arguments only for the call, as a synchronous one does, + // unless the future it returns borrows them: it then owns them, as an `async fn`'s + // future does, and holds each it lends in place until the future is dropped. + let future = function.future && (!function.eager || function.holds); + let mut held = Vec::new(); let mut stmts = Vec::new(); let mut args = Vec::new(); let mut params = Vec::new(); @@ -1509,8 +1522,14 @@ impl Gen<'_> { let (stmt, arg) = self.arg(&ty, "this", "a_self", future); stmts.push(stmt); args.push(arg); + if function.holds && *receiver != Receiver::Owned { + held.push("a_self".to_string()); + } } value => { + if function.holds && *receiver != Receiver::Owned { + held.push("a_self".to_string()); + } stmts.push(format!("let a_self = {};", self.lift(value, "unsafe { *this }"))); args.push(match receiver { Receiver::Owned => "a_self".to_string(), @@ -1565,11 +1584,27 @@ impl Gen<'_> { format!("let mut a{n} = p{n}.lift(w);"), format!("::std::pin::Pin::new(&mut a{n})"), ), - _ => self.arg(¶m.ty, &format!("p{n}"), &format!("a{n}"), future), + _ => { + let lent = match ¶m.ty { + Type::Option(inner) => matches!(**inner, Type::Ref(..)), + ty => matches!(ty, Type::Ref(..)), + }; + if function.holds && lent { + held.push(format!("a{n}")); + } + self.arg(¶m.ty, &format!("p{n}"), &format!("a{n}"), future) + } }; stmts.push(stmt); args.push(arg); } + // Each owned argument the call lends moves to the heap, where it stays while the + // future borrows it. + for local in &held { + stmts.push(format!( + "let {local}_held = rt::Pinned::new({local});\n\tlet {local} = unsafe {{ {local}_held.get() }};" + )); + } // A future made of a `Poll` calls the function at each poll, passing the poll's // context, or a value made from its waker and kept until the next poll, so what that // poll registers stays registered. @@ -1651,6 +1686,13 @@ impl Gen<'_> { // A function that is not `async` runs when called, and what it returns // borrows nothing, so it is called now; an `async fn` runs when polled. let (now, later) = match (function.eager, &function.task) { + (true, _) if function.holds => { + let held: String = held.iter().map(|local| format!("{local}_held, ")).collect(); + ( + format!("\n\tlet future = rt::Holding::new({call}, ({held}));"), + "future".to_string(), + ) + } (true, _) => (format!("\n\tlet future = {call};"), "future".to_string()), (false, None) => (String::new(), call), (false, Some(task)) => { diff --git a/ffi/src/ir.rs b/ffi/src/ir.rs index 52f8cffdb..05353b421 100644 --- a/ffi/src/ir.rs +++ b/ffi/src/ir.rs @@ -214,9 +214,18 @@ pub struct Object { /// Whether it is a foreign type, such as `url::Url`, that the facade maps rather than /// exports: its path is the type's in its own crate, not in the facade. pub foreign: bool, - /// Whether it is a foreign type behind an `Arc`, held erased, which the glue never - /// names: a handle with none of its API, which Rust takes back as the `Arc`. - pub opaque: bool, + /// What its handle holds of another crate's type, held erased, which the glue never + /// names: a handle with none of its API. + pub opaque: Option, +} + +/// What an opaque handle holds of another crate's type. +#[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)] +pub enum Held { + /// An `Arc` of it, which Rust takes back as the `Arc`, and clones share. + Arc, + /// The value itself, which Rust takes back by value or borrows. + Value, } /// A `pub` trait: implemented by the foreign side, through a table of functions. @@ -270,6 +279,9 @@ pub struct Function { /// For a future, whether the call itself runs code, as a function that is not /// `async` returning one does: the export calls it at once, and polls what it returns. pub eager: bool, + /// For an eager future, whether what it returns borrows its arguments: the export owns + /// them, as it does an `async fn`'s, and keeps them until the future is dropped. + pub holds: bool, /// The parameter it polls its task through, if any: C passes a waker for it or, for a /// future made of a returned `Poll`, the future's poll supplies it. pub task: Option, From a67125c7380c6bb8da413e432483a912f9dd7304 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 21:35:09 -0800 Subject: [PATCH 09/24] feat(ffi): another crate's value as an opaque handle, held borrows of eager futures, lent object fields Co-Authored-By: Claude Opus 5.5 --- ffi/Cargo.lock | 1 + ffi/README.md | 5 +- ffi/fixtures/api/examples/transcript.rs | 15 ++ ffi/fixtures/dep/src/lib.rs | 9 - ffi/fixtures/reject/Cargo.toml | 1 + ffi/fixtures/reject/expected.txt | 227 ++++++++++++------------ ffi/fixtures/reject/src/lib.rs | 2 +- ffi/fixtures/tls/src/lib.rs | 9 + ffi/justfile | 8 +- ffi/src/collect.rs | 2 - ffi/src/glue.rs | 10 +- ffi/tests/api.c | 23 ++- ffi/tests/api.cpp | 17 ++ ffi/tests/api.dart | 9 + ffi/tests/api.go | 9 + ffi/tests/api.kt | 9 + ffi/tests/api.py | 7 + ffi/tests/api.swift | 12 ++ ffi/tests/fixtures.rs | 1 + quest/m1/ffi-refusals/README.md | 8 +- quest/m1/ffi-refusals/moq-excluded.md | 36 ++++ quest/m1/ffi-refusals/moq-main.md | 28 --- quest/m1/ffi-refusals/moq-pin.md | 1 - quest/m1/ffi-refusals/no-config.md | 1 + 24 files changed, 286 insertions(+), 164 deletions(-) create mode 100644 quest/m1/ffi-refusals/moq-excluded.md delete mode 100644 quest/m1/ffi-refusals/moq-main.md diff --git a/ffi/Cargo.lock b/ffi/Cargo.lock index e53575e96..0fdd49e25 100644 --- a/ffi/Cargo.lock +++ b/ffi/Cargo.lock @@ -239,6 +239,7 @@ name = "reject-fixture" version = "0.0.0" dependencies = [ "dep-fixture", + "tls-fixture", ] [[package]] diff --git a/ffi/README.md b/ffi/README.md index 60386f2f6..8e6a99207 100644 --- a/ffi/README.md +++ b/ffi/README.md @@ -84,7 +84,7 @@ re-exports its items instead, which export. A type no path reaches is refused. | `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 returned tuple `(A, B)` | one out pointer each: `void f(..., A *out0, B *out1)` | | a tuple inside another type, or as a field or parameter | `_tuple__`: a struct of fields `_0`, `_1`, and so on; of references only returned | -| `async fn`, or a return that implements `Future` | a future: `f` makes it, `f_poll` polls it, `f_future_free` drops it; a function that is not `async` runs at the call, as in Rust | +| `async fn`, or a return that implements `Future` | a future: `f` makes it, `f_poll` polls it, `f_future_free` drops it; a function that is not `async` runs at the call, as in Rust, and when its future borrows the arguments, the future owns them as an `async fn`'s does, holding each in place until it drops | | a function returning `Poll` that polls through a `&Context`, a `&mut Context`, or a reference to an object exactly one associated function makes from a `Waker` alone, of a type with no generic parameters, such as kio's `Waiter`, which may be the method's own `&self`, as `Waiter::poll_future`'s is | a future of `T`, as an `async fn`'s: each poll calls the function again with the poll's context, or with an object made from its waker and kept until the next poll, so what it registers stays registered; each other parameter taken by value must be `Copy`; a method polling through its own `&self` is a function without one | | `poll_x`, when `x` exports as a future | left out: the future is its poll | | `bool`, integers but 128-bit, floats, `char` | `bool`, `` types, `float`, `double`, a `uint32_t` code point | @@ -96,6 +96,7 @@ re-exports its items instead, which export. A type no path reaches is refused. | `SocketAddr`, `SocketAddrV4`, `SocketAddrV6` | `_socket_addr`: its IP's bytes, port, and whether it is IPv6; one of the other family passed to `V4` or `V6` aborts | | `url::Url` | an object `_Url`, made by `_Url_parse`, which fails with the parse error's message, and printed by `_to_string` | | `Arc` of another crate's `Send` and `Sync` type that no other rule maps, such as `Arc` | an opaque object named by `T`'s crate and name, such as `_rustls_ServerConfig`, with `_clone` and `_free` and none of `T`'s API: it only passes back to Rust | +| another crate's `Send` and `Sync` type taken or returned by value or lent, with no type parameters, that no other rule maps and that is no iterator, such as `rustls_pki_types::CertificateDer<'static>` | an opaque object named as the `Arc` form is, with `_free` and none of `T`'s API, holding the value: Rust takes it back by value, or borrows it; a type also named behind an `Arc` is that form, and refused by value | | `std::time::Instant` | an object `_Instant`, which only Rust makes, copied into each call that takes it and compared by `_eq`, with none of its methods | | `tracing::Level` | `_Level`: a C enum of its five levels, `TRACE` to `ERROR` | | `tracing::level_filters::LevelFilter` | `Option`, whose `None` is `OFF` | @@ -133,7 +134,7 @@ A record or enum holds only values and `Copy` handles: one with a field that doe 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: that one, if not `Clone`, is a lent handle, which holds its receiver and checks it +alone, or an object's `pub` field holds: 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 diff --git a/ffi/fixtures/api/examples/transcript.rs b/ffi/fixtures/api/examples/transcript.rs index f273a3cde..ccbd8d5ea 100644 --- a/ffi/fixtures/api/examples/transcript.rs +++ b/ffi/fixtures/api/examples/transcript.rs @@ -360,6 +360,11 @@ fn main() { if let Poll::Ready(payload) = recv.as_mut().poll(&mut cx) { println!("recv {}", String::from_utf8_lossy(&payload)); } + // The send happens at the call, and the future borrows the channel and the tag. + let mut tagged = pin!(channel.tagged("tag")); + if let Poll::Ready(text) = tagged.as_mut().poll(&mut cx) { + println!("tagged {text}"); + } channel.send(Bytes::from_static(b"sized")); let mut sized = pin!(channel.recv_sized()); if let Poll::Ready((payload, len)) = sized.as_mut().poll(&mut cx) { @@ -583,12 +588,22 @@ fn main() { println!("nudge {} {}", point.x, point.y); let config = api::secure("h3"); println!("secure {} {}", api::alpn_lent(&config), api::alpn(config.clone())); + let cert = api::certify(b"der"); + let chain = vec![api::certify(b"a"), api::certify(b"bc")]; + println!( + "cert {} {} {}", + api::cert_len(&cert), + String::from_utf8_lossy(&api::cert_der(cert)), + api::chain_len(chain) + ); let mut meters = api::Meters::new(); let first = meters.first(); first.add(2); println!("lent {} {}", first.add(3), meters.first().count()); meters.clear(); println!("cleared {}", meters.first().count()); + meters.last.add(4); + println!("field lent {}", meters.last.add(1)); let tallies = api::Tallies::new(); tallies.first().bump(); println!("tallied {}", tallies.first().bump()); diff --git a/ffi/fixtures/dep/src/lib.rs b/ffi/fixtures/dep/src/lib.rs index 2b6dc8902..8f89b6bf6 100644 --- a/ffi/fixtures/dep/src/lib.rs +++ b/ffi/fixtures/dep/src/lib.rs @@ -37,15 +37,6 @@ impl Area { } } -/// A count of this crate that is not `Send`, which the reject fixture takes by value. -pub struct Local(std::rc::Rc); - -impl Local { - pub fn get(&self) -> u32 { - *self.0 - } -} - /// What no build compiles, which a config still names, as it does what one platform builds. #[cfg(any())] pub mod gone {} diff --git a/ffi/fixtures/reject/Cargo.toml b/ffi/fixtures/reject/Cargo.toml index 9a922c57d..5c7b998e0 100644 --- a/ffi/fixtures/reject/Cargo.toml +++ b/ffi/fixtures/reject/Cargo.toml @@ -12,6 +12,7 @@ name = "reject" [dependencies] dep-fixture = { path = "../dep" } +tls-fixture = { path = "../tls" } [lints] workspace = true diff --git a/ffi/fixtures/reject/expected.txt b/ffi/fixtures/reject/expected.txt index f707b0c4d..380368c69 100644 --- a/ffi/fixtures/reject/expected.txt +++ b/ffi/fixtures/reject/expected.txt @@ -1,119 +1,118 @@ -fixtures/reject/src/lib.rs:106: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:112:1: rust2-ffi: cannot export fn `forever`: 'static borrow `&'static [u8]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:118:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:105:1: rust2-ffi: cannot export fn `forever`: 'static borrow `&'static [u8]`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:111:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:11:1: rust2-ffi: cannot export fn `map`: foreign type `std::collections::HashMap`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:128:1: rust2-ffi: cannot export fn `measure`: foreign type `dep::Size`; foreign type `dep::Area`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:133: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:143: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:162: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:121:1: rust2-ffi: cannot export fn `measure`: foreign type `tls::Local`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:126: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:136: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:155: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:166: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:169: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: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:173: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:176: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:187: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:196: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:207:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:212:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:217: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:222: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:225: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:230: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:233: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:23:1: rust2-ffi: cannot export fn `borrowing`: borrowing future from a function that is not async; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:241:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:251: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:256: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:261: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:266: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:271: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:276: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:281: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:287: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:28: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:293: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:298: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:303: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:308: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:313: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:318: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:330: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:345: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:350: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:355: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:369: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:37: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:383: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:398: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:413: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:42:1: rust2-ffi: cannot export static `COUNT`: static; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:436: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:451:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:443:1: note: applies past the recursion limit -fixtures/reject/src/lib.rs:46:1: rust2-ffi: cannot export macro `noop`: macro; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:481: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:458:1: note: `std::string::String` converts too, which C passes alike -fixtures/reject/src/lib.rs:486:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:491: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:496: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:501: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:506: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:532: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:537: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:511:1: note: C cannot implement `Source`: callback signature `items` -fixtures/reject/src/lib.rs:542:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:547: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:547:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:54:1: rust2-ffi: cannot export fn `excluded`: excluded type `Excluded`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:554: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:554:20: note: `'b` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:561: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:561:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:570:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:576: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:582: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:599: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:59:1: rust2-ffi: cannot export fn `letters`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:616: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:639: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:653: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:658: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:665: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:671: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:676: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:681: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:180: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:189: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:200:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:205:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:210: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:215: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:218: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: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:223: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:226: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:234:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:244: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:249: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:254: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:259: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:264: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:269: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:274: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:280: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:286: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:291: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:296: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:301: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:306: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: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:311: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:323: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:338: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:343: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:348: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:35:1: rust2-ffi: cannot export static `COUNT`: static; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:362: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:376: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:391: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:39:1: rust2-ffi: cannot export macro `noop`: macro; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:406: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:429: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:444:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out + fixtures/reject/src/lib.rs:436:1: note: applies past the recursion limit +fixtures/reject/src/lib.rs:474: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:451:1: note: `std::string::String` converts too, which C passes alike +fixtures/reject/src/lib.rs:479:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:47:1: rust2-ffi: cannot export fn `excluded`: excluded type `Excluded`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:484: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:489: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:494: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:499: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:525: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:52:1: rust2-ffi: cannot export fn `letters`: Range `char`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:530: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:504:1: note: C cannot implement `Source`: callback signature `items` +fixtures/reject/src/lib.rs:535:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:540: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:540:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:547: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:547:20: note: `'b` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:554: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:554:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:563:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:569: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:575: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:592: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:609: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:632: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:646: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:651: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:658: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:664: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:669: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:66:2: rust2-ffi: cannot export method `Text::view`: returned object that borrows `Text<'_>`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:674:1: rust2-ffi: cannot export fn `successes`: foreign type `std::iter::Flatten`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:694: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: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:701: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:708: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:732: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:73: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:750: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:755: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:760: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:766: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:772: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:783:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:802: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:807: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:814: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:821: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:826: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:833: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:838: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:843: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:848: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:84: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:861: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:872: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:875: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:886:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:906: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:922: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:929: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:935: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:940: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:945: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:951: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:701: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:725: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:743: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:748: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:753: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:759: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:765: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:776:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:77:1: rust2-ffi: cannot export fn `first`: borrowed return that is not Clone `Opaque`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:795: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:800: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:807: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:814: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:819: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:826: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:831: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:836: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:841: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:854: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:865: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:868: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:879:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:899: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:915: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:922: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:928: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:933: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:938: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:944: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:946:2: note: has this discriminant +fixtures/reject/src/lib.rs:951: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:953:2: note: has this discriminant -fixtures/reject/src/lib.rs:958: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:958: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:960:2: note: has this discriminant -fixtures/reject/src/lib.rs:965: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:967:2: note: has this discriminant +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 diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index de5078298..f0640af68 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -118,7 +118,7 @@ pub struct Size { } /// Another crate's type that is not `Send`, which no handle may hold. -pub fn measure(local: dep::Local) -> u32 { +pub fn measure(local: tls::Local) -> u32 { local.get() } diff --git a/ffi/fixtures/tls/src/lib.rs b/ffi/fixtures/tls/src/lib.rs index 4144cc5ce..b1bb3d903 100644 --- a/ffi/fixtures/tls/src/lib.rs +++ b/ffi/fixtures/tls/src/lib.rs @@ -40,3 +40,12 @@ impl Cert { pub struct Session { pub id: u32, } + +/// A count that is not `Send`, which the reject fixture takes by value: no handle may hold it. +pub struct Local(std::rc::Rc); + +impl Local { + pub fn get(&self) -> u32 { + *self.0 + } +} diff --git a/ffi/justfile b/ffi/justfile index fc4c72ddd..6f39d6043 100644 --- a/ffi/justfile +++ b/ffi/justfile @@ -305,8 +305,11 @@ standin checkout="": src=$(cygpath -m "$src") fi dir=target/moq-ffi - # moq-ffi's dependencies, moq-tokio with its default features as moq-ffi has them. + # moq-ffi's dependencies, each with the features moq-ffi turns on, such as moq-mux's + # async wrappers, read from its manifest. deps=(hang kio moq-mux moq-net moq-pattern moq-tokio) + features=$(cd "$src" && cargo metadata --format-version 1 --no-deps \ + | jq -c '[.packages[] | select(.name == "moq-ffi") | .dependencies[] | select(.kind == null) | {key: .name, value: .features}] | from_entries') mkdir -p "$dir/src" { printf '# Generated by just ffi standin, from %s.\n' "$src" @@ -314,7 +317,8 @@ standin checkout="": # The prefix of every C name. printf '[lib]\nname = "moq"\n\n[dependencies]\n' for name in "${deps[@]}"; do - printf '%s = { path = "%s/rs/%s" }\n' "$name" "$src" "$name" + on=$(jq -r --arg name "$name" '.[$name] // [] | map(@json) | join(", ")' <<< "$features") + printf '%s = { path = "%s/rs/%s", features = [%s] }\n' "$name" "$src" "$name" "$on" done printf '\n[workspace]\n' } > "$dir/Cargo.toml" diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index c6041d383..f5be9222d 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -2475,13 +2475,11 @@ impl<'tcx> Collector<'tcx> { Err(why) => return vec![(Err(why), shown.clone(), false)], }; let mut functions = Vec::new(); - if shown.iter().any(|s| s.contains("connect_with")) { eprintln!("DEBUG {shown:?} instances {}", instances.len()); } for instance in &instances { let Some(shown) = self.shown(shown, instance) else { continue; }; let function = self.function(def_id, path.clone(), shown.clone(), self_ty, instance); - if shown.iter().any(|s| s.contains("connect_with")) { eprintln!("DEBUG fn {:?} {:?}", function.as_ref().err().map(|w| w.len()), function.as_ref().ok().map(|f| (f.params.iter().map(|p| format!("{:?}", p.ty)).collect::>(), f.on.clone()))); } functions.push((function, shown, !instance.named.is_empty())); } functions diff --git a/ffi/src/glue.rs b/ffi/src/glue.rs index f2e0d41fa..f302620fb 100644 --- a/ffi/src/glue.rs +++ b/ffi/src/glue.rs @@ -1599,12 +1599,20 @@ impl Gen<'_> { args.push(arg); } // Each owned argument the call lends moves to the heap, where it stays while the - // future borrows it. + // future borrows it, and the call reborrows it through the reference it is now. for local in &held { stmts.push(format!( "let {local}_held = rt::Pinned::new({local});\n\tlet {local} = unsafe {{ {local}_held.get() }};" )); } + for arg in &mut args { + if let Some(local) = held + .iter() + .find(|l| *arg == format!("&{l}") || *arg == format!("&mut {l}")) + { + *arg = arg.replacen(local.as_str(), &format!("*{local}"), 1); + } + } // A future made of a `Poll` calls the function at each poll, passing the poll's // context, or a value made from its waker and kept until the next poll, so what that // poll registers stays registered. diff --git a/ffi/tests/api.c b/ffi/tests/api.c index 3354b6ff0..3ea6b28a6 100644 --- a/ffi/tests/api.c +++ b/ffi/tests/api.c @@ -949,6 +949,13 @@ static int script(void) { print("recv ", payload, "\n"); } api_Channel_recv_future_free(recv); + /* The send happens at the call, and the future borrows the channel and the tag. */ + api_Channel_tagged_future *tagging = api_Channel_tagged(channel, str("tag")); + api_buf tagged_text; + if (api_Channel_tagged_poll(tagging, waker, &tagged_text) == API_POLL_READY) { + print("tagged ", tagged_text, "\n"); + } + api_Channel_tagged_future_free(tagging); api_Channel_send(channel, str("sized")); api_Channel_recv_sized_future *sized = api_Channel_recv_sized(channel); size_t len; @@ -1291,6 +1298,15 @@ static int script(void) { print("", api_alpn(config_copy), "\n"); api_tls_Config_free(config_copy); api_tls_Config_free(config); + /* Another crate's value by value: an opaque handle, lent or taken back. */ + api_tls_Cert *cert = api_certify(str("der")); + printf("cert %llu ", (unsigned long long)api_cert_len(cert)); + print("", api_cert_der(cert), " "); + api_tls_Cert_free(cert); + api_tls_Cert *chain[2] = {api_certify(str("a")), api_certify(str("bc"))}; + printf("%llu\n", (unsigned long long)api_chain_len((api_vec_tls_Cert){.ptr = chain, .len = 2})); + api_tls_Cert_free(chain[0]); + api_tls_Cert_free(chain[1]); /* A borrow of a meter that is not Clone, lent from its owner's handle. */ { api_Meters *lender = api_Meters_new(); @@ -1305,6 +1321,11 @@ static int script(void) { again = api_Meters_first(lender); printf("cleared %llu\n", (unsigned long long)api_Meter_count(again)); api_Meter_free(again); + /* A field that is not Clone, lent as a method's borrowed return is. */ + api_Meter *last = api_Meters_last_get(lender); + api_Meter_add(last, 4); + printf("field lent %llu\n", (unsigned long long)api_Meter_add(last, 1)); + api_Meter_free(last); api_Meters_free(lender); /* One lent from a handle that is not Sync, on one thread at a time. */ api_Tallies *tallies = api_Tallies_new(); @@ -1584,7 +1605,7 @@ static int script(void) { api_Token_free(twice); /* Each future dropped its waker once it finished, and Rust the one it was given. */ - if (drops != 12) { + if (drops != 13) { return 1; } return closures() && foreign_futures() ? 0 : 1; diff --git a/ffi/tests/api.cpp b/ffi/tests/api.cpp index a89ce001a..dd5d11d59 100644 --- a/ffi/tests/api.cpp +++ b/ffi/tests/api.cpp @@ -587,6 +587,13 @@ int script() { print("recv ", *payload, "\n"); } } + // The send happens at the call, and the future borrows the channel and the tag. + { + api::Channel_tagged_future tagged = channel.tagged("tag"); + if (auto text = tagged.poll(waker)) { + print("tagged ", *text, "\n"); + } + } channel.send("sized"); { api::Channel_recv_sized_future sized = channel.recv_sized(); @@ -838,6 +845,13 @@ int script() { auto config = api::secure("h3"); print("secure ", api::alpn_lent(config), " "); print("", api::alpn(config), "\n"); + auto cert = api::certify("der"); + std::printf("cert %llu ", ull(api::cert_len(cert))); + print("", api::cert_der(std::move(cert)), " "); + std::vector chain; + chain.push_back(api::certify("a")); + chain.push_back(api::certify("bc")); + std::printf("%llu\n", ull(api::chain_len(std::move(chain)))); auto meters = api::Meters::new_(); auto first = meters.first(); first.add(2); @@ -845,6 +859,9 @@ int script() { std::printf("lent %llu %llu\n", added, ull(meters.first().count())); meters.clear(); std::printf("cleared %llu\n", ull(meters.first().count())); + auto last = meters.last_get(); + last.add(4); + std::printf("field lent %llu\n", ull(last.add(1))); auto tallies = api::Tallies::new_(); tallies.first().bump(); std::printf("tallied %u\n", tallies.first().bump()); diff --git a/ffi/tests/api.dart b/ffi/tests/api.dart index 2d7d0d4ef..e91d03ed0 100644 --- a/ffi/tests/api.dart +++ b/ffi/tests/api.dart @@ -361,6 +361,8 @@ Future script() async { // The send happens at the call: the future is dropped unawaited. channel.sendLater(utf8.encode('eager')); print('recv ${text(await channel.recv())}'); + // The send happens at the call, and the future borrows the channel and the tag. + print('tagged ${await channel.tagged('tag')}'); channel.send(utf8.encode('sized')); final (payload, size) = await channel.recvSized(); print('sized ${text(payload)} $size'); @@ -535,6 +537,9 @@ Future script() async { print('nudge ${nudged.value.x} ${nudged.value.y}'); final config = api.secure('h3'); print('secure ${api.alpnLent(config)} ${api.alpn(config.clone())}'); + final cert = api.certify(utf8.encode('der')); + final certLen = api.certLen(cert); + print('cert $certLen ${text(api.certDer(cert))} ${api.chainLen([api.certify(utf8.encode('a')), api.certify(utf8.encode('bc'))])}'); config.close(); final meters = api.Meters(); final lentMeter = meters.first(); @@ -543,6 +548,10 @@ Future script() async { lentMeter.close(); meters.clear(); print('cleared ${meters.first().count()}'); + final lastMeter = meters.lastGet; + lastMeter.add(4); + print('field lent ${lastMeter.add(1)}'); + lastMeter.close(); meters.close(); final tallies = api.Tallies(); tallies.first().bump(); diff --git a/ffi/tests/api.go b/ffi/tests/api.go index ecd169d46..7cab67f58 100644 --- a/ffi/tests/api.go +++ b/ffi/tests/api.go @@ -27,6 +27,7 @@ import ( "api/rt" "api/serdejson" "api/std" + "api/tls" "api/tracingcore" "api/url" ) @@ -451,6 +452,8 @@ func script() { cancel() check(errors.Is(channel.SendLater(cancelled, []byte("eager")), context.Canceled), "a cancelled call returns its context's error") fmt.Printf("recv %s\n", must(channel.Recv(ctx)).Copy()) + // The send happens at the call, and the future borrows the channel and the tag. + fmt.Printf("tagged %s\n", must(channel.Tagged(ctx, "tag"))) channel.Send([]byte("sized")) sized, size, err := channel.RecvSized(ctx) check(err == nil, "recv sized") @@ -631,12 +634,18 @@ func script() { fmt.Printf("nudge %d %d\n", nudged.X, nudged.Y) config := api.Secure("h3") fmt.Printf("secure %s %s\n", must(api.AlpnLent(config)), must(api.Alpn(must(config.Clone())))) + cert := api.Certify([]byte("der")) + certLen := must(api.CertLen(cert)) + fmt.Printf("cert %d %s %d\n", certLen, must(api.CertDer(cert)).Copy(), must(api.ChainLen([]*tls.Cert{api.Certify([]byte("a")), api.Certify([]byte("bc"))}))) meters := api.NewMeters() meter := must(meters.First()) _ = must(meter.Add(2)) fmt.Printf("lent %d %d\n", must(meter.Add(3)), must(must(meters.First()).Count())) ok(meters.Clear()) fmt.Printf("cleared %d\n", must(must(meters.First()).Count())) + lastMeter := must(meters.LastGet()) + _ = must(lastMeter.Add(4)) + fmt.Printf("field lent %d\n", must(lastMeter.Add(1))) tallies := api.NewTallies() _ = must(must(tallies.First()).Bump()) fmt.Printf("tallied %d\n", must(must(tallies.First()).Bump())) diff --git a/ffi/tests/api.kt b/ffi/tests/api.kt index df02a065f..6a18fe6b8 100644 --- a/ffi/tests/api.kt +++ b/ffi/tests/api.kt @@ -292,6 +292,8 @@ fun script() { // The send happens at the call: the future is dropped unawaited. channel.sendLater("eager".encodeToByteArray()) println("recv ${channel.recv().text()}") + // The send happens at the call, and the future borrows the channel and the tag. + println("tagged ${channel.tagged("tag")}") channel.send("sized".encodeToByteArray()) val (payload, size) = channel.recvSized() println("sized ${payload.text()} $size") @@ -462,6 +464,9 @@ fun script() { nudge(nudged, 3) println("nudge ${nudged.value.x} ${nudged.value.y}") secure("h3").use { config -> println("secure ${alpnLent(config)} ${alpn(config.clone())}") } + val cert = certify("der".encodeToByteArray()) + val certLen = certLen(cert) + println("cert $certLen ${certDer(cert).text()} ${chainLen(listOf(certify("a".encodeToByteArray()), certify("bc".encodeToByteArray())))}") Meters.new().use { meters -> meters.first().use { first -> first.add(2uL) @@ -469,6 +474,10 @@ fun script() { } meters.clear() println("cleared ${meters.first().use { it.count() }}") + meters.lastGet.use { last -> + last.add(4uL) + println("field lent ${last.add(1uL)}") + } } Tallies.new().use { tallies -> tallies.first().use { it.bump() } diff --git a/ffi/tests/api.py b/ffi/tests/api.py index caf7fe791..3a9bcf731 100644 --- a/ffi/tests/api.py +++ b/ffi/tests/api.py @@ -364,6 +364,8 @@ async def block(): # The send happens at the call: the future is dropped unawaited. channel.send_later(b"eager") print(f"recv {text(await channel.recv())}") + # The send happens at the call, and the future borrows the channel and the tag. + print(f"tagged {await channel.tagged('tag')}") channel.send(b"sized") payload, size = await channel.recv_sized() print(f"sized {text(payload)} {size}") @@ -544,12 +546,17 @@ async def polls(): print(f"nudge {nudged.value.x} {nudged.value.y}") config = api.secure("h3") print(f"secure {api.alpn_lent(config)} {api.alpn(config.clone())}") + cert = api.certify(b"der") + print(f"cert {api.cert_len(cert)} {text(api.cert_der(cert))} {api.chain_len([api.certify(b'a'), api.certify(b'bc')])}") meters = api.Meters.new() first = meters.first() first.add(2) print(f"lent {first.add(3)} {meters.first().count()}") meters.clear() print(f"cleared {meters.first().count()}") + lent_last = meters.last_get + lent_last.add(4) + print(f"field lent {lent_last.add(1)}") tallies = api.Tallies.new() tallies.first().bump() print(f"tallied {tallies.first().bump()}") diff --git a/ffi/tests/api.swift b/ffi/tests/api.swift index 93b3fcca3..70a410371 100644 --- a/ffi/tests/api.swift +++ b/ffi/tests/api.swift @@ -442,6 +442,8 @@ func script() { // The send happens at the call, before the future is first polled. try await channel.sendLater(Data("eager".utf8)) print("recv \(text(try await channel.recv()))") + // The send happens at the call, and the future borrows the channel and the tag. + print("tagged \(try await channel.tagged("tag"))") channel.send(Data("sized".utf8)) let (payload, size) = try await channel.recvSized() print("sized \(text(payload)) \(size)") @@ -634,12 +636,22 @@ func script() { do { let config = secure("h3") print("secure \(alpnLent(config)) \(alpn(config.clone()))") + let cert = certify(Data("der".utf8)) + let certLength = certLen(cert) + let der = text(certDer(cert)) + var chain = UniqueArray() + chain.append(certify(Data("a".utf8))) + chain.append(certify(Data("bc".utf8))) + print("cert \(certLength) \(der) \(chainLen(chain))") var meters = Meters.new() let first = meters.first() _ = first.add(2) print("lent \(first.add(3)) \(meters.first().count())") meters.clear() print("cleared \(meters.first().count())") + let last = meters.lastGet + _ = last.add(4) + print("field lent \(last.add(1))") let tallies = Tallies.new() _ = tallies.first().bump() print("tallied \(tallies.first().bump())") diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index dee312bad..d58eedde6 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -1409,6 +1409,7 @@ fn relative_target() { "- `Lease`: object no export returns", "- `Void`: object no export returns", "- `release`: type C never holds `Lease`", + "- `handover`: type C never holds `tls::Session`", "- `Unnamed`: generic type no export instantiates", ] { assert!(text.contains(line), "the census lists no `{line}`:\n{text}"); diff --git a/quest/m1/ffi-refusals/README.md b/quest/m1/ffi-refusals/README.md index cf3ebae85..07ebef25e 100644 --- a/quest/m1/ffi-refusals/README.md +++ b/quest/m1/ffi-refusals/README.md @@ -77,9 +77,11 @@ Decided with the maintainer on 2026-11-12, in the quest audit: refuses 94 items and 5 types at the pin, behind `ffi/moq/ffi.toml`'s 100 excludes, and moq's `main` adds the 36 errors [the pin bump](/quest/m1/ffi-refusals/moq-pin.md) measured. So each construct left has a child again: - [`NonZero`](/quest/m1/ffi-refusals/nonzero.md), - [the rest at moq's main](/quest/m1/ffi-refusals/moq-main.md), and - [the excludes that hide what exports](/quest/m1/ffi-refusals/stale-excludes.md); the + [`NonZero`](/quest/m1/ffi-refusals/nonzero.md), 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`), + [the excludes that hide what exports](/quest/m1/ffi-refusals/stale-excludes.md), and + [what the excludes still hide at moq's main](/quest/m1/ffi-refusals/moq-excluded.md); the bump is then only the bump. The types refused for not being `Send` (`clock::Entered`, `clock::Rng`, `catalog::Guard`) clear with [not-send](/quest/m1/ffi-export/not-send.md). - ✅ The closing work is a child, [no config](/quest/m1/ffi-refusals/no-config.md), as diff --git a/quest/m1/ffi-refusals/moq-excluded.md b/quest/m1/ffi-refusals/moq-excluded.md new file mode 100644 index 000000000..435d40ffe --- /dev/null +++ b/quest/m1/ffi-refusals/moq-excluded.md @@ -0,0 +1,36 @@ +# [M] What the excludes hide at moq's main + +## Goal + +Each construct `just ffi census ` still refuses at moq's `main` behind an +exclude in `ffi/moq/ffi.toml` exports by a rule, or is left out as what C can never hold, +beyond [`NonZero`](/quest/m1/ffi-refusals/nonzero.md) and the types +[not-send](/quest/m1/ffi-export/not-send.md) exports. Measured on 2026-11-12 at moq +`04f63af`, with the rules for another crate's value, a non-`async` function's borrowing +future, and a lent object field in place: 11 items. + +## Plan + +[The epic](/quest/m1/ffi-refusals/README.md)'s decisions apply: rust2 asks moq for no +source change, and what C can never hold is left out and listed. Measure again first. + +- `std::io::Error` taken by value (`accept::Failure::classify`, `accept::Health::failed`) + and `std::net::IpAddr` (`quic::demux::Datagram::local`). Recommended: `IpAddr` crosses + as `SocketAddr` already does, by family; `io::Error` as an opaque handle, as another + crate's value now is, with the standard library no longer exempt. +- Trait objects: `quic::Controller`'s `Arc` + field and `tls::Serve::resolver`'s `Arc`. + Recommended: an opaque handle to the `Arc`, as another crate's `Arc` already is. +- Generic parameters: `server::Request::within` (`impl Future`), + `websocket::Listener::with_protocols` (`impl IntoIterator>`), + `tcp::TlsAcceptor::offered` (`impl Iterator`), and `tcp::TlsAcceptor::accept` (an IO + stream). Recommended: `AsRef` items as strings and an `Iterator` parameter as the + array of its items, as returns already are; a foreign future as #705's is; the IO + stream left out as what C can never hold, since no export returns one. +- `server::Config::websocket`, a borrowed `Option` of a listener that is not `Clone`. + Recommended: lent as `Some` of a handle, as a bare field now is. +- `server::Listener::accept_with`'s future is not `Send`. Left out today as what C can + never hold, since it takes a `qmux::Session` no export returns once the excludes go; + confirm the census lists it so. + +Public API: the generated API of each item that newly exports. diff --git a/quest/m1/ffi-refusals/moq-main.md b/quest/m1/ffi-refusals/moq-main.md deleted file mode 100644 index 1de4a9b3f..000000000 --- a/quest/m1/ffi-refusals/moq-main.md +++ /dev/null @@ -1,28 +0,0 @@ -# [M] Every refusal at moq's main has a rule - -## Goal - -`just ffi moq-cpp ` at moq's `main` exports with no error and no new exclude: -each construct the export refuses there, beyond -[`NonZero`](/quest/m1/ffi-refusals/nonzero.md), exports by a rule or is left out as what C -can never hold. Measured on 2026-11-12 at moq `6936f0a` -([the pin bump](/quest/m1/ffi-refusals/moq-pin.md)): single refusals such as -`qmux::Session` and `CertificateDer`, third-party types taken by value; a borrowing -future from the non-async `Server::accept`; and borrowed returns that are not `Clone`. - -## Plan - -[The epic](/quest/m1/ffi-refusals/README.md)'s decisions apply: rust2 asks moq for no -source change, a third-party type behind an `Arc` crosses as an opaque handle, and what C -can never hold is left out and listed. - -- Start from a census at a moq `main` checkout, and list every refusal it still has by - construct in the PR. A construct that needs a decision the epic does not already make - becomes its own quest here, with the options and a recommendation, rather than a guess. -- Recommended for a third-party type by value: an opaque handle with none of its API, as - the `Arc` form already is, since the value moves into the handle exactly. -- Recommended for the borrowing future of a non-async fn: the rule async fns' borrowing - futures already follow ([#710](https://github.com/moq-dev/rust2/pull/710)). -- No exclude is added to `ffi/moq/ffi.toml` to pass. - -Public API: the generated API of each item that newly exports. diff --git a/quest/m1/ffi-refusals/moq-pin.md b/quest/m1/ffi-refusals/moq-pin.md index eff90d9e6..593dd34d7 100644 --- a/quest/m1/ffi-refusals/moq-pin.md +++ b/quest/m1/ffi-refusals/moq-pin.md @@ -97,4 +97,3 @@ returns that are not `Clone`. - [Own pin](/quest/m1/ffi-refusals/own-pin.md) - the exporter's pin moves without rust2-ts's, which ends the wait on `rind` for wasm32 - [`NonZero`](/quest/m1/ffi-refusals/nonzero.md) - 15 of the 36 errors at moq's `main` -- [Every refusal at moq's main](/quest/m1/ffi-refusals/moq-main.md) - the rest of them, so the bump adds no exclude diff --git a/quest/m1/ffi-refusals/no-config.md b/quest/m1/ffi-refusals/no-config.md index d8ea045b9..5bb8ec0cd 100644 --- a/quest/m1/ffi-refusals/no-config.md +++ b/quest/m1/ffi-refusals/no-config.md @@ -31,4 +31,5 @@ that passes them). - [The moq pin bump](/quest/m1/ffi-refusals/moq-pin.md) - the pin is at moq's `main`, where the census is taken - [No exclude hides what exports](/quest/m1/ffi-refusals/stale-excludes.md) - the list is down to what the export refuses +- [What the excludes hide at moq's main](/quest/m1/ffi-refusals/moq-excluded.md) - exports the constructs the census still refuses there behind an exclude - [Not Send](/quest/m1/ffi-export/not-send.md) - exports the three types the census still refuses for not being `Send` From 3883ec880fbd8b5aeb3df22f04a1cb8148735c29 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 13 Nov 2026 02:18:00 -0800 Subject: [PATCH 10/24] fix(ffi): refuse a borrowing output of an eager future and an erased type as a type argument Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/reject/src/lib.rs | 11 +++++++++++ ffi/src/collect.rs | 18 +++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index f0640af68..ef92cf5f7 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -125,6 +125,17 @@ pub fn measure(local: tls::Local) -> u32 { /// A generic type, which exports at the instances its exports name. pub struct Cell(T); +/// An instance naming another crate's type that a handle holds by value, erased. +pub fn sealed(cert: tls::Cert) -> Cell { + Cell(cert) +} + +/// A future returned by a function that is not async, whose output borrows what the +/// future holds only until it completes. +pub fn echo(tag: &str) -> impl std::future::Future + '_ { + async move { tag } +} + impl Cell { pub fn new(value: T) -> Self { Self(value) diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index f5be9222d..052e5be1d 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -939,11 +939,13 @@ impl<'tcx> Collector<'tcx> { ty::Bool | ty::Char | ty::Float(_) => false, ty::Int(_) | ty::Uint(_) => int(ty).is_none(), ty::Adt(adt, _) => { - tcx.lang_items().string() != Some(adt.did()) - && self.bytes != Some(adt.did()) - && !tcx.is_diagnostic_item(rustc_span::Symbol::intern("Duration"), adt.did()) - && !self.exported(adt.did().krate) - && !self.foreign.iter().any(|&(ty, _)| ty == adt.did()) + let mapped = tcx.lang_items().string() == Some(adt.did()) + || self.bytes == Some(adt.did()) + || tcx.is_diagnostic_item(rustc_span::Symbol::intern("Duration"), adt.did()) + || self.exported(adt.did().krate) + || self.foreign.iter().any(|&(ty, _)| ty == adt.did()); + // A handle holds its value erased, so no instance names its type. + !mapped || self.owned.contains(&adt.did()) } _ => true, }; @@ -2773,6 +2775,12 @@ impl<'tcx> Collector<'tcx> { if !self.is_send(output, kept) { errs.push(why("future not Send", "")); } + // An eager future holds what it borrows only until it completes, so its output + // may borrow none of it. + let (held, lent) = self.lifetimes(sig.skip_binder().output()); + if eager && borrows && held.iter().chain(&lent).any(|region| !statics.contains(region)) { + errs.push(why("borrowing output of a future from a function that is not async", inner.to_string())); + } output = normalize(inner); future = true; } From 92d1dfb20afe0e5271bd594b9e8b2bcccd493194 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 13 Nov 2026 02:56:31 -0800 Subject: [PATCH 11/24] fix(ffi): read earlier baselines, lend no erased value, and an orphaned error as its message Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/api/src/lib.rs | 16 +++ ffi/fixtures/reject/expected.txt | 239 ++++++++++++++++--------------- ffi/fixtures/reject/src/lib.rs | 29 ++++ ffi/fixtures/tls/src/lib.rs | 15 ++ ffi/src/collect.rs | 13 +- ffi/src/ir.rs | 46 +++++- ffi/tests/fixtures.rs | 3 + 7 files changed, 234 insertions(+), 127 deletions(-) diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index 1522ba4fd..6f895d47e 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -2208,6 +2208,22 @@ pub fn handover(session: tls::Session) -> u32 { session.id } +/// A certificate's length, or why it is refused: another crate's error, which crosses as +/// its message though `blame` names it as a handle no export returns. +pub fn verify(cert: &tls::Cert) -> Result { + match cert.der().len() { + 0 => Err(tls::Invalid { + reason: "empty".to_string(), + }), + len => Ok(len as u32), + } +} + +/// Another crate's error taken back by value, which no export returns: left out. +pub fn blame(err: tls::Invalid) -> String { + err.to_string() +} + /// `text`'s length, or 0 for none: an optional borrow, lent as the borrow alone is. pub fn either(text: Option<&str>) -> usize { text.map_or(0, str::len) diff --git a/ffi/fixtures/reject/expected.txt b/ffi/fixtures/reject/expected.txt index de2ad23e3..70eb7e3ca 100644 --- a/ffi/fixtures/reject/expected.txt +++ b/ffi/fixtures/reject/expected.txt @@ -1,133 +1,134 @@ -fixtures/reject/src/lib.rs:1004:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1010:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1015:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1020: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:1010:1: note: C cannot implement `Trusted`: unsafe trait -fixtures/reject/src/lib.rs:1025: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:1015:1: note: C cannot implement `Hazard`: unsafe fn `risk` -fixtures/reject/src/lib.rs:1030: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:1002: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:1004:2: note: has this discriminant +fixtures/reject/src/lib.rs:1008:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1013:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1019:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1033:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1039:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1044:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1049: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:1039:1: note: C cannot implement `Trusted`: unsafe trait +fixtures/reject/src/lib.rs:1054: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:1044:1: note: C cannot implement `Hazard`: unsafe fn `risk` +fixtures/reject/src/lib.rs:1059: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:105:1: rust2-ffi: cannot export fn `forever`: 'static borrow `&'static [u8]`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:111:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:11:1: rust2-ffi: cannot export fn `map`: foreign type `std::collections::HashMap`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:121:1: rust2-ffi: cannot export fn `measure`: foreign type `tls::Local`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:126: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:126:1: rust2-ffi: cannot export instance `Cell`: type argument `tls::Cert`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:129: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:135: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:147: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:166: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:133:2: rust2-ffi: cannot export method `Link::session`: borrowed return that is not Clone `tls::Session`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:150:1: rust2-ffi: cannot export fn `measure`: foreign type `tls::Local`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:155: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:155:1: rust2-ffi: cannot export instance `Cell`: type argument `tls::Cert`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:158: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:164: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: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:177: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:180: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:191: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:200: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:211:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:216:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:176: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:195: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:206: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:209: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: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:221: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:226: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:229: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:234: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:237: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:245:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:255: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:260: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:265: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:270: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:275: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:280: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:285: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:291: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:297: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:302: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:307: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:220: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:229: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:240:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:245:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:250: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:255: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:258: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:263: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:266: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:274:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:284: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:289: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:294: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:299: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:304: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:309: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: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:312: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:317: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:322: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:334: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:349: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:354: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:359: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:314: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:320: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:326: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:331: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:336: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:341: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:346: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:351: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:35:1: rust2-ffi: cannot export static `COUNT`: static; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:373: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:387: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:363: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:378: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:383: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:388: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:39:1: rust2-ffi: cannot export macro `noop`: macro; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:402: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:417: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:440: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:455:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:447:1: note: applies past the recursion limit +fixtures/reject/src/lib.rs:402: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:416: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:431: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:446: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:469: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:47:1: rust2-ffi: cannot export fn `excluded`: excluded type `Excluded`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:485: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:462:1: note: `std::string::String` converts too, which C passes alike -fixtures/reject/src/lib.rs:490:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:495: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:500: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:505: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:510: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:484:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out + fixtures/reject/src/lib.rs:476:1: note: applies past the recursion limit +fixtures/reject/src/lib.rs:514: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:491:1: note: `std::string::String` converts too, which C passes alike +fixtures/reject/src/lib.rs:519:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:524: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:529: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:52:1: rust2-ffi: cannot export fn `letters`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:536: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:541: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:515:1: note: C cannot implement `Source`: callback signature `items` -fixtures/reject/src/lib.rs:546:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:551: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:551:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:558: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:558:20: note: `'b` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:565: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:565:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:574:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:580: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:586: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:603: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:620: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:643: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:657: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:662: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:669: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:534: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:539: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:565: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:570: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:544:1: note: C cannot implement `Source`: callback signature `items` +fixtures/reject/src/lib.rs:575:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:580: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:580:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:587: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:587:20: note: `'b` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:594: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:594:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:603:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:609: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:615: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:632: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:649: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: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:675: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:680: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:685: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:672: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:686: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:691: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:698: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: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:705: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:712: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:736: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:754: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:759: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:764: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:770: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:776: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:704: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:709: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:714: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:734: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:741: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:765: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: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:787:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:806: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:811: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:818: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:825: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:830: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:837: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:842: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:847: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:852: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:865: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:876: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:879: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:890:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:908:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:914: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:930: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:937: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:943: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:948: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:953: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:959: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:961:2: note: has this discriminant -fixtures/reject/src/lib.rs:966: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:968:2: note: has this discriminant -fixtures/reject/src/lib.rs:973: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:975:2: note: has this discriminant -fixtures/reject/src/lib.rs:979:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:984:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:990:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:783: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:788: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:793: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:799: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:805: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:816:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:835: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:840: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:847: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:854: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:859: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:866: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:871: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:876: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:881: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:894: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:905: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:908: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:919:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:937:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:943: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:959: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:966: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:972: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:977: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:982: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:988: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:990:2: note: has this discriminant +fixtures/reject/src/lib.rs:995: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:997:2: note: has this discriminant 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 diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index a40f5454a..2482f5d1a 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -117,6 +117,35 @@ pub struct Size { pub bytes: u64, } +/// An object holding another crate's session, which C holds as a handle. +pub struct Link { + session: tls::Session, +} + +impl Link { + pub fn new() -> Self { + Self { + session: tls::Session { id: 1 }, + } + } + + /// Not lent: a handle holds another crate's value only erased, and by value. + pub fn session(&self) -> &tls::Session { + &self.session + } + + /// What makes the session a value C holds. + pub fn take(self) -> tls::Session { + self.session + } +} + +impl Default for Link { + fn default() -> Self { + Self::new() + } +} + /// Another crate's type that is not `Send`, which no handle may hold. pub fn measure(local: tls::Local) -> u32 { local.get() diff --git a/ffi/fixtures/tls/src/lib.rs b/ffi/fixtures/tls/src/lib.rs index b1bb3d903..4cb88003c 100644 --- a/ffi/fixtures/tls/src/lib.rs +++ b/ffi/fixtures/tls/src/lib.rs @@ -41,6 +41,21 @@ pub struct Session { pub id: u32, } +/// Why a certificate is refused, which the api fixture's `verify` returns as its message +/// and `blame` takes back, though no export returns one: C never holds one. +#[derive(Debug)] +pub struct Invalid { + pub reason: String, +} + +impl std::fmt::Display for Invalid { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "invalid certificate: {}", self.reason) + } +} + +impl std::error::Error for Invalid {} + /// A count that is not `Send`, which the reject fixture takes by value: no handle may hold it. pub struct Local(std::rc::Rc); diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 43eec54e6..b07e77b11 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -2899,9 +2899,10 @@ impl<'tcx> Collector<'tcx> { let error = args.type_at(1); // Another crate's error, such as `anyhow::Error` or `io::Error`, crosses as // its message, as an exported error's `Display` already reads. - let foreign = |mapped: &Result| match mapped { - Err(why) => why.construct == "foreign type" || why.construct == BOTH, - Ok(_) => self.opaque_value(error).is_some(), + // One a handle holds by value is its message too, held or not. + let foreign = |mapped: &Result| { + self.opaque_value(error).is_some() + || matches!(mapped, Err(why) if why.construct == "foreign type" || why.construct == BOTH) }; let err = match self.ty(error, Pos::Return) { err if foreign(&err) && implements(tcx, error, def_id, rustc_span::sym::Display) => { @@ -4558,8 +4559,10 @@ impl<'tcx> Collector<'tcx> { } // Returned as a clone: a handle in it is a new handle to its clone. (Type::Str | Type::Slice | Type::Path, Pos::Return | Pos::Returned, _) => {} - // Lent from the receiver's handle, as [`Self::function`] decides. - (Type::Object(_), Pos::Return, Mutability::Not) if self.lending.take() => {} + // Lent from the receiver's handle, as [`Self::function`] decides, but for + // 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 slice's clone is a `Vec` of its elements' clones. (_, Pos::Return | Pos::Returned, _) if !self.is_clone(match inner.kind() { diff --git a/ffi/src/ir.rs b/ffi/src/ir.rs index 4a503ff09..3daae7775 100644 --- a/ffi/src/ir.rs +++ b/ffi/src/ir.rs @@ -18,7 +18,8 @@ pub struct Api { /// The crates items belong to, each after every crate it depends on. pub crates: Vec, /// The crates the facade does not re-export whose types an export names, which the - /// glue depends on directly. + /// glue depends on directly. A baseline written before it has none. + #[serde(default)] pub reached: Vec, /// The targets it serves, sorted: one for a single target's, several merged. pub targets: Vec, @@ -216,10 +217,27 @@ pub struct Object { /// exports: its path is the type's in its own crate, not in the facade. pub foreign: bool, /// What its handle holds of another crate's type, held erased, which the glue never - /// names: a handle with none of its API. + /// names: a handle with none of its API. A baseline written before the by-value form + /// has a `bool`, the `Arc` form's. + #[serde(deserialize_with = "held")] pub opaque: Option, } +/// An [`Object::opaque`], read from a baseline written before the by-value form as the +/// `bool` the `Arc` form was. +fn held<'de, D: serde::Deserializer<'de>>(de: D) -> Result, D::Error> { + #[derive(serde::Deserialize)] + #[serde(untagged)] + enum Either { + Arc(bool), + Held(Option), + } + Ok(match serde::Deserialize::deserialize(de)? { + Either::Arc(arc) => arc.then_some(Held::Arc), + Either::Held(held) => held, + }) +} + /// What an opaque handle holds of another crate's type. #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)] pub enum Held { @@ -281,7 +299,9 @@ pub struct Function { /// `async` returning one does: the export calls it at once, and polls what it returns. pub eager: bool, /// For an eager future, whether what it returns borrows its arguments: the export owns - /// them, as it does an `async fn`'s, and keeps them until the future is dropped. + /// them, as it does an `async fn`'s, and keeps them until the future is dropped. A + /// baseline written before it has none. + #[serde(default)] pub holds: bool, /// The parameter it polls its task through, if any: C passes a waker for it or, for a /// future made of a returned `Poll`, the future's poll supplies it. @@ -614,3 +634,23 @@ impl Type { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[derive(serde::Deserialize)] + struct Opaque { + #[serde(deserialize_with = "held")] + opaque: Option, + } + + #[test] + fn held_reads_an_earlier_baseline() { + let read = |json: &str| serde_json::from_str::(json).unwrap().opaque; + assert_eq!(read(r#"{"opaque":true}"#), Some(Held::Arc)); + assert_eq!(read(r#"{"opaque":false}"#), None); + assert_eq!(read(r#"{"opaque":"Value"}"#), Some(Held::Value)); + assert_eq!(read(r#"{"opaque":null}"#), None); + } +} diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index 69a29161c..2e5440956 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -1420,9 +1420,12 @@ fn relative_target() { "- `release`: type C never holds `Lease`", "- `handover`: type C never holds `tls::Session`", "- `Unnamed`: generic type no export instantiates", + "- `blame`: type C never holds `tls::Invalid`", ] { assert!(text.contains(line), "the census lists no `{line}`:\n{text}"); } + // 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}"); assert!(dir.join("build").exists()); } From aa6cf626f076b1b92b32c80fb867b5c04cda1893 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 13 Nov 2026 03:04:12 -0800 Subject: [PATCH 12/24] fix(ffi): refuse a facade module named as a crate another target reaches Co-Authored-By: Claude Opus 5.5 --- ffi/src/merge.rs | 72 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/ffi/src/merge.rs b/ffi/src/merge.rs index f804140bf..8be64abd3 100644 --- a/ffi/src/merge.rs +++ b/ffi/src/merge.rs @@ -288,6 +288,35 @@ impl Merged { } } } + // The glue names a reached crate's item through its own dependency, by the path's + // second segment, so no target's facade may name a module of its own alike. + let items = (self.api.records.iter().map(|r| (&r.path, r.on, r.span))) + .chain(self.api.enums.iter().map(|e| (&e.path, e.on, e.span))) + .chain( + self.api + .objects + .iter() + .filter(|o| !o.foreign) + .map(|o| (&o.path, o.on, o.span)), + ) + .chain(self.api.callbacks.iter().map(|c| (&c.path, c.on, c.span))) + .chain(self.api.functions.iter().map(|f| (&f.path, f.on, f.span))) + .chain(self.api.constants.iter().map(|c| (&c.path, c.on, c.span))); + let mut clashes = Vec::new(); + for (path, on, span) in items { + let Some(reached) = self.api.reached.iter().find(|r| path.get(1) == Some(&r.krate)) else { + continue; + }; + let reaches = On((self.api.targets.iter().enumerate()) + .filter(|(_, target)| reached.targets.contains(target)) + .fold(0, |bits, (i, _)| bits | 1 << i)); + // On a target that does not reach the crate, the path is the facade's module. + if on.0 & !reaches.0 != 0 { + let what = format!("module `{}`, also a crate a target reaches", reached.krate); + clashes.push(self.differs(what, (reaches, span), (On(on.0 & !reaches.0), span))); + } + } + self.differs.extend(clashes); match order_crates(&self.api) { Ok(crates) => self.api.crates = crates, Err(cycle) => { @@ -698,8 +727,47 @@ mod tests { use rustc_span::DUMMY_SP; - use super::{On, cycle, order_crates}; - use crate::ir::{Api, Enum, Field, Home, Traits, Type, Variant}; + use super::{On, cycle, merge, order_crates}; + use crate::ir::{Api, Constant, Enum, Field, Home, Literal, Reached, Traits, Type, Variant}; + + #[test] + fn refuses_a_module_named_as_a_crate_another_target_reaches() { + // `x`'s facade has a module `kio`; `y` reaches the crate `kio`, whose items the glue + // names through its own dependency. + let api = |target: &str, path: [&str; 3], reached: bool| Api { + records: Vec::new(), + enums: Vec::new(), + objects: Vec::new(), + callbacks: Vec::new(), + functions: Vec::new(), + constants: vec![Constant { + path: path.map(String::from).to_vec(), + home: Home { + krate: "f".into(), + outside: 0, + }, + span: DUMMY_SP, + on: On(0), + docs: String::new(), + value: Literal::Bool(true), + }], + crates: vec!["f".into()], + reached: (reached.then(|| Reached { + krate: "kio".into(), + targets: vec![target.into()], + })) + .into_iter() + .collect(), + targets: vec![target.into()], + }; + let (_, differs) = merge(vec![ + api("x", ["f", "kio", "LOCAL"], false), + api("y", ["f", "kio", "REACHED"], true), + ]); + let whats: Vec<&str> = differs.iter().map(|d| d.what.as_str()).collect(); + assert_eq!(whats, ["module `kio`, also a crate a target reaches"]); + assert_eq!((differs[0].first.0.as_str(), differs[0].second.0.as_str()), ("y", "x")); + } #[test] fn names_a_cycle_across_targets() { From e569638fe1d00f71f90b7a24358b61a1e58d5b59 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:17:40 -0800 Subject: [PATCH 13/24] fix(ffi): refuse an eager future whose output names any borrowed lifetime, and a Copy opaque value in a closure Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/reject/expected.txt | 232 +++++++++++++------------- ffi/fixtures/reject/src/lib.rs | 20 +++ ffi/fixtures/tls/src/lib.rs | 27 +++ ffi/src/collect.rs | 32 +++- quest/m1/ffi-refusals/moq-excluded.md | 10 +- 5 files changed, 199 insertions(+), 122 deletions(-) diff --git a/ffi/fixtures/reject/expected.txt b/ffi/fixtures/reject/expected.txt index 70eb7e3ca..39c783c85 100644 --- a/ffi/fixtures/reject/expected.txt +++ b/ffi/fixtures/reject/expected.txt @@ -1,17 +1,22 @@ -fixtures/reject/src/lib.rs:1002: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:1004:2: note: has this discriminant -fixtures/reject/src/lib.rs:1008:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1013:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1019:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1033:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1039:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1044:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1049: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:1039:1: note: C cannot implement `Trusted`: unsafe trait -fixtures/reject/src/lib.rs:1054: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:1044:1: note: C cannot implement `Hazard`: unsafe fn `risk` -fixtures/reject/src/lib.rs:1059: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:1002: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:1008: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:1010:2: note: has this discriminant +fixtures/reject/src/lib.rs:1015: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:1017:2: note: has this discriminant +fixtures/reject/src/lib.rs:1022: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:1024:2: note: has this discriminant +fixtures/reject/src/lib.rs:1028:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1033:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1039:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1053:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1059:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out fixtures/reject/src/lib.rs:105:1: rust2-ffi: cannot export fn `forever`: 'static borrow `&'static [u8]`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1064:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1069: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:1059:1: note: C cannot implement `Trusted`: unsafe trait +fixtures/reject/src/lib.rs:1074: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:1064:1: note: C cannot implement `Hazard`: unsafe fn `risk` +fixtures/reject/src/lib.rs:1079: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:111:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:11:1: rust2-ffi: cannot export fn `map`: foreign type `std::collections::HashMap`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:133:2: rust2-ffi: cannot export method `Link::session`: borrowed return that is not Clone `tls::Session`; exclude it in the config to leave it out @@ -20,115 +25,114 @@ fixtures/reject/src/lib.rs:155:1: rust2-ffi: cannot export instance `Cell`: type argument `tls::Cert`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:158: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:164: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:169: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: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:176: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:195: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:206: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:209: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:174: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:179:1: rust2-ffi: cannot export fn `spend`: closure signature `tls::Token`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:184:1: rust2-ffi: cannot export fn `mint`: closure signature `tls::Token`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:196: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:215: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: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:220: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:229: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:240:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:245:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:250: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:255: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:258: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:263: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:266: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:274:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:284: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:289: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:294: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:299: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:304: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:309: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:226: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:229: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:240: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:249: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:260:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:265:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:270: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:275: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:278: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:283: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:286: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:294:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:304: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:309: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: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:314: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:320: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:326: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:331: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:336: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:341: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:346: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:351: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:314: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:319: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:324: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:329: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:334: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:340: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:346: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:351: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:356: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:35:1: rust2-ffi: cannot export static `COUNT`: static; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:363: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:378: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:383: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:388: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:361: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:366: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:371: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:383: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:398: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:39:1: rust2-ffi: cannot export macro `noop`: macro; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:402: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:416: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:431: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:446: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:469: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:403: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:408: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:422: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:436: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:451: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:466: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:47:1: rust2-ffi: cannot export fn `excluded`: excluded type `Excluded`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:484:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:476:1: note: applies past the recursion limit -fixtures/reject/src/lib.rs:514: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:491:1: note: `std::string::String` converts too, which C passes alike -fixtures/reject/src/lib.rs:519:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:524: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:529: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:489: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:504:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out + fixtures/reject/src/lib.rs:496:1: note: applies past the recursion limit 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:534: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:539: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:565: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:570: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:544:1: note: C cannot implement `Source`: callback signature `items` -fixtures/reject/src/lib.rs:575:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:580: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:580:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:587: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:587:20: note: `'b` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:594: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:594:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:603:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:609: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:615: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:632: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:649: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:534: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:511:1: note: `std::string::String` converts too, which C passes alike +fixtures/reject/src/lib.rs:539:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:544: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:549: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:554: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:559: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:585: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:590: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:564:1: note: C cannot implement `Source`: callback signature `items` +fixtures/reject/src/lib.rs:595:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:600: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:600:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:607: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:607:20: note: `'b` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:614: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:614:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:623:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:629: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:635: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:652: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:669: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: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:672: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:686: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:691: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:698: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:692: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: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:704: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:709: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:714: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:734: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:741: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:765: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:706: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:711: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:718: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:724: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:729: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:734: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:754: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:761: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: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:783: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:788: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:793: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:799: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:805: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:816:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:835: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:840: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:847: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:854: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:859: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:866: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:871: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:876: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:881: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:894: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:905: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:908: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:919:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:937:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:943: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:959: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:966: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:972: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:977: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:982: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:988: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:990:2: note: has this discriminant -fixtures/reject/src/lib.rs:995: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:997:2: note: has this discriminant +fixtures/reject/src/lib.rs:785: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:803: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:808: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:813: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:819: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:825: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:836:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:855: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:860: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:867: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:874: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:879: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:886: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:891: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:896: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:901: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:914: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:925: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:928: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:939:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:957:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:963: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:979: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:986: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:992: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:997: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: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 diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index 2482f5d1a..6f8ab1ef4 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -165,6 +165,26 @@ pub fn echo(tag: &str) -> impl std::future::Future + '_ { async move { tag } } +/// As `echo`, but the output borrows only inside an error that crosses as its message. +pub fn blame(tag: &str) -> impl std::future::Future>> + '_ { + async move { Err(tls::Wrapped(tag, 0)) } +} + +/// As `echo`, but through a future that is not an `impl Future`. +pub fn resolve(tag: &str) -> tls::Lend<'_, u8> { + tls::Lend(tag, std::marker::PhantomData) +} + +/// A closure taking a `Copy` value of another crate's, which a handle holds. +pub fn spend(f: impl FnOnce(tls::Token) -> u32) -> u32 { + f(tls::Token(1)) +} + +/// A closure returning one. +pub fn mint(f: impl FnOnce() -> tls::Token) -> u32 { + f().0 +} + impl Cell { pub fn new(value: T) -> Self { Self(value) diff --git a/ffi/fixtures/tls/src/lib.rs b/ffi/fixtures/tls/src/lib.rs index 4cb88003c..edf5712d5 100644 --- a/ffi/fixtures/tls/src/lib.rs +++ b/ffi/fixtures/tls/src/lib.rs @@ -64,3 +64,30 @@ impl Local { *self.0 } } + +/// An error that borrows and takes a type parameter, so no handle holds it: it crosses as +/// its message. +#[derive(Debug)] +pub struct Wrapped<'a, T>(pub &'a str, pub T); + +impl std::fmt::Display for Wrapped<'_, T> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(self.0) + } +} + +/// A future that is not an `impl Future`, resolving to what it borrows; its type +/// parameter keeps any handle from holding it. +pub struct Lend<'a, T>(pub &'a str, pub std::marker::PhantomData); + +impl<'a, T> std::future::Future for Lend<'a, T> { + type Output = &'a str; + + fn poll(self: std::pin::Pin<&mut Self>, _: &mut std::task::Context<'_>) -> std::task::Poll<&'a str> { + std::task::Poll::Ready(self.0) + } +} + +/// A `Copy` token, which an opaque handle holds by value. +#[derive(Clone, Copy, Debug)] +pub struct Token(pub u32); diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index b07e77b11..43646d010 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -2853,8 +2853,7 @@ impl<'tcx> Collector<'tcx> { } // An eager future holds what it borrows only until it completes, so its output // may borrow none of it. - let (held, lent) = self.lifetimes(unbound.output()); - if eager && borrows && held.iter().chain(&lent).any(|region| !statics.contains(region)) { + if eager && borrows && self.output_borrows(unbound.output(), inner, &statics) { errs.push(why( "borrowing output of a future from a function that is not async", inner.to_string(), @@ -3639,10 +3638,13 @@ impl<'tcx> Collector<'tcx> { let sig = tcx.fn_sig(def_id).instantiate(tcx, tcx.mk_args(base)).skip_norm_wip(); // An `async fn`'s future, or a returned `impl Trait`, captures it. kept |= sig.skip_binder().output().walk().any(|arg| arg == param.into()); - // A `Copy` object, which C lends as its handle and hands back as a new one. + // A `Copy` object, which C lends as its handle and hands back as a new one; not one + // an opaque handle holds, which the closure would take as the handle's `rt::Owned`. let env = TypingEnv::post_analysis(tcx, def_id); let copied = - |ty: Ty<'tcx>, mapped: &Type| matches!(mapped, Type::Object(_)) && tcx.type_is_copy_modulo_regions(env, ty); + |ty: Ty<'tcx>, mapped: &Type| { + matches!(mapped, Type::Object(_)) && self.opaque_value(ty).is_none() && tcx.type_is_copy_modulo_regions(env, ty) + }; // Each parameter makes its own closure, which one type parameter cannot name twice. if sig .skip_binder() @@ -4158,6 +4160,28 @@ impl<'tcx> Collector<'tcx> { } } + /// Whether the output of the future `future` may name a lifetime outside `statics`, + /// whatever type holds it: an `impl Future`'s by what its bounds name; another future's, + /// whose lifetimes `output` has erased, by naming any at all. + fn output_borrows(&self, future: Ty<'tcx>, output: Ty<'tcx>, statics: &[ty::Region<'tcx>]) -> bool { + let tcx = self.tcx; + let ty::Alias( + _, + ty::AliasTy { + kind: ty::AliasTyKind::Opaque { def_id }, + args, + .. + }, + ) = future.kind() + else { + return output.walk().any(|arg| arg.as_region().is_some()); + }; + (tcx.explicit_item_bounds(*def_id).skip_binder().iter()) + .filter_map(|&(clause, _)| clause.as_projection_clause()?.skip_binder().term.as_type()) + .map(|term| ty::EarlyBinder::bind(tcx, term).instantiate(tcx, args).skip_norm_wip()) + .any(|term| term.walk().any(|arg| arg.as_region().is_some_and(|r| !statics.contains(&r)))) + } + /// The lifetimes in `ty`: those its objects take, then those it borrows with. fn lifetimes(&self, ty: Ty<'tcx>) -> (Vec>, Vec>) { let mut held = Vec::new(); diff --git a/quest/m1/ffi-refusals/moq-excluded.md b/quest/m1/ffi-refusals/moq-excluded.md index 61bedf892..6a98f5dee 100644 --- a/quest/m1/ffi-refusals/moq-excluded.md +++ b/quest/m1/ffi-refusals/moq-excluded.md @@ -14,21 +14,23 @@ future, and a lent object field in place: 11 items. [The epic](/quest/m1/ffi-refusals/README.md)'s decisions apply: rust2 asks moq for no source change, and what C can never hold is left out and listed. Measure again first. +The maintainer kept this quest on 2026-11-13 and accepted each recommendation below as its plan. + - `std::io::Error` taken by value (`accept::Failure::classify`, `accept::Health::failed`) - and `std::net::IpAddr` (`quic::demux::Datagram::local`). Recommended: `IpAddr` crosses + and `std::net::IpAddr` (`quic::demux::Datagram::local`). Decided: `IpAddr` crosses as `SocketAddr` already does, by family; `io::Error` as an opaque handle, as another crate's value now is, with the standard library no longer exempt. - Trait objects: `quic::Controller`'s `Arc` field and `tls::Serve::resolver`'s `Arc`. - Recommended: an opaque handle to the `Arc`, as another crate's `Arc` already is. + Decided: an opaque handle to the `Arc`, as another crate's `Arc` already is. - Generic parameters: `server::Request::within` (`impl Future`), `websocket::Listener::with_protocols` (`impl IntoIterator>`), `tcp::TlsAcceptor::offered` (`impl Iterator`), and `tcp::TlsAcceptor::accept` (an IO - stream). Recommended: `AsRef` items as strings and an `Iterator` parameter as the + stream). Decided: `AsRef` items as strings and an `Iterator` parameter as the array of its items, as returns already are; a foreign future as #705's is; the IO stream left out as what C can never hold, since no export returns one. - `server::Config::websocket`, a borrowed `Option` of a listener that is not `Clone`. - Recommended: lent as `Some` of a handle, as a bare field now is. + Decided: lent as `Some` of a handle, as a bare field now is. - `server::Listener::accept_with`'s future is not `Send`. Left out today as what C can never hold, since it takes a `qmux::Session` no export returns once the excludes go; confirm the census lists it so. From 9a2f0f1d3b77201c627c4233eaf811223777c075 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:18:26 -0800 Subject: [PATCH 14/24] style(ffi): format --- ffi/src/collect.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 43646d010..556408c1f 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -3641,10 +3641,11 @@ impl<'tcx> Collector<'tcx> { // A `Copy` object, which C lends as its handle and hands back as a new one; not one // an opaque handle holds, which the closure would take as the handle's `rt::Owned`. let env = TypingEnv::post_analysis(tcx, def_id); - let copied = - |ty: Ty<'tcx>, mapped: &Type| { - matches!(mapped, Type::Object(_)) && self.opaque_value(ty).is_none() && tcx.type_is_copy_modulo_regions(env, ty) - }; + let copied = |ty: Ty<'tcx>, mapped: &Type| { + matches!(mapped, Type::Object(_)) + && self.opaque_value(ty).is_none() + && tcx.type_is_copy_modulo_regions(env, ty) + }; // Each parameter makes its own closure, which one type parameter cannot name twice. if sig .skip_binder() @@ -4179,7 +4180,10 @@ impl<'tcx> Collector<'tcx> { (tcx.explicit_item_bounds(*def_id).skip_binder().iter()) .filter_map(|&(clause, _)| clause.as_projection_clause()?.skip_binder().term.as_type()) .map(|term| ty::EarlyBinder::bind(tcx, term).instantiate(tcx, args).skip_norm_wip()) - .any(|term| term.walk().any(|arg| arg.as_region().is_some_and(|r| !statics.contains(&r)))) + .any(|term| { + term.walk() + .any(|arg| arg.as_region().is_some_and(|r| !statics.contains(&r))) + }) } /// The lifetimes in `ty`: those its objects take, then those it borrows with. From 4ba1788a9be65595443cdeef1704e76904bf5aaf Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 11:01:06 -0800 Subject: [PATCH 15/24] test(ffi): reject a borrowed slice of Copy opaque values and a conversion to one --- ffi/fixtures/reject/src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index 6f8ab1ef4..457166c11 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -185,6 +185,26 @@ pub fn mint(f: impl FnOnce() -> tls::Token) -> u32 { f().0 } +/// Returns another crate's `Copy` value, which a handle holds. +pub fn token() -> tls::Token { + tls::Token(2) +} + +/// Borrows a slice of them, whose handles C would have to give up. +pub fn spent(tokens: &[tls::Token]) -> u32 { + tokens.iter().map(|t| t.0).sum() +} + +/// Returns another crate's value, which a handle holds. +pub fn issue() -> tls::Cert { + tls::Cert::new(b"der") +} + +/// Takes what converts into it, which only inference could name in the glue. +pub fn adopt(cert: impl Into) -> usize { + cert.into().der().len() +} + impl Cell { pub fn new(value: T) -> Self { Self(value) From 0d3a7f732a125fa03d965498fd2dc364b96b8e5c Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 11:46:03 -0800 Subject: [PATCH 16/24] fix(ffi): refuse a borrowed aggregate of Copy opaque values and a conversion only inference names Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/reject/expected.txt | 230 ++++++++++++++++--------------- ffi/src/collect.rs | 15 +- 2 files changed, 126 insertions(+), 119 deletions(-) diff --git a/ffi/fixtures/reject/expected.txt b/ffi/fixtures/reject/expected.txt index 39c783c85..47ef9a644 100644 --- a/ffi/fixtures/reject/expected.txt +++ b/ffi/fixtures/reject/expected.txt @@ -1,22 +1,25 @@ -fixtures/reject/src/lib.rs:1002: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:1008: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:1010:2: note: has this discriminant -fixtures/reject/src/lib.rs:1015: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:1017:2: note: has this discriminant -fixtures/reject/src/lib.rs:1022: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:1024:2: note: has this discriminant -fixtures/reject/src/lib.rs:1028:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1033:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1039:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1053:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1059:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1006: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:1012: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:1017: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:1022: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:1028: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:1030:2: note: has this discriminant +fixtures/reject/src/lib.rs:1035: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:1037:2: note: has this discriminant +fixtures/reject/src/lib.rs:1042: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:1044:2: note: has this discriminant +fixtures/reject/src/lib.rs:1048:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1053:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1059:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:105:1: rust2-ffi: cannot export fn `forever`: 'static borrow `&'static [u8]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1064:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1069: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:1059:1: note: C cannot implement `Trusted`: unsafe trait -fixtures/reject/src/lib.rs:1074: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:1064:1: note: C cannot implement `Hazard`: unsafe fn `risk` -fixtures/reject/src/lib.rs:1079: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:1073:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1079:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1084:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1089: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:1079:1: note: C cannot implement `Trusted`: unsafe trait +fixtures/reject/src/lib.rs:1094: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:1084:1: note: C cannot implement `Hazard`: unsafe fn `risk` +fixtures/reject/src/lib.rs:1099: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:111:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:11:1: rust2-ffi: cannot export fn `map`: foreign type `std::collections::HashMap`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:133:2: rust2-ffi: cannot export method `Link::session`: borrowed return that is not Clone `tls::Session`; exclude it in the config to leave it out @@ -30,109 +33,108 @@ fixtures/reject/src/lib.rs:16:1: rust2-ffi: cannot export fn `generic`: generic fixtures/reject/src/lib.rs:174: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:179:1: rust2-ffi: cannot export fn `spend`: closure signature `tls::Token`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:184:1: rust2-ffi: cannot export fn `mint`: closure signature `tls::Token`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:196: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:215: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:194:1: rust2-ffi: cannot export fn `spent`: reference to a handle inside a value `[tls::Token]`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:204: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:216: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: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:226: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:229: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:240: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:249: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:260:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:265:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:270: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:275: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:278: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:283: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:286: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:294:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:304: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:309: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:235: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:246: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:249: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:260: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:269: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:280:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:285:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:290: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:295: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:298: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:303: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:306: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: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:314: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:319: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:324: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:329: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:334: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:340: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:346: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:351: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:356: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:314:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:324: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:329: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:334: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:339: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:344: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:349: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:354: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:35:1: rust2-ffi: cannot export static `COUNT`: static; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:361: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:366: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:371: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:383: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:398: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:360: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:366: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:371: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:376: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:381: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:386: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:391: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:39:1: rust2-ffi: cannot export macro `noop`: macro; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:403: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:408: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:422: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:436: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:451: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:466: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:403: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:418: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:423: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:428: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:442: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:456: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:471: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:47:1: rust2-ffi: cannot export fn `excluded`: excluded type `Excluded`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:489: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:504:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:496:1: note: applies past the recursion limit +fixtures/reject/src/lib.rs:486: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:509: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:524:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out + fixtures/reject/src/lib.rs:516:1: note: applies past the recursion limit 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:534: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:511:1: note: `std::string::String` converts too, which C passes alike -fixtures/reject/src/lib.rs:539:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:544: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:549: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:554: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:559: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:585: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:590: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:564:1: note: C cannot implement `Source`: callback signature `items` -fixtures/reject/src/lib.rs:595:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:600: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:600:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:607: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:607:20: note: `'b` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:614: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:614:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:623:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:629: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:635: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:652: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:669: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:554: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:531:1: note: `std::string::String` converts too, which C passes alike +fixtures/reject/src/lib.rs:559:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:564: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:569: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:574: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:579: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:605: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:610: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:584:1: note: C cannot implement `Source`: callback signature `items` +fixtures/reject/src/lib.rs:615:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:620: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:620:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:627: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:627:20: note: `'b` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:634: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:634:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:643:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:649: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:655: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: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:692: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:672: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:689: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: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:706: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:711: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:718: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:724: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:729: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:734: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:754: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:761: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:712: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:726: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:731: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:738: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:744: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:749: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:754: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:774: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: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:785: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:803: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:808: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:813: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:819: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:825: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:836:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:855: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:860: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:867: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:874: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:879: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:886: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:891: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:896: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:901: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:914: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:925: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:928: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:939:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:957:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:963: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:979: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:986: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:992: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:997: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:781: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:805: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:823: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:828: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:833: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:839: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:845: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:856:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:875: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:880: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:887: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:894: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:899: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:906: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:911: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:916: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:921: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:934: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:945: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:948: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:959:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:977:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:983: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:999: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: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 diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 556408c1f..010316782 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -3218,8 +3218,12 @@ impl<'tcx> Collector<'tcx> { } candidates.extend(self.vec_of(tcx.types.u8).map(|ty| (ty, None))); // `impl Into>` takes a `String` too, which maps where `Arc` does not. + // Not another crate's type a handle holds: the glue never names it, so nothing would + // fix the call's type argument. candidates.retain(|&(candidate, _)| { - self.at(def_id, param, base, candidate).is_some() && self.maps(candidate, Pos::Param) + self.at(def_id, param, base, candidate).is_some() + && self.maps(candidate, Pos::Param) + && !(candidate.walk().filter_map(|arg| arg.as_type())).any(|ty| self.is_opaque(ty)) }); // Two sources that C passes as one buffer but that hold different values, as a // `String` and a `Vec` do, leave the caller no say in which conversion runs. Forms @@ -4266,14 +4270,15 @@ impl<'tcx> Collector<'tcx> { } } - /// Whether `ty` holds an object that is not `Copy`, which a copy would duplicate. + /// Whether `ty` holds a handle a copy would duplicate: an object that is not `Copy`, or any opaque one. fn holds_handle(&self, ty: Ty<'tcx>) -> bool { let tcx = self.tcx; ty.walk().filter_map(|arg| arg.as_type()).any(|ty| match ty.kind() { ty::Adt(adt, args) => { - let object = matches!(self.decl(adt.did(), args), Some(Decl::Object(_))) - || self.foreign.iter().any(|&(ty, _)| ty == adt.did()); - object && !implements(tcx, ty, adt.did(), sym::Copy) + // An opaque handle is never copied, even of a `Copy` value: lifting takes it. + let opaque = self.foreign.iter().any(|&(ty, _)| ty == adt.did()); + let object = matches!(self.decl(adt.did(), args), Some(Decl::Object(_))); + opaque || object && !implements(tcx, ty, adt.did(), sym::Copy) } _ => false, }) From faf44c8e2ba6b929159ff168b38e19d7234cec2b Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 12:00:33 -0800 Subject: [PATCH 17/24] fix(ffi): deref GenericArgs after the nightly bump Co-Authored-By: Claude Opus 5.5 --- ffi/src/collect.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 458ddfbd0..fd2bb856b 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -2235,7 +2235,7 @@ impl<'tcx> Collector<'tcx> { // 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. let lends = !self.is_clone(ty) - && matches!(ty.kind(), ty::Adt(adt, args) if matches!(self.decl(adt.did(), args), Some(Decl::Object(_)))); + && matches!(ty.kind(), ty::Adt(adt, args) if matches!(self.decl(adt.did(), *args), Some(Decl::Object(_)))); let mapped = { self.lending.set(lends); let get = self.ty(read, Pos::Return); From ba62a8ec1b1b4514b0735024d1b6df087f2d37d2 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 17:42:29 -0800 Subject: [PATCH 18/24] fix(ffi): drop the excludes this branch exports at the pin, and re-measure moq-excluded load_roots, Client::connect, and four quic driver futures export at the pin; RootCertStore's reach adds Der::from_slice, refused as CertificateDer::from_slice is. moq-excluded lists what #721's reach adds at moq's main, with four new decisions. Co-Authored-By: Claude Opus 5.5 --- ffi/README.md | 6 +++--- ffi/moq/ffi.toml | 7 +------ quest/m1/ffi-refusals/moq-excluded.md | 30 ++++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/ffi/README.md b/ffi/README.md index 26b64a558..8c87d79d9 100644 --- a/ffi/README.md +++ b/ffi/README.md @@ -81,8 +81,8 @@ another of its name shares, the facade's root names, or another registry serves reached. A crate only signatures reach keeps the roles of one no export is: its error in a `Result` crosses as its message, and its type behind an `Arc` as an opaque handle, refused bare. Its errors, the types implementing `std::error::Error`, are never reached, so an -exported error holding one is an object, as it was. A type no public path names stays -refused. +exported error holding one is an object, as it was. A type it cannot reach, such as one no +public path names, or an error taken by value, is held by value as an opaque handle instead. | Rust | C | | --- | --- | @@ -114,7 +114,7 @@ refused. | `SocketAddr`, `SocketAddrV4`, `SocketAddrV6` | `_socket_addr`: its IP's bytes, port, and whether it is IPv6; one of the other family passed to `V4` or `V6` aborts | | `url::Url` | an object `_Url`, made by `_Url_parse`, which fails with the parse error's message, and printed by `_to_string` | | `Arc` of another crate's `Send` and `Sync` type that no other rule maps, such as `Arc` | an opaque object named by `T`'s crate and name, such as `_rustls_ServerConfig`, with `_clone` and `_free` and none of `T`'s API: it only passes back to Rust | -| another crate's `Send` and `Sync` type taken or returned by value or lent, with no type parameters, that no other rule maps and that is no iterator, such as `rustls_pki_types::CertificateDer<'static>` | an opaque object named as the `Arc` form is, with `_free` and none of `T`'s API, holding the value: Rust takes it back by value, or borrows it; a type also named behind an `Arc` is that form, and refused by value | +| another crate's `Send` and `Sync` type taken or returned by value or lent, with no type parameters, that no other rule maps, that is no iterator, and that is not reached by its public path, such as one only a `#[doc(hidden)]` module names | an opaque object named as the `Arc` form is, with `_free` and none of `T`'s API, holding the value: Rust takes it back by value, or borrows it; a type also named behind an `Arc` is that form, and refused by value | | `std::time::Instant` | an object `_Instant`, which only Rust makes, copied into each call that takes it and compared by `_eq`, with none of its methods | | `tracing::Level` | `_Level`: a C enum of its five levels, `TRACE` to `ERROR` | | `tracing::level_filters::LevelFilter` | `Option`, whose `None` is `OFF` | diff --git a/ffi/moq/ffi.toml b/ffi/moq/ffi.toml index 96a64d9d8..4f87d828e 100644 --- a/ffi/moq/ffi.toml +++ b/ffi/moq/ffi.toml @@ -3,7 +3,6 @@ # still has to cover. `kio` is moq-net's re-export of all of kio, of which moq-ffi ships # only what the facade re-exports. exclude = [ - "Client::connect", "bytes", "clock::Deadlines::enter", "clock::Entered", @@ -17,15 +16,11 @@ exclude = [ "moq_tokio::accept::Health::failed", "moq_tokio::quic::Controller::0", "moq_tokio::quic::demux::Datagram::local", - "moq_tokio::quic::driver::connection::Connection::close_reason", - "moq_tokio::quic::driver::connection::Connection::closed", "moq_tokio::quic::driver::connection::Connection::congestion_state", "moq_tokio::quic::driver::connection::Connection::poll_closed", - "moq_tokio::quic::driver::connection::Connection::read_datagram", "moq_tokio::quic::driver::recv::Stream::read", "moq_tokio::quic::driver::recv::Stream::read_exact", "moq_tokio::quic::driver::send::Options::group", - "moq_tokio::quic::driver::send::Stream::stopped", "moq_tokio::quic::driver::send::Stream::write", "moq_tokio::tcp::TlsAcceptor::accept", "moq_tokio::tcp::TlsAcceptor::offered", @@ -69,8 +64,8 @@ exclude = [ "rustls::ConfigBuilder", "rustls::client::Resumption::store", "rustls_pki_types::CertificateDer::from_slice", + "rustls_pki_types::Der::from_slice", "tokio::server::Config::websocket", "tokio::server::Request::within", - "tokio::tls::Listen::load_roots", "tokio::tls::Serve::resolver", ] diff --git a/quest/m1/ffi-refusals/moq-excluded.md b/quest/m1/ffi-refusals/moq-excluded.md index 6a98f5dee..261ab185b 100644 --- a/quest/m1/ffi-refusals/moq-excluded.md +++ b/quest/m1/ffi-refusals/moq-excluded.md @@ -5,9 +5,10 @@ Each construct `just ffi census ` still refuses at moq's `main` behind an exclude in `ffi/moq/ffi.toml` exports by a rule, or is left out as what C can never hold, beyond `NonZero`, which exports, and the types -[not-send](/quest/m1/ffi-export/not-send.md) exports. Measured on 2026-11-12 at moq -`04f63af`, with the rules for another crate's value, a non-`async` function's borrowing -future, and a lent object field in place: 11 items. +[not-send](/quest/m1/ffi-export/not-send.md) exports. Measured on 2026-11-13 at moq +`98e54e7`, with #721's reach of other crates' types and the rules for another crate's +value, a non-`async` function's borrowing future, and a lent object field in place: 23 +items beyond not-send's, 13 of them in crates #721 newly reaches. ## Plan @@ -35,4 +36,27 @@ The maintainer kept this quest on 2026-11-13 and accepted each recommendation be never hold, since it takes a `qmux::Session` no export returns once the excludes go; confirm the census lists it so. +- Reached since #721 exports other crates' types with their API: rustls's + `ClientConfig` fields of `Arc` (5) and `client::Resumption::store`, under the + trait-object decision above. And four constructs no decision covers yet, listed under + Waiting: `CertificateDer::from_slice` and `Der::from_slice` (a `'static` borrow, + `&'a [u8]` of a handle's `'static` lifetime), the two `rustls::ConfigBuilder` instances (`ServerConfig` by value, which an `Arc` elsewhere holds), + `qmux::Session::connect` and `accept` (a type parameter bounded by qmux's `Transport`), + and `moq_sock::demux::Discard::ALL` (`[Discard; 4]`, an array of a non-`u8` element). + Public API: the generated API of each item that newly exports. + +## Waiting + +- Maintainer: a `'static` borrow parameter (`CertificateDer::from_slice`, + `Der::from_slice`). Recommended: left out and listed as what C can never hold, since C + lends only for the call; rejected: copy into a leaked buffer, which never frees. +- Maintainer: a type both by value and in an `Arc` (`ConfigBuilder`). + Recommended: left out and listed, as a type argument no handle can name; rejected: a + second, by-value handle, which `Arc::try_unwrap` would need at run time. +- Maintainer: a type parameter bounded by another crate's trait (`qmux::Session::connect`, + `accept`, over `Transport`). Recommended: left out and listed, since no export returns a + `Transport`; rejected: a callback trait for it, which C would implement over raw IO. +- Maintainer: an array of a non-`u8` element (`Discard::ALL`). Recommended: crosses as the + `Vec` of its elements, as a returned slice does; rejected: left out. From b71ab2ee0715fca5cc96496a762bbcee425c54e7 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 17:42:43 -0800 Subject: [PATCH 19/24] style(ffi): format Co-Authored-By: Claude Opus 5.5 --- ffi/tests/fixtures.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index 514120412..db04f0d2a 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -1557,7 +1557,10 @@ fn unreached_types() { // alone is refused as unreached, though an alias names it. `net`'s error in `Failure` is // never reached, so a handle holds it by value, and `Failure`, which holds it, is an object. assert!(report.contains("| Types | 6 | 0 |"), "{report}"); - assert!(report.contains("- `Failure`: object in a value `net::Fault`"), "{report}"); + assert!( + report.contains("- `Failure`: object in a value `net::Fault`"), + "{report}" + ); // 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 [ From d61e4ee98e25a8072cc6c9d3ad0b5cea368d5f28 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 18:05:10 -0800 Subject: [PATCH 20/24] fix(ffi): review round 1: pinned optional slices, message-only error lifetimes, opaque waiters - An eager future's held argument is read through its heap reference wherever the call's argument names it, not only as `&a`/`&mut a`, so `Option<&[u32]>` builds (`Channel::itemized`, exercised in every language). - A `Result`'s error of another crate crosses as its message, so its lifetimes no longer count as a returned object's (`parse_cert` exports). - An opaque by-value type is never a synthesized waiter, whose constructor the glue cannot name; it crashed the merge (reject fixture `poll_ready`). Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/api/examples/transcript.rs | 6 + ffi/fixtures/api/src/lib.rs | 20 ++ ffi/fixtures/reject/expected.txt | 261 ++++++++++++------------ ffi/fixtures/reject/src/lib.rs | 11 + ffi/fixtures/tls/src/lib.rs | 26 +++ ffi/src/collect.rs | 25 ++- ffi/src/glue.rs | 27 ++- ffi/tests/api.c | 10 +- ffi/tests/api.cpp | 7 + ffi/tests/api.dart | 1 + ffi/tests/api.go | 1 + ffi/tests/api.kt | 1 + ffi/tests/api.py | 1 + ffi/tests/api.swift | 1 + ffi/tests/fixtures.rs | 2 + 15 files changed, 260 insertions(+), 140 deletions(-) diff --git a/ffi/fixtures/api/examples/transcript.rs b/ffi/fixtures/api/examples/transcript.rs index d41c13511..3756b9e87 100644 --- a/ffi/fixtures/api/examples/transcript.rs +++ b/ffi/fixtures/api/examples/transcript.rs @@ -367,6 +367,12 @@ fn main() { if let Poll::Ready(text) = tagged.as_mut().poll(&mut cx) { println!("tagged {text}"); } + // So does a future borrowing an optional slice, which the export owns while it is pending. + let items = [1u32, 2, 3]; + let mut itemized = pin!(channel.itemized(Some(&items))); + if let Poll::Ready(count) = itemized.as_mut().poll(&mut cx) { + println!("itemized {count}"); + } channel.send(Bytes::from_static(b"sized")); let mut sized = pin!(channel.recv_sized()); if let Poll::Ready((payload, len)) = sized.as_mut().poll(&mut cx) { diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index e89839b44..63028c469 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -882,6 +882,17 @@ impl Channel { } } + /// Sends the sum of `items`, if any, at once, and returns a future that borrows them: + /// their count once this channel next receives. + pub fn itemized<'a>(&'a self, items: Option<&'a [u32]>) -> impl Future + 'a { + let sum: u32 = items.unwrap_or_default().iter().sum(); + self.send(Bytes::copy_from_slice(&sum.to_le_bytes())); + async move { + self.recv().await; + items.map_or(0, <[u32]>::len) + } + } + /// `recv`'s poll, which does not map: left out, since `recv` exports as a future. pub fn poll_recv(&self, cx: &mut std::task::Context<'_>) -> Poll { let mut state = self.state.lock().unwrap(); @@ -2316,6 +2327,15 @@ pub fn verify(cert: &tls::held::Cert) -> Result { } } +/// `text`'s length, or why it is no certificate: another crate's error borrowing `text`, +/// which crosses as its message, so nothing outlives the call. +pub fn parse_cert(text: &str) -> Result> { + match text.is_empty() { + true => Err(tls::held::Malformed(text)), + false => Ok(text.len() as u32), + } +} + /// Another crate's error taken back by value, which no export returns: left out. pub fn blame(err: tls::held::Invalid) -> String { err.to_string() diff --git a/ffi/fixtures/reject/expected.txt b/ffi/fixtures/reject/expected.txt index 1ea9a95c9..389b4246f 100644 --- a/ffi/fixtures/reject/expected.txt +++ b/ffi/fixtures/reject/expected.txt @@ -1,144 +1,145 @@ -fixtures/reject/src/lib.rs:1006: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:1012: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:1017: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:1022: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:1028: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:1030:2: note: has this discriminant -fixtures/reject/src/lib.rs:1035: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:1037:2: note: has this discriminant -fixtures/reject/src/lib.rs:1042: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:1044:2: note: has this discriminant -fixtures/reject/src/lib.rs:1048:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1053:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1059:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1010: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:1017: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:1023: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:1028: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:1033: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:1039: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:1041:2: note: has this discriminant +fixtures/reject/src/lib.rs:1046: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:1048:2: note: has this discriminant +fixtures/reject/src/lib.rs:1053: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:1055:2: note: has this discriminant +fixtures/reject/src/lib.rs:1059:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out fixtures/reject/src/lib.rs:105:1: rust2-ffi: cannot export fn `forever`: 'static borrow `&'static [u8]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1073:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1079:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1084:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1089: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:1079:1: note: C cannot implement `Trusted`: unsafe trait -fixtures/reject/src/lib.rs:1094: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:1084:1: note: C cannot implement `Hazard`: unsafe fn `risk` -fixtures/reject/src/lib.rs:1099: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:1104: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:1109: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:1114: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:1119: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:1064:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1070:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1084:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1090:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1095:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1100: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:1090:1: note: C cannot implement `Trusted`: unsafe trait +fixtures/reject/src/lib.rs:1105: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:1095:1: note: C cannot implement `Hazard`: unsafe fn `risk` +fixtures/reject/src/lib.rs:1110: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:1115: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:111:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1120: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:1125: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:1130: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:11:1: rust2-ffi: cannot export fn `map`: foreign type `std::collections::HashMap`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:133:2: rust2-ffi: cannot export method `Link::session`: borrowed return that is not Clone `tls::held::Handoff`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:150: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:155: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:155: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:158: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:164: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:169: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:127:1: rust2-ffi: cannot export fn `poll_ready`: Poll with no Context or waiter parameter `std::task::Poll`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:144:2: rust2-ffi: cannot export method `Link::session`: borrowed return that is not Clone `tls::held::Handoff`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:161: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:166: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:166: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:169: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: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:174: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:179: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:184: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:194: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:204: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:216: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:175: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:180: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:185: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:190: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:195: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:205: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:215: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: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:235: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:246: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:249: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:260: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:269: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:280:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:285:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:290: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:295: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:298: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:303: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:306: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:227: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:246: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:257: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:260: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:271: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:280: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:291:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:296:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:301: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:306: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:309: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: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:314:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:324: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:329: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:334: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:339: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:344: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:349: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:354: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:314: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:317: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:325:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:335: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:340: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:345: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:350: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:355: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:35:1: rust2-ffi: cannot export static `COUNT`: static; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:360: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:366: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:371: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:376: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:381: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:386: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:391: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:360: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:365: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:371: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:377: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:382: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:387: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:392: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:397: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:39:1: rust2-ffi: cannot export macro `noop`: macro; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:403: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:418: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:423: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:428: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:442: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:456: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:471: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:402: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:414: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:429: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:434: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:439: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:453: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:467: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`: excluded type `Excluded`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:486: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:509: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:524:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:516:1: note: applies past the recursion limit +fixtures/reject/src/lib.rs:482: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:497: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:520: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:52:1: rust2-ffi: cannot export fn `letters`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:554: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:531:1: note: `std::string::String` converts too, which C passes alike -fixtures/reject/src/lib.rs:559:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:564: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:569: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:574: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:579: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:605: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:610: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:584:1: note: C cannot implement `Source`: callback signature `items` -fixtures/reject/src/lib.rs:615:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:620: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:620:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:627: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:627:20: note: `'b` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:634: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:634:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:643:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:649: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:655: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:535:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out + fixtures/reject/src/lib.rs:527:1: note: applies past the recursion limit +fixtures/reject/src/lib.rs:565: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:542:1: note: `std::string::String` converts too, which C passes alike +fixtures/reject/src/lib.rs:570:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:575: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:580: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:585: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:590: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:616: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:621: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:595:1: note: C cannot implement `Source`: callback signature `items` +fixtures/reject/src/lib.rs:626:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:631: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:631:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:638: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:638:20: note: `'b` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:645: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:645:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:654:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:660: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:666: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: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:672: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:689: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:683: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:6:1: rust2-ffi: cannot export fn `pair`: tuple of references `(&str, u8)`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:712:1: rust2-ffi: cannot export fn `pumped`: foreign type `std::iter::Flatten`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:726: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:731: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:738: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:744: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:749: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:754: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:774: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:700: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:723: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:737: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:742: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:749: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:755: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:760: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:765: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: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:781: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:805: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:823: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:828: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:833: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:839: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:845: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:856:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:875: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:880: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:887: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:894: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:899: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:906: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:911: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:916: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:921: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:934: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:945: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:948: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:959:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:977:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:983: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:999: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:785: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:792: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:816: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:834: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:839: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:844: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:850: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:856: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:867:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:886: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:891: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:898: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:905: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:910: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:917: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:922: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:927: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:932: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:945: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:956: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:959: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:970:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:988:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:994: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: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 diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index 68137205d..cb976bb89 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -117,6 +117,17 @@ pub struct Size { pub bytes: u64, } +/// A waiter of another crate, which a handle holds by value. +pub fn waiter() -> tls::held::Waiter { + tls::held::Waiter::new(std::task::Waker::noop().clone()) +} + +/// Not a poll through [`waiter`]'s: the glue cannot name the type a handle holds to make one +/// from the poll's waker. +pub fn poll_ready(_waiter: &tls::held::Waiter) -> std::task::Poll { + std::task::Poll::Ready(1) +} + /// An object holding another crate's session, which C holds as a handle. pub struct Link { session: tls::held::Handoff, diff --git a/ffi/fixtures/tls/src/lib.rs b/ffi/fixtures/tls/src/lib.rs index 32b21ef65..56d240db0 100644 --- a/ffi/fixtures/tls/src/lib.rs +++ b/ffi/fixtures/tls/src/lib.rs @@ -115,6 +115,32 @@ pub mod held { impl std::error::Error for Invalid {} + /// Why text is not a certificate, borrowing the text: an error that crosses as its + /// message, so the borrow ends with the call. + #[derive(Debug)] + pub struct Malformed<'a>(pub &'a str); + + impl std::fmt::Display for Malformed<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "malformed: {}", self.0) + } + } + + impl std::error::Error for Malformed<'_> {} + + /// What a poll registers its waker with, made from the waker alone, as kio's `Waiter` is. + pub struct Waiter(std::task::Waker); + + impl Waiter { + pub fn new(waker: std::task::Waker) -> Self { + Self(waker) + } + + pub fn wake(&self) { + self.0.wake_by_ref(); + } + } + /// A count that is not `Send`, which the reject fixture takes by value: no handle may hold it. pub struct Local(std::rc::Rc); diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index b2891bfe7..ec6b8acf8 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -4283,9 +4283,25 @@ impl<'tcx> Collector<'tcx> { errs.push(why); } } - // A returned object's lifetimes are `'static` too, which no lent borrow may be. + // A returned object's lifetimes are `'static` too, which no lent borrow may be; not a + // `Result`'s error of another crate, which crosses as its message. + let output = match sig.output().kind() { + ty::Adt(adt, args) + if tcx.is_diagnostic_item(sym::Result, adt.did()) + && self.opaque_value(args.type_at(1)).is_some() + && implements( + tcx, + ty::fold_regions(tcx, args.type_at(1), |_, _| tcx.lifetimes.re_erased), + def_id, + rustc_span::sym::Display, + ) => + { + args.type_at(0) + } + _ => sig.output(), + }; let returned = statics.len(); - for region in self.lifetimes(sig.output()).0 { + for region in self.lifetimes(output).0 { if !statics.contains(®ion) { statics.push(region); } @@ -4560,8 +4576,9 @@ impl<'tcx> Collector<'tcx> { ty::Mutability::Mut => Mutability::Mut, })); } - // A generic type's constructor may belong to another of its instances. - if !polled || m == ty::Mutability::Mut || !args.is_empty() { + // A generic type's constructor may belong to another of its instances, and the glue + // cannot name an opaque handle's type to call its constructor. + if !polled || m == ty::Mutability::Mut || !args.is_empty() || self.opaque_value(inner).is_some() { return None; } let Ok(Type::Object(object)) = self.ty(inner, Pos::Behind) else { diff --git a/ffi/src/glue.rs b/ffi/src/glue.rs index 136bb80d9..5d53ba49f 100644 --- a/ffi/src/glue.rs +++ b/ffi/src/glue.rs @@ -1728,11 +1728,8 @@ impl Gen<'_> { )); } for arg in &mut args { - if let Some(local) = held - .iter() - .find(|l| *arg == format!("&{l}") || *arg == format!("&mut {l}")) - { - *arg = arg.replacen(local.as_str(), &format!("*{local}"), 1); + for local in &held { + *arg = deref_local(arg, local); } } // A future made of a `Poll` calls the function at each poll, passing the poll's @@ -1999,3 +1996,23 @@ fn go_module_resolves_missing_parent() { assert!(generated.check_baseline(&root.join("baseline-link.json")).is_err()); } } + +/// `expr` with each use of the local `name`, a reference, read through it as `(*name)`, so +/// what it lends borrows the referent rather than the local. +fn deref_local(expr: &str, name: &str) -> String { + let ident = |c: char| c.is_alphanumeric() || c == '_'; + let mut out = String::new(); + let mut rest = expr; + while let Some(at) = rest.find(name) { + let (before, after) = (&rest[..at], &rest[at + name.len()..]); + let whole = !before.ends_with(ident) && !after.starts_with(ident); + out.push_str(before); + match whole { + true => out.push_str(&format!("(*{name})")), + false => out.push_str(name), + } + rest = after; + } + out.push_str(rest); + out +} diff --git a/ffi/tests/api.c b/ffi/tests/api.c index ad717f8c3..268ec36da 100644 --- a/ffi/tests/api.c +++ b/ffi/tests/api.c @@ -1078,6 +1078,14 @@ static int script(void) { print("tagged ", tagged_text, "\n"); } api_Channel_tagged_future_free(tagging); + /* So does a future borrowing an optional slice, which the export owns while it is pending. */ + const uint32_t items[] = {1, 2, 3}; + api_Channel_itemized_future *itemizing = api_Channel_itemized(channel, (api_vec_u32){.ptr = items, .len = 3}); + size_t itemized; + if (api_Channel_itemized_poll(itemizing, waker, &itemized) == API_POLL_READY) { + printf("itemized %zu\n", itemized); + } + api_Channel_itemized_future_free(itemizing); api_Channel_send(channel, str("sized")); api_Channel_recv_sized_future *sized = api_Channel_recv_sized(channel); size_t len; @@ -1793,7 +1801,7 @@ static int script(void) { api_Token_free(twice); /* Each future dropped its waker once it finished, and Rust the one it was given. */ - if (drops != 13) { + if (drops != 14) { return 1; } return closures() && foreign_futures() && started_futures() ? 0 : 1; diff --git a/ffi/tests/api.cpp b/ffi/tests/api.cpp index 9d451879a..607aee797 100644 --- a/ffi/tests/api.cpp +++ b/ffi/tests/api.cpp @@ -651,6 +651,13 @@ int script() { print("tagged ", *text, "\n"); } } + // So does a future borrowing an optional slice, which the export owns while it is pending. + { + api::Channel_itemized_future itemized = channel.itemized(std::vector{1, 2, 3}); + if (auto count = itemized.poll(waker)) { + std::printf("itemized %zu\n", *count); + } + } channel.send("sized"); { api::Channel_recv_sized_future sized = channel.recv_sized(); diff --git a/ffi/tests/api.dart b/ffi/tests/api.dart index 4a304097d..a39609670 100644 --- a/ffi/tests/api.dart +++ b/ffi/tests/api.dart @@ -392,6 +392,7 @@ Future script() async { print('recv ${text(await channel.recv())}'); // The send happens at the call, and the future borrows the channel and the tag. print('tagged ${await channel.tagged('tag')}'); + print('itemized ${await channel.itemized(Uint32List.fromList([1, 2, 3]))}'); channel.send(utf8.encode('sized')); final (payload, size) = await channel.recvSized(); print('sized ${text(payload)} $size'); diff --git a/ffi/tests/api.go b/ffi/tests/api.go index 05da65e84..b5b272d71 100644 --- a/ffi/tests/api.go +++ b/ffi/tests/api.go @@ -479,6 +479,7 @@ func script() { fmt.Printf("recv %s\n", must(channel.Recv(ctx)).Copy()) // The send happens at the call, and the future borrows the channel and the tag. fmt.Printf("tagged %s\n", must(channel.Tagged(ctx, "tag"))) + fmt.Printf("itemized %d\n", must(channel.Itemized(ctx, &[]uint32{1, 2, 3}))) // An eager call whose callback cancels its context while it makes its future is never // polled: only the eager half logs. { diff --git a/ffi/tests/api.kt b/ffi/tests/api.kt index 940ead829..994a76e56 100644 --- a/ffi/tests/api.kt +++ b/ffi/tests/api.kt @@ -316,6 +316,7 @@ fun script() { println("recv ${channel.recv().text()}") // The send happens at the call, and the future borrows the channel and the tag. println("tagged ${channel.tagged("tag")}") + println("itemized ${channel.itemized(uintArrayOf(1u, 2u, 3u))}") channel.send("sized".encodeToByteArray()) val (payload, size) = channel.recvSized() println("sized ${payload.text()} $size") diff --git a/ffi/tests/api.py b/ffi/tests/api.py index 79efb014f..39418d0c9 100644 --- a/ffi/tests/api.py +++ b/ffi/tests/api.py @@ -393,6 +393,7 @@ async def block(): print(f"recv {text(await channel.recv())}") # The send happens at the call, and the future borrows the channel and the tag. print(f"tagged {await channel.tagged('tag')}") + print(f"itemized {await channel.itemized(array.array('I', [1, 2, 3]))}") channel.send(b"sized") payload, size = await channel.recv_sized() print(f"sized {text(payload)} {size}") diff --git a/ffi/tests/api.swift b/ffi/tests/api.swift index dc73a52f2..9a9a6aff1 100644 --- a/ffi/tests/api.swift +++ b/ffi/tests/api.swift @@ -462,6 +462,7 @@ func script() { print("recv \(text(try await channel.recv()))") // The send happens at the call, and the future borrows the channel and the tag. print("tagged \(try await channel.tagged("tag"))") + print("itemized \(try await channel.itemized([1, 2, 3]))") channel.send(Data("sized".utf8)) let (payload, size) = try await channel.recvSized() print("sized \(text(payload)) \(size)") diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index db04f0d2a..7331167df 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -1718,6 +1718,8 @@ fn relative_target() { } // 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. + assert!(!text.contains("`parse_cert`"), "the census lists `parse_cert`:\n{text}"); assert!(dir.join("build").exists()); } From 90680804a4204aa85fcb116e8fb59691170a5b45 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 18:18:34 -0800 Subject: [PATCH 21/24] test(ffi): refuse a future whose held foreign error borrows its arguments The glue awaits the future past the call that owns the argument, so the error's borrow would outlive it (E0597, as main generates for every such error). The reject fixture's parse_later locks the refusal; the general case is the future-error-borrow follow-up. Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/reject/expected.txt | 263 +++++++++++---------- ffi/fixtures/reject/src/lib.rs | 9 + quest/m1/ffi-export/future-error-borrow.md | 20 ++ 3 files changed, 161 insertions(+), 131 deletions(-) create mode 100644 quest/m1/ffi-export/future-error-borrow.md diff --git a/ffi/fixtures/reject/expected.txt b/ffi/fixtures/reject/expected.txt index 389b4246f..b850f2d0e 100644 --- a/ffi/fixtures/reject/expected.txt +++ b/ffi/fixtures/reject/expected.txt @@ -1,145 +1,146 @@ -fixtures/reject/src/lib.rs:1010: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:1017: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:1023: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:1028: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:1033: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:1039: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:1041:2: note: has this discriminant -fixtures/reject/src/lib.rs:1046: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:1048:2: note: has this discriminant -fixtures/reject/src/lib.rs:1053: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:1055:2: note: has this discriminant -fixtures/reject/src/lib.rs:1059:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1003: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:1019: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:1026: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:1032: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:1037: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:1042: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:1048: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:1050:2: note: has this discriminant +fixtures/reject/src/lib.rs:1055: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:1057:2: note: has this discriminant fixtures/reject/src/lib.rs:105:1: rust2-ffi: cannot export fn `forever`: 'static borrow `&'static [u8]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1064:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1070:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1084:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1090:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1095:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1100: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:1090:1: note: C cannot implement `Trusted`: unsafe trait -fixtures/reject/src/lib.rs:1105: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:1095:1: note: C cannot implement `Hazard`: unsafe fn `risk` -fixtures/reject/src/lib.rs:1110: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:1115: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:1062: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:1064:2: note: has this discriminant +fixtures/reject/src/lib.rs:1068:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1073:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1079:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1093:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1099:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1104:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1109: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:1099:1: note: C cannot implement `Trusted`: unsafe trait +fixtures/reject/src/lib.rs:1114: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:1104:1: note: C cannot implement `Hazard`: unsafe fn `risk` +fixtures/reject/src/lib.rs:1119: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:111:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1120: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:1125: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:1130: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:1124: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:1129: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:1134: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:1139: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:11:1: rust2-ffi: cannot export fn `map`: foreign type `std::collections::HashMap`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:127:1: rust2-ffi: cannot export fn `poll_ready`: Poll with no Context or waiter parameter `std::task::Poll`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:144:2: rust2-ffi: cannot export method `Link::session`: borrowed return that is not Clone `tls::held::Handoff`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:161: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:166: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:166: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:169: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:122:1: rust2-ffi: cannot export fn `parse_later`: returned object that borrows `impl std::future::Future>>`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:136:1: rust2-ffi: cannot export fn `poll_ready`: Poll with no Context or waiter parameter `std::task::Poll`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:153:2: rust2-ffi: cannot export method `Link::session`: borrowed return that is not Clone `tls::held::Handoff`; exclude it in the config to leave it out fixtures/reject/src/lib.rs: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:175: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:180: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:185: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:190: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:195: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:205: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:215: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:170: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:175: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:175: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:178: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:184: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:189: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:194: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:199: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:204: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:214: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: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:227: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:246: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:257: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:260: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:271: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:280: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:291:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:296:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:301: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:306: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:309: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:224: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:236: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:255: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:266: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:269: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:280: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:289: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:300:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:305:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out fixtures/reject/src/lib.rs: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:314: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:317: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:325:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:335: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:340: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:345: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:350: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:355: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:310: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:315: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:318: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:323: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:326: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:334:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:344: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:349: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:354: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:359: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:35:1: rust2-ffi: cannot export static `COUNT`: static; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:360: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:365: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:371: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:377: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:382: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:387: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:392: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:397: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:364: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:369: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:374: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:380: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:386: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:391: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:396: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:39:1: rust2-ffi: cannot export macro `noop`: macro; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:402: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:414: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:429: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:434: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:439: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:453: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:467: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:401: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:406: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:411: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:423: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 `hold`: generic parameter `std::convert::Into`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:443: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:448: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:462: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:476: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`: excluded type `Excluded`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:482: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:497: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:520: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:491: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:506: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:529: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:52:1: rust2-ffi: cannot export fn `letters`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:535:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:527:1: note: applies past the recursion limit -fixtures/reject/src/lib.rs:565: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:542:1: note: `std::string::String` converts too, which C passes alike -fixtures/reject/src/lib.rs:570:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:575: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:580: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:585: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:590: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:616: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:621: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:595:1: note: C cannot implement `Source`: callback signature `items` -fixtures/reject/src/lib.rs:626:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:631: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:631:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:638: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:638:20: note: `'b` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:645: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:645:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:654:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:660: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:666: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:544:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out + fixtures/reject/src/lib.rs:536:1: note: applies past the recursion limit +fixtures/reject/src/lib.rs:574: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:551:1: note: `std::string::String` converts too, which C passes alike +fixtures/reject/src/lib.rs:579:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:584: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:589: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:594: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:599: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:625: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:630: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:604:1: note: C cannot implement `Source`: callback signature `items` +fixtures/reject/src/lib.rs:635:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:640: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:640:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:647: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:647:20: note: `'b` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:654: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:654:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:663:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:669: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: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:683: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:675: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:692: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: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:700: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:723: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:737: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:742: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:749: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:755: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:760: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:765: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:709: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:732: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:746: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:751: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:758: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:764: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:769: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:774: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: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:785: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:792: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:816: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:834: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:839: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:844: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:850: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:856: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:867:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:886: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:891: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:898: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:905: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:910: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:917: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:922: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:927: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:932: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:945: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:956: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:959: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:970:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:988:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:994: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:794: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:801: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:825: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:843: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:848: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:853: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:859: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:865: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:876:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:895: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:900: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:907: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:914: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:919: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:926: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:931: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:936: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:941: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:954: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:965: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:968: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:979:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:997:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out fixtures/reject/src/lib.rs:99:2: rust2-ffi: cannot export method `Text::later`: returned object that borrows `impl std::future::Future>`; exclude it in the config to leave it out diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index cb976bb89..aa998184e 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -117,6 +117,15 @@ pub struct Size { pub bytes: u64, } +/// Another crate's error borrowing `text`, the output of a future: the glue awaits the +/// future past the call that owns `text`, so the error's borrow would outlive it. +pub async fn parse_later(text: &str) -> Result> { + match text.is_empty() { + true => Err(tls::held::Malformed(text)), + false => Ok(text.len() as u32), + } +} + /// A waiter of another crate, which a handle holds by value. pub fn waiter() -> tls::held::Waiter { tls::held::Waiter::new(std::task::Waker::noop().clone()) diff --git a/quest/m1/ffi-export/future-error-borrow.md b/quest/m1/ffi-export/future-error-borrow.md new file mode 100644 index 000000000..db6d8d50b --- /dev/null +++ b/quest/m1/ffi-export/future-error-borrow.md @@ -0,0 +1,20 @@ +# [S] A future whose error borrows its arguments + +## Goal + +`async fn parse(text: &str) -> Result>`, whose error is another +crate's and crosses as its message, either exports or is refused with a span; today, unless +a handle would hold the error, the export accepts it and generates glue that fails to build +(E0597: the glue awaits the future past the call that owns `text`, and the error's borrow +outlives it). Found on 2026-11-13 by +[kixel-ai/rust2#733](https://github.com/kixel-ai/rust2/pull/733)'s review, which refuses the +held case (`parse_later` in the reject fixture); main has the bug for every such error. + +## Plan + +Recommended: the glue converts a future's error to its message inside the `async` block, +while the arguments the future owns are alive, so the function exports as its sync form +already does (`parse_cert` in the api fixture); the held case's refusal then goes too. +Rejected: refuse every future whose error names a lifetime, which leaves out what maps. + +Public API: each such function newly exports as a future of its `Ok` type and a message. From db8aa63a47b0662a2228951cdd49c43a507fe2da Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 18:42:06 -0800 Subject: [PATCH 22/24] quest: record the maintainer's follow-up answers for #733 Co-Authored-By: Claude Opus 5.5 --- quest/m1/ffi-export/future-error-borrow.md | 8 +++-- quest/m1/ffi-refusals/moq-excluded.md | 36 ++++++++++------------ 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/quest/m1/ffi-export/future-error-borrow.md b/quest/m1/ffi-export/future-error-borrow.md index db6d8d50b..e37a5b6d3 100644 --- a/quest/m1/ffi-export/future-error-borrow.md +++ b/quest/m1/ffi-export/future-error-borrow.md @@ -12,9 +12,11 @@ held case (`parse_later` in the reject fixture); main has the bug for every such ## Plan -Recommended: the glue converts a future's error to its message inside the `async` block, -while the arguments the future owns are alive, so the function exports as its sync form -already does (`parse_cert` in the api fixture); the held case's refusal then goes too. +The maintainer kept this quest on 2026-11-13 (rejected: drop) and decided its fix: +✅ the glue converts the borrowed foreign error to its message inside the `async` block, +as foreign errors already cross, while the arguments the future owns are alive, so nothing +borrowed outlives the call and the function exports as its sync form already does +(`parse_cert` in the api fixture); the held case's refusal then goes too. Rejected: refuse every future whose error names a lifetime, which leaves out what maps. Public API: each such function newly exports as a future of its `Ok` type and a message. diff --git a/quest/m1/ffi-refusals/moq-excluded.md b/quest/m1/ffi-refusals/moq-excluded.md index 261ab185b..1e3a4267b 100644 --- a/quest/m1/ffi-refusals/moq-excluded.md +++ b/quest/m1/ffi-refusals/moq-excluded.md @@ -38,25 +38,21 @@ The maintainer kept this quest on 2026-11-13 and accepted each recommendation be - Reached since #721 exports other crates' types with their API: rustls's `ClientConfig` fields of `Arc` (5) and `client::Resumption::store`, under the - trait-object decision above. And four constructs no decision covers yet, listed under - Waiting: `CertificateDer::from_slice` and `Der::from_slice` (a `'static` borrow, - `&'a [u8]` of a handle's `'static` lifetime), the two `rustls::ConfigBuilder` instances (`ServerConfig` by value, which an `Arc` elsewhere holds), - `qmux::Session::connect` and `accept` (a type parameter bounded by qmux's `Transport`), - and `moq_sock::demux::Discard::ALL` (`[Discard; 4]`, an array of a non-`u8` element). + trait-object decision above. Four more constructs, decided by the maintainer on 2026-11-13: + - A `'static` borrow parameter (`CertificateDer::from_slice`, `Der::from_slice`): + ✅ exported by interning by content (rejected: left out and listed). The binding keeps + one process-wide table keyed by the bytes' contents; the first call with given bytes + copies them into a leaked Rust allocation, and later calls with equal bytes reuse it. + Never key by C's pointer, which C may free or reuse. The generated docs on such a + parameter say memory grows with each distinct value and is never freed. This is sound + for a shared `&'static [u8]`: the copy is immutable and never freed, and equal bytes + differ only by address. Refuse with a span any other `'static` borrow, such as a + `&'static mut` (interning would alias it) or a non-byte element type. + - `rustls::ConfigBuilder`, both by value and behind an `Arc`: + ✅ left out and listed (rejected: a handle everywhere). + - `qmux::Session::connect` and `accept`, bounded by qmux's `Transport`: ✅ left out and + listed (rejected: a callback interface). + - `moq_sock::demux::Discard::ALL` (`[Discard; 4]`): ✅ crosses as the `Vec` of its + elements, as a returned slice does (rejected: left out). Public API: the generated API of each item that newly exports. - -## Waiting - -- Maintainer: a `'static` borrow parameter (`CertificateDer::from_slice`, - `Der::from_slice`). Recommended: left out and listed as what C can never hold, since C - lends only for the call; rejected: copy into a leaked buffer, which never frees. -- Maintainer: a type both by value and in an `Arc` (`ConfigBuilder`). - Recommended: left out and listed, as a type argument no handle can name; rejected: a - second, by-value handle, which `Arc::try_unwrap` would need at run time. -- Maintainer: a type parameter bounded by another crate's trait (`qmux::Session::connect`, - `accept`, over `Transport`). Recommended: left out and listed, since no export returns a - `Transport`; rejected: a callback trait for it, which C would implement over raw IO. -- Maintainer: an array of a non-`u8` element (`Discard::ALL`). Recommended: crosses as the - `Vec` of its elements, as a returned slice does; rejected: left out. From 85cb859794194f35db92f39155f16f540c9a0fa7 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 19:49:55 -0800 Subject: [PATCH 23/24] fix(ffi): a named future is no opaque handle, and a role-mapped type no held handle CodeRabbit's two findings on #733, both reproduced in the api fixture: another crate's future type with no type parameters, such as `Pending<'a>`, passed `opaque_value`, so `byte_len(&[u8]) -> Pending<'_>` was refused as a returned object that borrows; and `holds_handle` took every `FOREIGN` type for an opaque handle, so `&Option` was refused as a reference to a handle inside a value. Co-Authored-By: Claude Opus 5.5 --- ffi/README.md | 2 +- ffi/fixtures/api/examples/transcript.rs | 11 +++++++++++ ffi/fixtures/api/src/lib.rs | 12 ++++++++++++ ffi/fixtures/tls/src/lib.rs | 12 ++++++++++++ ffi/src/collect.rs | 19 +++++++++++++------ ffi/tests/api.c | 11 ++++++++++- ffi/tests/api.cpp | 9 +++++++++ ffi/tests/api.dart | 2 ++ ffi/tests/api.go | 2 ++ ffi/tests/api.kt | 2 ++ ffi/tests/api.py | 2 ++ ffi/tests/api.swift | 2 ++ 12 files changed, 78 insertions(+), 8 deletions(-) diff --git a/ffi/README.md b/ffi/README.md index 96a31c608..850fadb84 100644 --- a/ffi/README.md +++ b/ffi/README.md @@ -114,7 +114,7 @@ public path names, or an error taken by value, is held by value as an opaque han | `SocketAddr`, `SocketAddrV4`, `SocketAddrV6` | `_socket_addr`: its IP's bytes, port, and whether it is IPv6; one of the other family passed to `V4` or `V6` aborts | | `url::Url` | an object `_Url`, made by `_Url_parse`, which fails with the parse error's message, and printed by `_to_string` | | `Arc` of another crate's `Send` and `Sync` type that no other rule maps, such as `Arc` | an opaque object named by `T`'s crate and name, such as `_rustls_ServerConfig`, with `_clone` and `_free` and none of `T`'s API: it only passes back to Rust | -| another crate's `Send` and `Sync` type taken or returned by value or lent, with no type parameters, that no other rule maps, that is no iterator, and that is not reached by its public path, such as one only a `#[doc(hidden)]` module names | an opaque object named as the `Arc` form is, with `_free` and none of `T`'s API, holding the value: Rust takes it back by value, or borrows it; a type also named behind an `Arc` is that form, and refused by value | +| another crate's `Send` and `Sync` type taken or returned by value or lent, with no type parameters, that no other rule maps, that is no iterator or future, and that is not reached by its public path, such as one only a `#[doc(hidden)]` module names | an opaque object named as the `Arc` form is, with `_free` and none of `T`'s API, holding the value: Rust takes it back by value, or borrows it; a type also named behind an `Arc` is that form, and refused by value | | `std::time::Instant` | an object `_Instant`, which only Rust makes, copied into each call that takes it and compared by `_eq`, with none of its methods | | `tracing::Level` | `_Level`: a C enum of its five levels, `TRACE` to `ERROR` | | `tracing::level_filters::LevelFilter` | `Option`, whose `None` is `OFF` | diff --git a/ffi/fixtures/api/examples/transcript.rs b/ffi/fixtures/api/examples/transcript.rs index 3756b9e87..c10132fd2 100644 --- a/ffi/fixtures/api/examples/transcript.rs +++ b/ffi/fixtures/api/examples/transcript.rs @@ -373,6 +373,11 @@ fn main() { if let Poll::Ready(count) = itemized.as_mut().poll(&mut cx) { println!("itemized {count}"); } + // Another crate's future borrowing its bytes, which the export owns while it is pending. + let bytes = *b"abc"; + if let Poll::Ready(len) = pin!(api::byte_len(&bytes)).poll(&mut cx) { + println!("byte_len {len}"); + } channel.send(Bytes::from_static(b"sized")); let mut sized = pin!(channel.recv_sized()); if let Poll::Ready((payload, len)) = sized.as_mut().poll(&mut cx) { @@ -773,6 +778,12 @@ fn main() { start == api::later(start, std::time::Duration::ZERO), start == end ); + // An instant lent inside an `Option`, which takes no handle. + println!( + "has_instant {} {}", + api::has_instant(&Some(start)), + api::has_instant(&None) + ); let mut verbosity = api::Verbosity::new(tracing::Level::WARN); println!( "verbosity {} {}", diff --git a/ffi/fixtures/api/src/lib.rs b/ffi/fixtures/api/src/lib.rs index 2e6b07edc..f7e2ed8a9 100644 --- a/ffi/fixtures/api/src/lib.rs +++ b/ffi/fixtures/api/src/lib.rs @@ -2295,6 +2295,12 @@ pub fn certify(der: &[u8]) -> tls::held::Cert { tls::held::Cert::new(der) } +/// The length of `bytes`, through another crate's future that borrows them but resolves +/// to an owned count: a future, not an opaque handle. +pub fn byte_len(bytes: &[u8]) -> tls::held::Pending<'_> { + tls::held::Pending(bytes) +} + /// The length of a certificate [`certify`] made, lent. pub fn cert_len(cert: &tls::held::Cert) -> usize { cert.der().len() @@ -2639,6 +2645,12 @@ pub fn since(later: std::time::Instant, earlier: std::time::Instant) -> Duration later.saturating_duration_since(earlier) } +/// Whether `at` holds an instant, lent inside an `Option`: an instant crosses as a `Copy` +/// object, so lending one inside a value takes no handle. +pub fn has_instant(at: &Option) -> bool { + at.is_some() +} + /// How much to log, as moq-tokio's `Log` holds it: a field of a foreign enum, and its filter. #[non_exhaustive] pub struct Verbosity { diff --git a/ffi/fixtures/tls/src/lib.rs b/ffi/fixtures/tls/src/lib.rs index 56d240db0..335d6d574 100644 --- a/ffi/fixtures/tls/src/lib.rs +++ b/ffi/fixtures/tls/src/lib.rs @@ -173,6 +173,18 @@ pub mod held { } } + /// A future that is not an `impl Future`, borrowing what it reads but resolving to an + /// owned count. + pub struct Pending<'a>(pub &'a [u8]); + + impl std::future::Future for Pending<'_> { + type Output = usize; + + fn poll(self: std::pin::Pin<&mut Self>, _: &mut std::task::Context<'_>) -> std::task::Poll { + std::task::Poll::Ready(self.0.len()) + } + } + /// A `Copy` token, which an opaque handle holds by value. #[derive(Clone, Copy, Debug)] pub struct Token(pub u32); diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index ec6b8acf8..927e9b35c 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -912,8 +912,8 @@ impl<'tcx> Collector<'tcx> { /// The type a handle holds by value, if it exports as an opaque handle: as /// [`Self::opaque_arc`]'s, a type of a crate the walk from the root does not reach, - /// taking no type parameters, and `Send` and `Sync`, but not an iterator, nor one that - /// exports by its own crate's path. Its lifetimes are `'static`, as an object's are. + /// taking no type parameters, and `Send` and `Sync`, but not an iterator or a future, + /// nor one that exports by its own crate's path. Its lifetimes are `'static`, as an object's are. fn opaque_value(&self, ty: Ty<'tcx>) -> Option { let ty::Adt(adt, args) = ty.kind() else { return None }; let did = adt.did(); @@ -923,11 +923,16 @@ impl<'tcx> Collector<'tcx> { let erasable = args.iter().all(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(_))); // Asked of a signature's type, whose lifetimes may be bound by it. let ty = ty::fold_regions(self.tcx, ty, |_, _| self.tcx.lifetimes.re_erased); - // An iterator crosses as the array of its items instead. + // An iterator crosses as the array of its items instead, and a future as a future. let iterator = implements(self.tcx, ty, did, sym::Iterator); + let future = (self.tcx.lang_items().future_trait()).is_some_and(|tr| { + let (infcx, env) = (self.tcx.infer_ctxt()).build_with_typing_env(TypingEnv::fully_monomorphized()); + infcx.type_implements_trait(tr, [ty], env).must_apply_modulo_regions() + }); (held && erasable && !iterator + && !future && self.is_send(ty, TypingEnv::fully_monomorphized()) && self.is_sync(ty) && !self.reaches(ty, did)) @@ -4471,9 +4476,11 @@ impl<'tcx> Collector<'tcx> { let tcx = self.tcx; ty.walk().filter_map(|arg| arg.as_type()).any(|ty| match ty.kind() { ty::Adt(adt, args) => { - // An opaque handle is never copied, even of a `Copy` value: lifting takes it. - let opaque = self.foreign.iter().any(|&(ty, _)| ty == adt.did()); - let object = matches!(self.decl(adt.did(), *args), Some(Decl::Object(_))); + // An opaque handle is never copied, even of a `Copy` value: lifting takes it. A + // type [`FOREIGN`] maps by its role is an object. + let foreign = self.foreign.iter().any(|&(ty, _)| ty == adt.did()); + let opaque = foreign && self.opaque(adt.did()); + let object = foreign || matches!(self.decl(adt.did(), *args), Some(Decl::Object(_))); opaque || object && !implements(tcx, ty, adt.did(), sym::Copy) } _ => false, diff --git a/ffi/tests/api.c b/ffi/tests/api.c index 268ec36da..ca5b213ff 100644 --- a/ffi/tests/api.c +++ b/ffi/tests/api.c @@ -1086,6 +1086,13 @@ static int script(void) { printf("itemized %zu\n", itemized); } api_Channel_itemized_future_free(itemizing); + /* Another crate's future borrowing its bytes, which the export owns while it is pending. */ + api_byte_len_future *measuring = api_byte_len(str("abc")); + size_t byte_len; + if (api_byte_len_poll(measuring, waker, &byte_len) == API_POLL_READY) { + printf("byte_len %zu\n", byte_len); + } + api_byte_len_future_free(measuring); api_Channel_send(channel, str("sized")); api_Channel_recv_sized_future *sized = api_Channel_recv_sized(channel); size_t len; @@ -1772,6 +1779,8 @@ static int script(void) { printf("instants %llu %llu %s %s\n", (unsigned long long)(forward.secs * 1000 + forward.nanos / 1000000), (unsigned long long)(backward.secs * 1000 + backward.nanos / 1000000), api_Instant_eq(began, same) ? "true" : "false", api_Instant_eq(began, ended) ? "true" : "false"); + /* An instant lent inside an `Option`, which takes no handle. */ + printf("has_instant %s %s\n", api_has_instant(began) ? "true" : "false", api_has_instant(NULL) ? "true" : "false"); api_Instant_free(same); api_Instant_free(ended); api_Instant_free(began); @@ -1801,7 +1810,7 @@ static int script(void) { api_Token_free(twice); /* Each future dropped its waker once it finished, and Rust the one it was given. */ - if (drops != 14) { + if (drops != 15) { return 1; } return closures() && foreign_futures() && started_futures() ? 0 : 1; diff --git a/ffi/tests/api.cpp b/ffi/tests/api.cpp index 607aee797..a0bc94764 100644 --- a/ffi/tests/api.cpp +++ b/ffi/tests/api.cpp @@ -658,6 +658,13 @@ int script() { std::printf("itemized %zu\n", *count); } } + // Another crate's future borrowing its bytes, which the export owns while it is pending. + { + api::byte_len_future measuring = api::byte_len("abc"); + if (auto len = measuring.poll(waker)) { + std::printf("byte_len %zu\n", *len); + } + } channel.send("sized"); { api::Channel_recv_sized_future sized = channel.recv_sized(); @@ -1162,6 +1169,8 @@ int script() { auto ended = api::later(began, {1, 500000000}); std::printf("instants %llu %llu %s %s\n", millis(api::since(ended, began)), millis(api::since(began, ended)), began == api::later(began, {0, 0}) ? "true" : "false", began == ended ? "true" : "false"); + // An instant lent inside an `Option`, which takes no handle. + std::printf("has_instant %s %s\n", api::has_instant(&began) ? "true" : "false", api::has_instant(nullptr) ? "true" : "false"); } // tracing's level, and its filter as an optional level whose empty is `OFF`. { diff --git a/ffi/tests/api.dart b/ffi/tests/api.dart index a39609670..acd37621b 100644 --- a/ffi/tests/api.dart +++ b/ffi/tests/api.dart @@ -393,6 +393,7 @@ Future script() async { // The send happens at the call, and the future borrows the channel and the tag. print('tagged ${await channel.tagged('tag')}'); print('itemized ${await channel.itemized(Uint32List.fromList([1, 2, 3]))}'); + print('byte_len ${await api.byteLen(utf8.encode('abc'))}'); channel.send(utf8.encode('sized')); final (payload, size) = await channel.recvSized(); print('sized ${text(payload)} $size'); @@ -690,6 +691,7 @@ Future script() async { final ended = api.later(began, const Duration(milliseconds: 1500)); final same = api.later(began, Duration.zero); print('instants ${api.since(ended, began).inMilliseconds} ${api.since(began, ended).inMilliseconds} ${began == same} ${began == ended}'); + print('has_instant ${api.hasInstant(began)} ${api.hasInstant(null)}'); began.close(); ended.close(); same.close(); diff --git a/ffi/tests/api.go b/ffi/tests/api.go index b5b272d71..b044c7b90 100644 --- a/ffi/tests/api.go +++ b/ffi/tests/api.go @@ -480,6 +480,7 @@ func script() { // The send happens at the call, and the future borrows the channel and the tag. fmt.Printf("tagged %s\n", must(channel.Tagged(ctx, "tag"))) fmt.Printf("itemized %d\n", must(channel.Itemized(ctx, &[]uint32{1, 2, 3}))) + fmt.Printf("byte_len %d\n", must(api.ByteLen(ctx, []byte("abc")))) // An eager call whose callback cancels its context while it makes its future is never // polled: only the eager half logs. { @@ -814,6 +815,7 @@ func script() { same := must(api.Later(began, 0)) fmt.Printf("instants %d %d %t %t\n", must(api.Since(ended, began)).Milliseconds(), must(api.Since(began, ended)).Milliseconds(), must(began.Equal(same)), must(began.Equal(ended))) + fmt.Printf("has_instant %t %t\n", must(api.HasInstant(began)), must(api.HasInstant(nil))) began.Close() ended.Close() same.Close() diff --git a/ffi/tests/api.kt b/ffi/tests/api.kt index 2a4f8eba6..00e69293d 100644 --- a/ffi/tests/api.kt +++ b/ffi/tests/api.kt @@ -317,6 +317,7 @@ fun script() { // The send happens at the call, and the future borrows the channel and the tag. println("tagged ${channel.tagged("tag")}") println("itemized ${channel.itemized(uintArrayOf(1u, 2u, 3u))}") + println("byte_len ${byteLen("abc".encodeToByteArray())}") channel.send("sized".encodeToByteArray()) val (payload, size) = channel.recvSized() println("sized ${payload.text()} $size") @@ -604,6 +605,7 @@ fun script() { later(began, 1500.milliseconds).use { ended -> later(began, kotlin.time.Duration.ZERO).use { same -> println("instants ${since(ended, began).inWholeMilliseconds} ${since(began, ended).inWholeMilliseconds} ${began == same} ${began == ended}") + println("has_instant ${hasInstant(began)} ${hasInstant(null)}") } } } diff --git a/ffi/tests/api.py b/ffi/tests/api.py index 39418d0c9..68707d41c 100644 --- a/ffi/tests/api.py +++ b/ffi/tests/api.py @@ -394,6 +394,7 @@ async def block(): # The send happens at the call, and the future borrows the channel and the tag. print(f"tagged {await channel.tagged('tag')}") print(f"itemized {await channel.itemized(array.array('I', [1, 2, 3]))}") + print(f"byte_len {await api.byte_len(b'abc')}") channel.send(b"sized") payload, size = await channel.recv_sized() print(f"sized {text(payload)} {size}") @@ -674,6 +675,7 @@ async def polls(): ended = api.later(began, datetime.timedelta(milliseconds=1500)) same = api.later(began, datetime.timedelta()) print(f"instants {api.since(ended, began) // ms} {api.since(began, ended) // ms} {flag(began == same)} {flag(began == ended)}") + print(f"has_instant {flag(api.has_instant(began))} {flag(api.has_instant(None))}") # tracing's level, and its filter as an optional level whose None is `OFF`. verbosity = api.Verbosity.new(api.Level.WARN) print(f"verbosity {api.spell(verbosity.filter())} {api.spell(api.louder(verbosity.filter()))}") diff --git a/ffi/tests/api.swift b/ffi/tests/api.swift index 9a9a6aff1..02cc95cb4 100644 --- a/ffi/tests/api.swift +++ b/ffi/tests/api.swift @@ -463,6 +463,7 @@ func script() { // The send happens at the call, and the future borrows the channel and the tag. print("tagged \(try await channel.tagged("tag"))") print("itemized \(try await channel.itemized([1, 2, 3]))") + print("byte_len \(try await byteLen(Data("abc".utf8)))") channel.send(Data("sized".utf8)) let (payload, size) = try await channel.recvSized() print("sized \(text(payload)) \(size)") @@ -764,6 +765,7 @@ func script() { let began = now() let ended = later(began, .milliseconds(1500)) print("instants \(millis(since(ended, began))) \(millis(since(began, ended))) \(began == later(began, .zero)) \(began == ended)") + print("has_instant \(hasInstant(began)) \(hasInstant(nil))") // tracing's level, and its filter as an optional level whose nil is `OFF`. var verbosity = Verbosity.new(.warn) print("verbosity \(spell(verbosity.filter())) \(spell(louder(verbosity.filter())))") From 1e521b804dd83ab2f826f3db46ab23faad8faf14 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 13 Nov 2026 20:58:25 -0800 Subject: [PATCH 24/24] fix(ffi): read an impl Trait's elaborated bounds, so a supertrait's future output is seen `output_borrows`, `lifetimes`, and instance inference read only an `impl Trait`'s explicit bounds, so `-> impl Borrowing<'_>`, whose supertrait is `Future`, passed as a future whose output borrows nothing, and its glue dropped the owned argument before cloning the output. The reject fixture's `relay` now records the refusal. Co-Authored-By: Claude Opus 5.5 --- ffi/fixtures/reject/expected.txt | 247 ++++++++++++++++--------------- ffi/fixtures/reject/src/lib.rs | 5 + ffi/fixtures/tls/src/lib.rs | 5 + ffi/src/collect.rs | 16 +- 4 files changed, 143 insertions(+), 130 deletions(-) diff --git a/ffi/fixtures/reject/expected.txt b/ffi/fixtures/reject/expected.txt index b850f2d0e..9ba588290 100644 --- a/ffi/fixtures/reject/expected.txt +++ b/ffi/fixtures/reject/expected.txt @@ -1,32 +1,33 @@ -fixtures/reject/src/lib.rs:1003: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:1019: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:1026: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:1032: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:1037: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:1042: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:1048: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:1050:2: note: has this discriminant -fixtures/reject/src/lib.rs:1055: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:1057:2: note: has this discriminant +fixtures/reject/src/lib.rs:1002:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1008: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:1024: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:1031: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:1037: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:1042: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:1047: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:1053: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:1055:2: note: has this discriminant fixtures/reject/src/lib.rs:105:1: rust2-ffi: cannot export fn `forever`: 'static borrow `&'static [u8]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1062: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:1064:2: note: has this discriminant -fixtures/reject/src/lib.rs:1068:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1073:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1079:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1093:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1099:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1104:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1109: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:1099:1: note: C cannot implement `Trusted`: unsafe trait -fixtures/reject/src/lib.rs:1114: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:1104:1: note: C cannot implement `Hazard`: unsafe fn `risk` -fixtures/reject/src/lib.rs:1119: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:1060: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:1062:2: note: has this discriminant +fixtures/reject/src/lib.rs:1067: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:1069:2: note: has this discriminant +fixtures/reject/src/lib.rs:1073:1: rust2-ffi: cannot export fn `raw`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1078:1: rust2-ffi: cannot export fn `sum`: C-variadic function; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1084:1: rust2-ffi: cannot export fn `custom`: uncallable ABI `"custom"`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1098:2: rust2-ffi: cannot export method `Raw::peek`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1104:1: rust2-ffi: cannot export trait `Trusted`: unsafe trait; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1109:1: rust2-ffi: cannot export trait `Hazard`: unsafe fn `risk`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:1114: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:1104:1: note: C cannot implement `Trusted`: unsafe trait +fixtures/reject/src/lib.rs:1119: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:1109:1: note: C cannot implement `Hazard`: unsafe fn `risk` fixtures/reject/src/lib.rs:111:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:1124: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:1129: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:1134: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:1139: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:1124: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:1129: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:1134: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:1139: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:1144: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:11:1: rust2-ffi: cannot export fn `map`: foreign type `std::collections::HashMap`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:122:1: rust2-ffi: cannot export fn `parse_later`: returned object that borrows `impl std::future::Future>>`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:136: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 @@ -38,109 +39,109 @@ fixtures/reject/src/lib.rs:175:1: rust2-ffi: cannot export instance `Cell`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:184: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:189: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:194: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:199: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:204: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:214: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:194: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:199: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:204: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:209: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:219: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:21:1: rust2-ffi: cannot export fn `nested`: nested Option `std::option::Option>>`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:224:1: rust2-ffi: cannot export fn `adopt`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:236: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:255: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:266: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:269: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:280: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:289: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:300:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:305:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:229: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:241: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:260: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:271: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:274: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:285: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:294: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:305:1: rust2-ffi: cannot export fn `probe`: const generic `N`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:30:1: rust2-ffi: cannot export fn `peek`: reference to a handle inside a value `std::boxed::Box`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:310: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:315: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:318: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:323: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:326: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:334:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:344: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:349: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:354: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:359: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:310:1: rust2-ffi: cannot export fn `excluded_cell`: excluded type `reject::Cell`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:315: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:320: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:323: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:328: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:331: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:339:2: rust2-ffi: cannot export field `Tag::label`: 'static borrow `&'static str`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:349: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:354: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:359: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:35:1: rust2-ffi: cannot export static `COUNT`: static; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:364:1: rust2-ffi: cannot export fn `rewrite`: reader bound `std::io::Write`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:369: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:374: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:380: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:386: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:391: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:396: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:364: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:369: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:374: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:379: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:385: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:391: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:396: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:39:1: rust2-ffi: cannot export macro `noop`: macro; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:401: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:406: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:411: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:423: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 `hold`: generic parameter `std::convert::Into`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:443: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:448: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:462: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:476: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:401: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:406: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:411: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:416: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:428: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:443: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:448: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:453: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:467: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:47:1: rust2-ffi: cannot export fn `excluded`: excluded type `Excluded`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:491: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:506: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:529: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:481: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:496: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:511:1: rust2-ffi: cannot export fn `paired`: generic parameter `std::convert::Into`; exclude it in the config to leave it out fixtures/reject/src/lib.rs:52:1: rust2-ffi: cannot export fn `letters`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:544:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out - fixtures/reject/src/lib.rs:536:1: note: applies past the recursion limit -fixtures/reject/src/lib.rs:574: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:551:1: note: `std::string::String` converts too, which C passes alike -fixtures/reject/src/lib.rs:579:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:584: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:589: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:594: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:599: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:625: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:630: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:604:1: note: C cannot implement `Source`: callback signature `items` -fixtures/reject/src/lib.rs:635:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:640: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:640:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:647: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:647:20: note: `'b` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:654: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:654:20: note: `'a` is `'static`, as a handle outlives every call -fixtures/reject/src/lib.rs:663:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:669: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:534: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:549:1: rust2-ffi: cannot export fn `grows`: growing conversion `Grows`; exclude it in the config to leave it out + fixtures/reject/src/lib.rs:541:1: note: applies past the recursion limit +fixtures/reject/src/lib.rs:579: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:556:1: note: `std::string::String` converts too, which C passes alike +fixtures/reject/src/lib.rs:584:1: rust2-ffi: cannot export fn `alphabet`: Range `char`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:589: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:594: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:599: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:604: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:630: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:635: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:609:1: note: C cannot implement `Source`: callback signature `items` +fixtures/reject/src/lib.rs:640:1: rust2-ffi: cannot export fn `summed_forever`: 'static borrow `&'static [u32]`; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:645: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:645:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:652: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:652:20: note: `'b` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:659: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:659:20: note: `'a` is `'static`, as a handle outlives every call +fixtures/reject/src/lib.rs:668:1: rust2-ffi: cannot export fn `ones`: foreign type `std::iter::Repeat`; exclude it in the config to leave it out fixtures/reject/src/lib.rs: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:675: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:692: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:674: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:680: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:697: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: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:709: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:732: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:746: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:751: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:758: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:764: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:769: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:774: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:714: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:737: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:751: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:756: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:763: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:769: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:774: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:779: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: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:794: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:801: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:825: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:843: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:848: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:853: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:859: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:865: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:876:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:895: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:900: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:907: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:914: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:919: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:926: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:931: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:936: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:941: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:954: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:965: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:968: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:979:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out -fixtures/reject/src/lib.rs:997:2: rust2-ffi: cannot export method `Risky::new`: unsafe fn; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:799: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:806: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:830: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:848: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:853: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:858: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:864: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:870: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:881:1: rust2-ffi: cannot export fn `context_later`: Context of a function returning a future; future not Send; exclude it in the config to leave it out +fixtures/reject/src/lib.rs:900: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:905: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:912: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:919: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:924: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:931: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:936: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:941: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:946: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:959: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:970: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:973: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:984:2: rust2-ffi: cannot export method `Tally::poll_bump`: `&mut self` of a value; exclude it in the config to leave it out fixtures/reject/src/lib.rs:99:2: rust2-ffi: cannot export method `Text::later`: returned object that borrows `impl std::future::Future>`; exclude it in the config to leave it out diff --git a/ffi/fixtures/reject/src/lib.rs b/ffi/fixtures/reject/src/lib.rs index aa998184e..6e6b20a1b 100644 --- a/ffi/fixtures/reject/src/lib.rs +++ b/ffi/fixtures/reject/src/lib.rs @@ -190,6 +190,11 @@ pub fn blame(tag: &str) -> impl std::future::Future impl tls::held::Borrowing<'_> { + async move { tag } +} + /// As `echo`, but through a future that is not an `impl Future`. pub fn resolve(tag: &str) -> tls::held::Lend<'_, u8> { tls::held::Lend(tag, std::marker::PhantomData) diff --git a/ffi/fixtures/tls/src/lib.rs b/ffi/fixtures/tls/src/lib.rs index 335d6d574..5bbd68985 100644 --- a/ffi/fixtures/tls/src/lib.rs +++ b/ffi/fixtures/tls/src/lib.rs @@ -173,6 +173,11 @@ pub mod held { } } + /// A future named by a trait of its own, whose borrowed output only its supertrait names. + pub trait Borrowing<'a>: std::future::Future {} + + impl<'a, F: std::future::Future> Borrowing<'a> for F {} + /// A future that is not an `impl Future`, borrowing what it reads but resolving to an /// owned count. pub struct Pending<'a>(pub &'a [u8]); diff --git a/ffi/src/collect.rs b/ffi/src/collect.rs index 927e9b35c..46a9e237f 100644 --- a/ffi/src/collect.rs +++ b/ffi/src/collect.rs @@ -3041,8 +3041,8 @@ impl<'tcx> Collector<'tcx> { continue; }; if ty == unrevealed && (future || collect) { - let bounds = tcx.explicit_item_bounds(*def_id).skip_binder(); - named.extend(bounds.iter().filter_map(|&(clause, _)| { + let bounds = tcx.item_bounds(*def_id).skip_binder(); + named.extend(bounds.iter().filter_map(|clause| { let term = clause.as_projection_clause()?.skip_binder().term.as_type()?; Some(ty::EarlyBinder::bind(tcx, term).instantiate(tcx, args).skip_norm_wip()) })); @@ -4347,8 +4347,9 @@ impl<'tcx> Collector<'tcx> { else { return output.walk().any(|arg| arg.as_region().is_some()); }; - (tcx.explicit_item_bounds(*def_id).skip_binder().iter()) - .filter_map(|&(clause, _)| clause.as_projection_clause()?.skip_binder().term.as_type()) + // Elaborated, as a supertrait may name the output. + (tcx.item_bounds(*def_id).skip_binder().iter()) + .filter_map(|clause| clause.as_projection_clause()?.skip_binder().term.as_type()) .map(|term| ty::EarlyBinder::bind(tcx, term).instantiate(tcx, args).skip_norm_wip()) .any(|term| { term.walk() @@ -4379,11 +4380,12 @@ impl<'tcx> Collector<'tcx> { }, ) => { let tcx = self.tcx; - let bounds = tcx.explicit_item_bounds(*def_id).skip_binder(); + // Elaborated, as a supertrait may be the future or name its output. + let bounds = tcx.item_bounds(*def_id).skip_binder(); // Any other `impl Trait` holds what its hidden type holds, as `impl Iterator + '_` // over an object borrowing the receiver does; one collected at the call, or a // future, whose borrows are checked apart, holds nothing past it. - let future = (bounds.iter()).any(|&(clause, _)| { + let future = (bounds.iter()).any(|clause| { clause .as_trait_clause() .is_some_and(|tr| tcx.is_lang_item(tr.def_id(), LangItem::Future)) @@ -4414,7 +4416,7 @@ impl<'tcx> Collector<'tcx> { held.extend(args.iter().flat_map(|arg| arg.walk()).filter_map(|arg| arg.as_region())); } } - for &(clause, _) in bounds { + for clause in bounds { let term = clause .as_projection_clause() .and_then(|p| p.skip_binder().term.as_type());