Skip to content

A package's interface records what was inferred: a view's origins, a stored callable, a callable invoked once; an effect pin above a method is attached to it (#3401); a test for #898 - #3501

Merged
ehartford merged 8 commits into
mainfrom
package-interface
Nov 21, 2026

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Part of #3401 (package bundles, order of work step 1). Closes #898.

The rule (Eric, 2026-11-20): an importer reads the interface, never the body; the interface records what was inferred.

What the interface now prints, for a tree bundle, where the declaration left the fact to inference:

  • A result's origins. A view with two possible origins, or one whose origin is not the default, was left out of the interface ("not exported"). It is printed with the clause a person would write: pub fn bigger(a: &Shape, b: &Shape) -> &Shape from a, b.
  • A callable parameter the body stores or returns, as the @[effect] pin a person would write. Without it an importer accepted a closure holding a local by place where the source check refuses it.
  • A callable parameter invoked at most once, as once. Without it an importer refused a consuming closure the source check accepts.

A parser defect this exposed. An @[effect] pin above a method in an impl block was never attached to the method: it stayed pending and landed on the next function declared outside the block. The compiler's own bundle failed its fingerprint check on five methods because of it. Fixed in the parser.

The check. New lane package-interface-check (a dependency of tests): the fixture package test/package_bundle/lib leaves a return type, a view's origins, a stored callable and a single invocation to inference, in functions and in a method. Each of eight programs under test/package_bundle/app states its outcome on its first line and is checked against the package's source and against its interface alone; both must give that outcome, and the interface must reproduce the source's declaration fingerprint.

Still to do in step 1 (recorded on #3401): generics carried as source, pub-only output, the effect-disagreement warnings that are noise for a package, the bundle's wording for a twice-invoked callable, and suspension.

#898. type_needs_drop(*mut T) answered true in a specialization because the pointee's Drop impl was read as the pointer's; a later guard in type_has_drop_impl fixed it. behav_898_pointer_field_in_specialization_owns_nothing pins it: one drop, no leak.

Battery green; :release-checks green, on the current main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

type_needs_drop returns true for *mut T during generic specialization re-check (is_copy simultaneously true)

1 participant