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

Generator::httpmock fails with a confusing error when provided crate_name contains hyphen #984

Open
ewancg opened this issue Nov 26, 2024 · 0 comments

Comments

@ewancg
Copy link

ewancg commented Nov 26, 2024

When using progenitor to generate a statically typed httpmock extension, someone might be tempted to put a hyphen inside their crate name:

generator.httpmock(&spec, "something-mock")

This will work for many use cases because package names with hyphens are automatically converted to have underscores, thanks to the fact that hyphens are not valid characters in Rust identifiers. In the case of progenitor, it will fail like so:

called `Result::unwrap()` on an `Err` value: Error("unexpected token")

because, presumably, something and mock are being interpreted as separate identifiers. There's nothing untrue about this error per se, but it really did confuse me until I realized what was actually going on. Perhaps this edge-case should be caught and error explicitly.

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