json-ld
json-ld copied to clipboard
Compilation errors with rustc 1.64.0-nightly
Compiling 0.6.1
with current rustc 1.64.0-nightly (2643b1646 2022-07-27)
results in multiple errors ambiguous associated type 'MetaData'
.
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.
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
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
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.
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 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.
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.