Errors when 'rkyv' feature is activated.
If I try to compile my crate which imports kiddo with the rkyv feature activated, I get a lot of errors.
This is how I import kiddo:
kiddo = { version = "4.2.0", features = ["serialize", "rkyv"] }
And those are the errors:
error[E0432]: unresolved imports crate::float::kdtree::ArchivedKdTree, crate::float::kdtree::ArchivedLeafNode
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/float/query/best_n_within.rs:58:28
|
58 | use crate::float::kdtree::{ArchivedKdTree, ArchivedLeafNode};
| ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ no ArchivedLeafNode in float::kdtree
| |
| no ArchivedKdTree in float::kdtree
error[E0432]: unresolved import crate::float::kdtree::ArchivedKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/float/query/nearest_n.rs:50:5
|
50 | use crate::float::kdtree::ArchivedKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedKdTree in float::kdtree
error[E0432]: unresolved import crate::float::kdtree::ArchivedKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/float/query/nearest_n_within.rs:55:5
|
55 | use crate::float::kdtree::ArchivedKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedKdTree in float::kdtree
error[E0432]: unresolved imports crate::float::kdtree::ArchivedKdTree, crate::float::kdtree::ArchivedLeafNode
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/float/query/nearest_one.rs:55:28
|
55 | use crate::float::kdtree::{ArchivedKdTree, ArchivedLeafNode};
| ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ no ArchivedLeafNode in float::kdtree
| |
| no ArchivedKdTree in float::kdtree
error[E0432]: unresolved import crate::float::kdtree::ArchivedKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/float/query/within.rs:49:5
|
49 | use crate::float::kdtree::ArchivedKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedKdTree in float::kdtree
error[E0432]: unresolved import crate::float::kdtree::ArchivedKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/float/query/within_unsorted.rs:50:5
|
50 | use crate::float::kdtree::ArchivedKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedKdTree in float::kdtree
error[E0432]: unresolved import crate::float::kdtree::ArchivedKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/float/query/within_unsorted_iter.rs:52:5
|
52 | use crate::float::kdtree::ArchivedKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedKdTree in float::kdtree
error[E0432]: unresolved import crate::immutable::float::kdtree::ArchivedImmutableKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/immutable/float/query/approx_nearest_one.rs:51:5
|
51 | use crate::immutable::float::kdtree::ArchivedImmutableKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedImmutableKdTree in immutable::float::kdtree
error[E0432]: unresolved import crate::immutable::float::kdtree::ArchivedImmutableKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/immutable/float/query/best_n_within.rs:56:5
|
56 | use crate::immutable::float::kdtree::ArchivedImmutableKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedImmutableKdTree in immutable::float::kdtree
error[E0432]: unresolved import crate::immutable::float::kdtree::ArchivedImmutableKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/immutable/float/query/nearest_n.rs:48:5
|
48 | use crate::immutable::float::kdtree::ArchivedImmutableKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedImmutableKdTree in immutable::float::kdtree
error[E0432]: unresolved import crate::immutable::float::kdtree::ArchivedImmutableKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/immutable/float/query/nearest_n_within.rs:58:5
|
58 | use crate::immutable::float::kdtree::ArchivedImmutableKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedImmutableKdTree in immutable::float::kdtree
error[E0432]: unresolved import crate::immutable::float::kdtree::ArchivedImmutableKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/immutable/float/query/nearest_one.rs:56:5
|
56 | use crate::immutable::float::kdtree::ArchivedImmutableKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedImmutableKdTree in immutable::float::kdtree
error[E0432]: unresolved import crate::immutable::float::kdtree::ArchivedImmutableKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/immutable/float/query/within.rs:48:5
|
48 | use crate::immutable::float::kdtree::ArchivedImmutableKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedImmutableKdTree in immutable::float::kdtree
error[E0432]: unresolved import crate::immutable::float::kdtree::ArchivedImmutableKdTree
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/immutable/float/query/within_unsorted.rs:48:5
|
48 | use crate::immutable::float::kdtree::ArchivedImmutableKdTree;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no ArchivedImmutableKdTree in immutable::float::kdtree
error[E0412]: cannot find type ArchivedKdTree in this scope
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/float/kdtree.rs:293:7
|
293 | > ArchivedKdTree<A, T, K, B, IDX>
| ^^^^^^^^^^^^^^ not found in this scope
error[E0412]: cannot find type ArchivedImmutableKdTree in this scope
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/immutable/float/kdtree.rs:606:7
|
606 | > ArchivedImmutableKdTree<A, T, K, B>
| ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
error[E0412]: cannot find type ArchivedLeafNode in this scope
--> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-4.2.0/src/float_leaf_simd/leaf_node.rs:105:44
|
105 | impl<A, T, const K: usize, const B: usize> ArchivedLeafNode<A, T, K, B>
| ^^^^^^^^^^^^^^^^ not found in this scope
Some errors have detailed explanations: E0412, E0432.
For more information about an error, try rustc --explain E0412.
error: could not compile kiddo (lib) due to 17 previous errors
you might wanna use the serialize_rkyv feature as well - in my case that resolved the problem.
kiddo = { version = "4.2.0", features = ["rkyv", "serialize_rkyv"] }
Apologies, Kiddo should not be exposing rkyv as a feature here - this is due to incorrectly having serialize_rkyv = ["rkyv"] instead of serialize_rkyv = ["dep:rkyv"] in the lib.rs file., which causes rkyv to be exposed as a feature of Kiddo when only serialize_rkyv should have been exposed. This mistake is compounded by the inconsistent use of rkyv as a conditional compilation flag in the code, requiring both the serialize_rkyv and rkyv features needing to be enabled, as suggested by @t2m4k1 above.
For clarity and consistency with convention, I'll be renaming the serialize and serialize_rkyv features to serde and rkyv respectively, which will be a bit more self-explanatory. This will obviously be a breaking change and so will end up being in version 5.x.
This issue should be resolved in https://github.com/sdd/kiddo/pull/186 which was just released as Kiddo v5.0.0 🎉
https://crates.io/crates/kiddo/5.0.0
I know this issue was raised a while ago, and you have probably moved on, but if you do get chance to try v5 I'd love to hear any feedback. I'm closing this issue.