json-ld icon indicating copy to clipboard operation
json-ld copied to clipboard

Compilation errors with rustc 1.64.0-nightly

Open roper79 opened this issue 2 years ago • 4 comments

Compiling 0.6.1 with current rustc 1.64.0-nightly (2643b1646 2022-07-27) results in multiple errors ambiguous associated type 'MetaData'.

roper79 avatar Jul 28 '22 12:07 roper79

I saw the same issue and I believe that I managed to fix it. I am relatively new to Rust, so there may be a much better fix. To fix the ambiguity, for each of the places where there was ambiguity, I clarified that the item has the type generic_json::Json.

Here is an example of one of the changes that I made to src/compaction/mod.rs. I changed:

M: 'a + Send + Sync + Clone + Fn(Option<&J::MetaData>) -> K::MetaData;

to:

M: 'a + Send + Sync + Clone + Fn(Option<&J::MetaData>) -> <K as generic_json::Json>::MetaData;

Similar changes need to be made to all instances of the error.

ashbeitz avatar Aug 15 '22 15:08 ashbeitz

It almost seems like a bug in the compiler. Chasing the patch that you suggested, one of the suggestions from the compiler was

error[E0221]: ambiguous associated type `MetaData` in bounds of `K`
   --> src/indexed.rs:142:72
    |
142 |     fn as_json_with(&self, meta: impl Clone + Fn(Option<&J::MetaData>) -> K::MetaData) -> K {
    |                                                                           ^^^^^^^^^^^ ambiguous associated type `MetaData`
    |
    = note: associated type `K` could derive from `generic_json::Json`
    = note: associated type `K` could derive from `generic_json::Json`

I'd have expected duplicate identical derivations would unify

blast-hardcheese avatar Aug 18 '22 19:08 blast-hardcheese

Also, for those interested, the build that broke this was nightly release 7c4b47696 2022-04-30. Last known good version was e85edd9a8 2022-04-28

blast-hardcheese avatar Aug 18 '22 20:08 blast-hardcheese

Yes this is a recurrent issue that keeps popping with new nightly releases. My goal is now to remove the trait_alias feature that causes a lot of problems and is not going to be stabilized soon. See #37 for more info. Once GATs are stabilized, then json_ld will be usable with stable Rust, and we won't have this kind of issues anymore.

timothee-haudebourg avatar Aug 24 '22 15:08 timothee-haudebourg

Sorry, drive-by-er at the moment. The GATs that this blog says are stable in 1.65 coming Nov 3rd (tomorrow)?

https://blog.rust-lang.org/2022/10/28/gats-stabilization.html

FrankReh avatar Nov 02 '22 22:11 FrankReh

@FrankReh that's right, and I already released a beta version on crates.io that works with this version. I have some more testing and documentation to write before I can safely remove the -beta label.

timothee-haudebourg avatar Nov 03 '22 09:11 timothee-haudebourg

I've just release version 0.9.1, which work with stable Rust 1.65. The transition from the old architecture may be rough, please don't hesitate to ask if you need help transitioning.

This should solve this issue.

timothee-haudebourg avatar Dec 09 '22 16:12 timothee-haudebourg