I got an "conflicting type" error which I don't understand. I also didn't succeed to create a minimal example, so the code below doesn't compile.
The conflicting types are between an associated type and an explicit type. I expect those types to be different, as the conv_12
and conv_21
functions also suggest (because they don't compile). If I swap the associated type with the explicit type I expect it to be, it compiles fine (but that isn't an option because the code is generated).
I have no clue anymore what to check next or how to make a minimal example. What should be my next steps in understand why I get this error message here?
extern crate glib;
struct Type1;
struct Type2;
struct InnerType1;
struct InnerType2;
impl ::glib::wrapper::Wrapper for Type1 { type GlibType = InnerType1; type GlibClassType = InnerType1; }
impl ::glib::wrapper::Wrapper for Type2 { type GlibType = InnerType2; type GlibClassType = InnerType2; }
/*
//Failing aliases
type Alias1 = <gobject_gen_test::auto::Counter as ::glib::wrapper::Wrapper>::GlibType;
type Alias2 = imp::RustCounterFfi;
fn _conv12(i: Alias1) -> Alias2 { i } //Failes
fn _conv21(i: Alias2) -> Alias1 { i } //Failes
*/
// Compiling aliases
type Alias1 = <Type1 as ::glib::wrapper::Wrapper>::GlibType;
type Alias2 = InnerType2;
/*
error[E0119]: conflicting implementations of trait `glib::translate::ToGlibPtr<'_, *mut RustCounterMod::imp::RustCounterFfi>` for type `Type1`:
--> src/main.rs:1004:1
|
997 | impl <'a> ::glib::translate::ToGlibPtr<'a, *mut Alias1> for Type1
| ----------------------------------------------------------------- first implementation here
...
1004 | impl <'a> ::glib::translate::ToGlibPtr<'a, *mut Alias2> for Type1
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Type1`
*/
impl <'a> ::glib::translate::ToGlibPtr<'a, *mut Alias1> for Type1 //Line 997
{
type Storage = ();
fn to_glib_none(&'a self) -> ::glib::translate::Stash<'a, *mut Alias1, Self> { unimplemented!() }
}
impl <'a> ::glib::translate::ToGlibPtr<'a, *mut Alias2> for Type1 //Line 1004
{
type Storage = ();
fn to_glib_none(&'a self) -> ::glib::translate::Stash<'a, *mut Alias2, Self> { unimplemented!() }
}```