Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small codegen alteration question/request regarding generic types with nested nodes #262

Open
aikalant opened this issue Feb 24, 2022 · 0 comments

Comments

@aikalant
Copy link

aikalant commented Feb 24, 2022

Currently, nested capnp struct definitions translate into rust codegen builders/readers /etc that contain ALL possible generic types, even if they do not use them. For example:

struct RootStruct(T) {
  tVal @0 :T;

  struct SubStruct(R) {
      rVal @0 :R;
  }
}

The SubStruct mod's structs contain both T and R generic types, even though they only use R.

root_struct::sub_struct::Builder<T,R>

Here are some examples of some awkward usage this can potentially cause:

let builder = TypedBuilder::<sub_struct::Owned<XXXX_unused_XXXXX, some_struct::Owned>>::new_default();

fn write_to_builder(builder: sub_struct::Builder<XXXX_unused_XXXXX, some_struct::Owned>);

Given the changes in this recent commit, is there any architectural reason it would not be possible to expand the concept of only including used generic types in struct/interface/group definitions instead of only unions? From some of my own (albeit limited) tests, it seems like it would be ok.

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

No branches or pull requests

1 participant