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

panic in the face of type cycles #151

Merged
merged 2 commits into from
Oct 18, 2021
Merged

panic in the face of type cycles #151

merged 2 commits into from
Oct 18, 2021

Conversation

ahl
Copy link
Collaborator

@ahl ahl commented Oct 16, 2021

Closes #150

These can arise because the schemars ignores conflicting names and
doesn't use e.g. the mod to qualify the name when necessary. There are
other errors that can result from this such as overwritten types, but
this is the most acute at the moment.

@smklein I don't think this is a great solution, but it may actually be what we want. There an issue in schemars that describes the problem of name conflicts more generally. In this case, however, we actually don't want two types in the schema and #[serde(transparent)] does exactly what we want.

I'm not sure why serde (and schemars) don't do this automatically when they see #[repr(transparent)] but it may be that derive macros don't reliably see that attribute. See also serde-rs/serde#1054

These can arise because the schemars ignores conflicting names and
doesn't use e.g. the mod to qualify the name when necessary. There are
other errors that can result from this such as overwritten types, but
this is the most acute at the moment.
@ahl ahl requested a review from smklein October 16, 2021 15:02
dropshot/src/type_util.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@smklein smklein left a comment

Choose a reason for hiding this comment

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

Thanks for fixing - I believe this would have hit my use case, and helped me get to a working solution quickly!

@ahl ahl merged commit 6703120 into main Oct 18, 2021
@ahl ahl deleted the cycle branch October 18, 2021 16:17
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.

Registration of endpoint using nested type with same name causes infinite loop
2 participants