Skip to content

DRAFT v0.10: migrate to typespace - #1088

Draft
ahl wants to merge 20 commits into
mainfrom
v0_10
Draft

ahl wants to merge 20 commits into
mainfrom
v0_10

Conversation

@ahl

@ahl ahl commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Switch to using the typespace crate for type construction and code generation.

We're going to operate out of the v0_10 branch for a little bit at least, including publishing pre-release versions from that branch.

Adam H. Leventhal and others added 20 commits September 28, 2026 15:05
typespace becomes a path dependency and takes over the type
representation, the query surface, and rendering. typify's own
TypeEntry/TypeEntryDetails tree, its query and render facade, and
the structural dedup of unnamed types all come out; conversion now
builds typespace types directly and to_stream finalizes a
TypespaceBuilder and renders through codespace.

to_stream and the consumer entry points become fallible so
finalization errors (dangling references, name collisions,
unsatisfiable trait requirements) surface as Error::Typespace.
typespace_ext.rs holds the glue: native type capabilities, patch
derives and attributes, and the notes on the gaps that remain
relative to typify1's renderer.
with_typify_compat withholds Default from a tuple struct, a unit
struct, and a newtype, which typify never derives it for.
Ask for Eq, PartialEq, Ord, PartialOrd, Hash, Display, FromStr, and
Copy as desired traits so typespace derives them where it can, and
pass the settings-wide extra attributes through with_attr.
Five breaks, all from typespace changes that landed after the last sync:

TraitProvision moved to the crate root when it absorbed
TraitDisposition, so settings:: no longer names it.

Native::new takes the path as &str.

Native::name is gone; path() answers a syn::Type. native_name_match
reads the last path segment rather than splitting rendered tokens,
which is what it wanted anyway: quoting a path spaces out its
separators.

view::Type::name answers a Cow borrowed from the typespace, so the
typespace has to outlive the name in convert's test.

parameter_ident_in and parameter_ident_with_lifetime merged into one
parameter_ident(scope, lifetime).
test_empty_any_of arrived on main after this branch's previous base
and speaks the deleted TypeEntryDetails vocabulary; it now matches on
the typespace-backed TypeEntry.
TypeSpaceSettings keeps only what governs conversion (replacements,
patches, conversions, crate policy) and carries a typespace::Settings
for everything about rendering; map_typespace_settings adjusts it and
new() holds typify's defaults. The extra_derives, extra_attrs,
struct_builder, and map_type fields and MapType are gone. Derive names
from the CLI and the macro go through TraitSpec::parse, so typespace
decides whether a name is a trait it models or a foreign derive; a bare
foreign name is now an error. A map named by path takes the HashMap
preset with that path, since a JSON map key is always string-like.
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.

1 participant