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

conflicting implementations of trait Clone for type `database::schema::sql_types::ConsumableUnit #102

Open
brianmay opened this issue Jan 6, 2025 · 4 comments

Comments

@brianmay
Copy link

brianmay commented Jan 6, 2025

I thought I saw an existing bug report, but now I can't find it. So apologies if this is a duplicate.

11:25:57 [cargo] error[E0119]: conflicting implementations of trait `Clone` for type `database::schema::sql_types::ConsumableUnit
  --> src/server/database/schema.rs:4:46
   |
4  |     #[derive(diesel::query_builder::QueryId, Clone, diesel::sql_types::SqlType)]
   |                                              ^^^^^ conflicting implementation for `database::schema::sql_types::ConsumableUnit
   |
  ::: src/server/database/models/consumables.rs:11:10
   |
11 | #[derive(diesel_derive_enum::DbEnum, Debug)]
   |          -------------------------- first implementation here
   |
   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info

11:25:59 [cargo] For more information about this error, try `rustc --explain E0119`.

My schema.rs has:

pub mod sql_types {
    #[derive(diesel::query_builder::QueryId, Clone, diesel::sql_types::SqlType)]
    #[diesel(postgres_type(name = "consumable_unit"))]
    pub struct ConsumableUnit;
}

The other file has:

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum ConsumableUnit {
    Mls,
    G,
}

Deleting the Clone by hand from the schema.rs file fixes the problem. But will come back when the file is regenerated again.

I am guessing what happened is that previously the auto-generated file did not add the Clone trait, and it was required, so the DbEnum macro added it. But now the auto-generated file does have the Clone trait and the two conflict.

@brianmay
Copy link
Author

brianmay commented Jan 6, 2025

I just found #94. But in the above case everything is in one crate only.

@GamerBene19
Copy link

I think the issue is here
https://github.com/adwhit/diesel-derive-enum/blob/master/src/lib.rs#L307

or perhaps here
https://github.com/adwhit/diesel-derive-enum/blob/master/src/lib.rs#L385-L397

I'll try to modify the library locally (in the next few days) to test out which of these is the culprit.

@adwhit
Copy link
Owner

adwhit commented Jan 27, 2025

I am aware that this issue is causing problems, I hope to get a fix out this week

@GamerBene19
Copy link

I am aware that this issue is causing problems, I hope to get a fix out this week

Nice, thanks! No pressure though, maintaining an open source lib is not a job 😉

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

3 participants