Repository navigation
feat(ffi): take what converts into an Into target through a chain of From implementations - #248
Conversation
Quest-Claim: e28c09b1fd47aeaf
…From implementations An `impl Into<X>` whose `X` does not map follows each `Into<Y>` bound of a `From` source parameter whose `Y` does not map either, through any number of levels, carrying whether a level must outlive the call and visiting each target once so a cycle ends. Two chain sources that C passes as one buffer but that hold different values, such as `String` and `Vec<u8>`, are refused as an ambiguous conversion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… target names 'static Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…get ties to 'static Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…call Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Decision (maintainer, round 4 checkpoint): continue with option 1. Apply the borrow filter only to a chain's leaves, carry the outlives requirement into followed targets, and add an api case with an owned record behind a lifetime-carrying intermediate, reproducing the over-refusal first. The narrowing of "same foreign signature" to different values in one C buffer stands and stays listed in the PR body. (written by Claude Opus 5.5) |
# Conflicts: # quest/m3/ffi-from-chains.md
… filtering only borrowed leaves Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…etimes the target ties to 'static Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s 'static Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, not by walk position Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 40 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit 34bd5fae511c18b0ecc4ccc21d74340a9a0c47a4.
No actionable bugs found. The breadth-first walk follows unmapped Into-bound targets rather than assuming arbitrary From conversions compose; visited target/outlives pairs terminate cycles, and candidate validation still checks the original export's bounds. Static lifetime constraints are carried through intermediate targets, while unrelated borrowed inputs remain usable. The fixtures cover non-UTF-8 chains, owned intermediates, cycles with an exit, finite expansion, growing-chain refusal, lifetime rejection and ambiguous buffer sources across the C/C++/Kotlin transcripts.
Direction: extending the existing source discovery is preferable to adding consumer-specific conversion configuration. The explicit growing/ambiguous refusals avoid silently falling back to a different parameter representation. The documented string-form equivalence is treated as the chosen API policy.
Verification limits: GitHub-only static review of the implementation, surrounding candidate selection and fixtures, plus an independent read-only pass. I did not run the exporter, differential suites, census or reported local checks, and do not claim they passed.
(Written by OpenAI)
Completes quest/m3/ffi-from-chains.md.
Problem
impl Into<X>, whereXdoes not map, followed only one level ofFromimplementations. A source parameter bounded byInto<Y>with an unmappedYstopped there. The parameter then fell back toString,Bytes, orVec<u8>, which is the #197 bug class: for example,api_sample_hexrejected a payload that is not UTF-8.Approach
sourcesinffi/src/collect.rswalks breadth-first. It follows eachInto<Y>bound of aFromsource parameter whoseYdoes not map, throughhop(the old one-level body). Each (target, outlives) pair is visited once, which ends cycles.recursion_limit, past which rustc proves no conversion either, is refused asgrowing conversion, with a note at the impl. The pinned nightly accepts impls such asFrom<U: Into<Wrap<Vec<T>>>> for Wrap<T>, so without this the walk hung. A finite expansion that stops matching still exports.hopreads the inference context's region constraints. It pins to'staticeach impl lifetime the target makes'static(or that a lifetime the export makes'staticcovers), closes over'b: 'aclauses, and erases the rest. A followed target keeps those'statics. A leaf borrow is dropped when it names'static, or when any level must outlive the call. A lifetime-bearing intermediate is followed, not dropped.StringandVec<u8>, are refused asambiguous conversion, with a note at the other impl.instantiatereturns both new refusals directly instead of falling back toeach.sample_hexand three-hopqueued_hex(middle level'static), both with a payload that is not UTF-8Tick/Tockcycle with aLabelexitrooted_name: an owned record behind a'staticintermediatestored_text: a&strits'statictarget does not borrow forlayer_name: a finite expansioncall(ambiguous),grows(growing), andholder,lender,outlived,paired,pinner(borrows some level demands outlive the call)Choices made without asking
&str,String, andBox<str>are forms of one value and convert alike, so they are not ambiguous. Counting them as ambiguous refused moq-net'sbroadcast::Producer::create_trackandreserve_track(impl Into<Arc<str>>). The maintainer confirmed this narrowing.Impact
ambiguous conversionandgrowing conversion.just ffi censusfor moq: no movement. With main's exporter at 3c4fb50, every package's census is identical. No moq parameter goes through two levels;impl Into<Timed<Bytes>>is one.Alternatives
walk()s: rejected after review.walk()deduplicates, so repeated target lifetimes misalign.&str/String: regresses moq (above).Follow-ups
Review
Codex (gpt-6.1-sol, medium),
quest review --base origin/main. The latest round is clean (0 findings) on head dcaf1e9.First session (rounds 1 to 4):
'staticintermediate lost on erasure: fixed (holder). Expanding chains: wrongly refuted with system rustc 1.98.'staticthrough the target: fixed (lender). Expanding chains hang on the pinned nightly: fixed (grows).pinner).rooted_name).Second session (restarted by the merge of #249):
layer_name). Untied source under a'statictarget over-refused: fixed with lifetime pinning (stored_text).'b: 'anot propagated: fixed (outlived).walk()zip misaligns repeated lifetimes: fixed with region constraints (paired).Head 34bd5fa is dcaf1e9 plus a conflict-free merge of origin/main (6c3fd5a, ts and quest files only), so the review carries over. Local checks:
just cipasses on 34bd5fa;just ffi moqpasses on dcaf1e9.Merge of main at
cbf8ee08417c3fc6fa0f76bec146b5f8c58a73fc: git merged it without conflicts and it touches noffi/file; it only refreshes the base so GitHub can merge, with no change to this PR's diff since34bd5fae, so it is a recorded skip, too trivial to review.(written by Claude Opus 5.5)