danielpclark / rutie

“The Tie Between Ruby and Rust.”
MIT License
940 stars 62 forks source link

Make generated class!es FFI compatible #130

Closed NeoLegends closed 3 years ago

NeoLegends commented 3 years ago

This should fix #128 and make rutie warning-free on rust v1.46.

danielpclark commented 3 years ago

@NeoLegends @calavera I'll try and get to this and make a release this evening.

danielpclark commented 3 years ago

I must have missed some changes to the Rust language. This evening I couldn't get past the following:

error[E0210]: type parameter `Obj` must be used as the type parameter for some local type (e.g., `MyStruct<Obj>`)
    --> src/class/traits/object.rs:1401:1
     |
1401 | impl<Obj: Object> From<Value> for Option<Obj> {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `Obj` must be used as the type parameter for some local type
     |
     = note: only traits defined in the current crate can be implemented for a type parameter

error: aborting due to previous error

I'll have to look into this more another day.

NeoLegends commented 3 years ago

This is due to rusts orphan rules, where you're only allowed to:

impl<T: LocalTrait> Blah for Option<T> {} doesn't satisfy this because this impl would also apply for foreign types that implement LocalTrait, which is forbidden.

But why does this have to do anything with merging and releasing this PR? We're using my fork for quite some time with just this fix applied and it compiles fine.

danielpclark commented 3 years ago

@NeoLegends

But why does this have to do anything with merging and releasing this PR?

The tests would not pass for Stable or Nightly and that is what this project tests against. I believe I'll need to update it so that every local trait implements this instead of the more convenient way that has worked until now. This is highly depended upon.