Skip to content

Export replaced types#1356

Closed
inickles wants to merge 1 commit intomainfrom
inickles/export-replaced
Closed

Export replaced types#1356
inickles wants to merge 1 commit intomainfrom
inickles/export-replaced

Conversation

@inickles
Copy link
Copy Markdown
Contributor

This exports the types that someone includes in replace when using the generatie_api! macro, making them available to users.

@inickles inickles force-pushed the inickles/export-replaced branch from 596e4e7 to b91980d Compare April 28, 2026 15:32
Copy link
Copy Markdown
Collaborator

@ahl ahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be helpful to understand the utility of this change, and I'd like to see how this is materialized in the generated code.

Also the style of the code here doesn't particularly match the code around it.

Comment on lines +379 to +391
let mut sorted_replace: Vec<_> = self.settings.replace.iter().collect();
sorted_replace.sort_by_key(|(name, _)| name.as_str());
let replaced_type_reexports =
sorted_replace.iter().map(|(type_name, (replace_path, _))| {
let type_ident = quote::format_ident!("{}", type_name);
let replace_tokens: TokenStream =
replace_path.parse().expect("invalid replacement type path");
quote! {
#[allow(unused_imports)]
pub use #replace_tokens as #type_ident;
}
});
let replaced_type_reexports = quote! { #(#replaced_type_reexports)* };
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, I think this may make more sense in typify.

Do we think this should be the only behavior or should be opt-in (or opt-out)?

What if there's a replace imperative that's never used? Is that caught elsewhere? Would we want to check for that?

Would we want to do something for the other ways to replace a type such as x-rust-type.

Copy link
Copy Markdown
Collaborator

@ahl ahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean to say: let's change this (not approved)

@inickles
Copy link
Copy Markdown
Contributor Author

inickles commented Apr 30, 2026

Closing in place of oxidecomputer/typify#1007

@inickles inickles closed this Apr 30, 2026
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.

2 participants