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

Problems with code bases already using std::error:Error #1020

Open
KamWithK opened this issue Dec 27, 2024 · 1 comment
Open

Problems with code bases already using std::error:Error #1020

KamWithK opened this issue Dec 27, 2024 · 1 comment

Comments

@KamWithK
Copy link

Progenitor has an enum called Error, so if you try import std::error::Error you'll get errors about it being defined multiple times, along with an onslaught of other type errors due to the compiler trying to match the uses of Error to your enum

Maybe the enum should be renamed something else less generic to prevent clashes with code already in use, or at least a warning in the README about it?
I understand completely if you consider this a non-problem though too, just wanted to make the suggestion

error[E0252]: the name `Error` is defined multiple times
 --> /home/kamwithk/repos/funkyduck/target/debug/build/funkyduck-693277bb923d1a99/out/codegen.rs:2:41
  |
2 | pub use progenitor_client::{ByteStream, Error, ResponseValue};
  |                                         ^^^^^ `Error` reimported here
  |
 ::: src/main.rs:4:5
  |
4 | use std::error::Error;
  |     ----------------- previous import of the trait `Error` here
  |
  = note: `Error` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
 --> src/main.rs:4:22
  |
4 | use std::error::Error as OtherError;
  |                       +++++++++++++
@ahl
Copy link
Collaborator

ahl commented Dec 27, 2024

It's a good suggestion. We've been trending in a direction of explicit naming, and I think that's probably the approach we should take here: fully qualify the types we use and avoid the import.

In your case, you might be able to wrap your generated code in a mod my_client { .. }

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

2 participants