sdd / kiddo

Kiddo
Apache License 2.0
85 stars 14 forks source link

Compiler errors if i include the `fixed` crate with feature `num-traits` enabled. #89

Closed rendarz closed 10 months ago

rendarz commented 10 months ago

I use the kiddo crate with f32 and f64 types, and NOT with any of the fixed types. I also use the fixed crate for separate calculations, not involved with Kd-Trees or kiddo crate. But, when I use fixed with the feature num-traits enabled, like this: fixed = { version = "1.24.0", features = ["serde", "num-traits"] }, then I get a BUNCH of errors from the kiddo crate sources, when I try to build my project.

PLEASE HELP! Or I cannot build my project! :(

$  cargo build

   Compiling kiddo v2.1.1
error[E0034]: multiple applicable items in scope
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/common/generate_best_n_within.rs:17:27
   |
17 |           let mut off = [A::zero(); K];
   |                             ^^^^ multiple `zero` found
   |
  ::: /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/query/best_n_within.rs:15:5
   |
15 | /     generate_best_n_within!(
16 | |         LeafNode,
17 | |         (r#"Queries the tree to find the best `n` elements within `dist` of `point`, using the specified
18 | | distance metric function. Results are returned in arbitrary order. 'Best' is determined by
...  |
41 | | ```"#)
42 | |     );
   | |_____- in this macro invocation
   |
note: candidate #1 is defined in the trait `fixed::kdtree::Axis`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/kdtree.rs:26:5
   |
26 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `num_traits::Zero`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.16/src/identities.rs:20:5
   |
20 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `generate_best_n_within` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
   |
17 |         let mut off = [<A as fixed::kdtree::Axis>::zero(); K];
   |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
17 |         let mut off = [<A as num_traits::Zero>::zero(); K];
   |                        ~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0034]: multiple applicable items in scope
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/common/generate_best_n_within.rs:30:20
   |
30 |                   A::zero(),
   |                      ^^^^ multiple `zero` found
   |
  ::: /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/query/best_n_within.rs:15:5
   |
15 | /     generate_best_n_within!(
16 | |         LeafNode,
17 | |         (r#"Queries the tree to find the best `n` elements within `dist` of `point`, using the specified
18 | | distance metric function. Results are returned in arbitrary order. 'Best' is determined by
...  |
41 | | ```"#)
42 | |     );
   | |_____- in this macro invocation
   |
note: candidate #1 is defined in the trait `fixed::kdtree::Axis`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/kdtree.rs:26:5
   |
26 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `num_traits::Zero`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.16/src/identities.rs:20:5
   |
20 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `generate_best_n_within` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
   |
30 |                 <A as fixed::kdtree::Axis>::zero(),
   |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
30 |                 <A as num_traits::Zero>::zero(),
   |                 ~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0034]: multiple applicable items in scope
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/common/generate_nearest_n.rs:11:27
   |
11 |           let mut off = [A::zero(); K];
   |                             ^^^^ multiple `zero` found
   |
  ::: /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/query/nearest_n.rs:16:5
   |
16 | /     generate_nearest_n!(
17 | |         (r#"Finds the nearest `qty` elements to `query`, using the specified
18 | | distance metric function.
19 | |
...  |
40 | | ```"#)
41 | |     );
   | |_____- in this macro invocation
   |
note: candidate #1 is defined in the trait `fixed::kdtree::Axis`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/kdtree.rs:26:5
   |
26 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `num_traits::Zero`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.16/src/identities.rs:20:5
   |
20 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `generate_nearest_n` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
   |
11 |         let mut off = [<A as fixed::kdtree::Axis>::zero(); K];
   |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
11 |         let mut off = [<A as num_traits::Zero>::zero(); K];
   |                        ~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0034]: multiple applicable items in scope
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/common/generate_nearest_n.rs:22:20
   |
22 |                   A::zero(),
   |                      ^^^^ multiple `zero` found
   |
  ::: /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/query/nearest_n.rs:16:5
   |
16 | /     generate_nearest_n!(
17 | |         (r#"Finds the nearest `qty` elements to `query`, using the specified
18 | | distance metric function.
19 | |
...  |
40 | | ```"#)
41 | |     );
   | |_____- in this macro invocation
   |
note: candidate #1 is defined in the trait `fixed::kdtree::Axis`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/kdtree.rs:26:5
   |
26 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `num_traits::Zero`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.16/src/identities.rs:20:5
   |
20 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `generate_nearest_n` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
   |
22 |                 <A as fixed::kdtree::Axis>::zero(),
   |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
22 |                 <A as num_traits::Zero>::zero(),
   |                 ~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0034]: multiple applicable items in scope
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/common/generate_nearest_one.rs:11:35
   |
11 |                   let mut off = [A::zero(); K];
   |                                     ^^^^ multiple `zero` found
   |
  ::: /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/query/nearest_one.rs:14:5
   |
14 | /     generate_nearest_one!(
15 | |         LeafNode,
16 | |         (r#"Queries the tree to find the nearest element to `query`, using the specified
17 | | distance metric function.
...  |
41 | | ```"#)
42 | |     );
   | |_____- in this macro invocation
   |
note: candidate #1 is defined in the trait `fixed::kdtree::Axis`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/kdtree.rs:26:5
   |
26 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `num_traits::Zero`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.16/src/identities.rs:20:5
   |
20 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `generate_nearest_one` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
   |
11 |                 let mut off = [<A as fixed::kdtree::Axis>::zero(); K];
   |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
11 |                 let mut off = [<A as num_traits::Zero>::zero(); K];
   |                                ~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0034]: multiple applicable items in scope
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/common/generate_nearest_one.rs:20:28
   |
20 |                           A::max_value(),
   |                              ^^^^^^^^^ multiple `max_value` found
   |
  ::: /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/query/nearest_one.rs:14:5
   |
14 | /     generate_nearest_one!(
15 | |         LeafNode,
16 | |         (r#"Queries the tree to find the nearest element to `query`, using the specified
17 | | distance metric function.
...  |
41 | | ```"#)
42 | |     );
   | |_____- in this macro invocation
   |
note: candidate #1 is defined in the trait `Bounded`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.16/src/bounds.rs:12:5
   |
12 |     fn max_value() -> Self;
   |     ^^^^^^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `fixed::kdtree::Axis`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/kdtree.rs:24:5
   |
24 |     fn max_value() -> Self;
   |     ^^^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `generate_nearest_one` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
   |
20 |                         <A as Bounded>::max_value(),
   |                         ~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
20 |                         <A as fixed::kdtree::Axis>::max_value(),
   |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0034]: multiple applicable items in scope
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/common/generate_nearest_one.rs:22:28
   |
22 |                           A::zero(),
   |                              ^^^^ multiple `zero` found
   |
  ::: /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/query/nearest_one.rs:14:5
   |
14 | /     generate_nearest_one!(
15 | |         LeafNode,
16 | |         (r#"Queries the tree to find the nearest element to `query`, using the specified
17 | | distance metric function.
...  |
41 | | ```"#)
42 | |     );
   | |_____- in this macro invocation
   |
note: candidate #1 is defined in the trait `fixed::kdtree::Axis`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/kdtree.rs:26:5
   |
26 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `num_traits::Zero`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.16/src/identities.rs:20:5
   |
20 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `generate_nearest_one` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
   |
22 |                         <A as fixed::kdtree::Axis>::zero(),
   |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
22 |                         <A as num_traits::Zero>::zero(),
   |                         ~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0034]: multiple applicable items in scope
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/common/generate_within.rs:11:27
   |
11 |           let mut off = [A::zero(); K];
   |                             ^^^^ multiple `zero` found
   |
  ::: /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/query/within.rs:16:5
   |
16 | /     generate_within!(
17 | |         (r#"Finds all elements within `dist` of `query`, using the specified
18 | | distance metric function.
19 | |
...  |
41 | | ```"#)
42 | |     );
   | |_____- in this macro invocation
   |
note: candidate #1 is defined in the trait `fixed::kdtree::Axis`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/kdtree.rs:26:5
   |
26 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `num_traits::Zero`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.16/src/identities.rs:20:5
   |
20 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `generate_within` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
   |
11 |         let mut off = [<A as fixed::kdtree::Axis>::zero(); K];
   |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
11 |         let mut off = [<A as num_traits::Zero>::zero(); K];
   |                        ~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0034]: multiple applicable items in scope
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/common/generate_within.rs:23:20
   |
23 |                   A::zero(),
   |                      ^^^^ multiple `zero` found
   |
  ::: /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/query/within.rs:16:5
   |
16 | /     generate_within!(
17 | |         (r#"Finds all elements within `dist` of `query`, using the specified
18 | | distance metric function.
19 | |
...  |
41 | | ```"#)
42 | |     );
   | |_____- in this macro invocation
   |
note: candidate #1 is defined in the trait `fixed::kdtree::Axis`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/kdtree.rs:26:5
   |
26 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `num_traits::Zero`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.16/src/identities.rs:20:5
   |
20 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `generate_within` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
   |
23 |                 <A as fixed::kdtree::Axis>::zero(),
   |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
23 |                 <A as num_traits::Zero>::zero(),
   |                 ~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0034]: multiple applicable items in scope
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/common/generate_within_unsorted.rs:11:27
   |
11 |           let mut off = [A::zero(); K];
   |                             ^^^^ multiple `zero` found
   |
  ::: /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/query/within_unsorted.rs:15:5
   |
15 | /     generate_within_unsorted!(
16 | |         (r#"Finds all elements within `dist` of `query`, using the specified
17 | | distance metric function.
18 | |
...  |
41 | | ```"#)
42 | |     );
   | |_____- in this macro invocation
   |
note: candidate #1 is defined in the trait `fixed::kdtree::Axis`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/kdtree.rs:26:5
   |
26 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `num_traits::Zero`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.16/src/identities.rs:20:5
   |
20 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `generate_within_unsorted` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
   |
11 |         let mut off = [<A as fixed::kdtree::Axis>::zero(); K];
   |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
11 |         let mut off = [<A as num_traits::Zero>::zero(); K];
   |                        ~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0034]: multiple applicable items in scope
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/common/generate_within_unsorted.rs:23:20
   |
23 |                   A::zero(),
   |                      ^^^^ multiple `zero` found
   |
  ::: /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/query/within_unsorted.rs:15:5
   |
15 | /     generate_within_unsorted!(
16 | |         (r#"Finds all elements within `dist` of `query`, using the specified
17 | | distance metric function.
18 | |
...  |
41 | | ```"#)
42 | |     );
   | |_____- in this macro invocation
   |
note: candidate #1 is defined in the trait `fixed::kdtree::Axis`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/kiddo-2.1.1/src/fixed/kdtree.rs:26:5
   |
26 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `num_traits::Zero`
  --> /home/rendar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.16/src/identities.rs:20:5
   |
20 |     fn zero() -> Self;
   |     ^^^^^^^^^^^^^^^^^^
   = note: this error originates in the macro `generate_within_unsorted` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
   |
23 |                 <A as fixed::kdtree::Axis>::zero(),
   |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
23 |                 <A as num_traits::Zero>::zero(),
   |                 ~~~~~~~~~~~~~~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0034`.
error: could not compile `kiddo` (lib) due to 11 previous errors
sdd commented 10 months ago

Hi Rendarz - I'll take a look into this for you today and see what I can do 👍🏼

sdd commented 10 months ago

Fix released as https://crates.io/crates/kiddo/2.1.2.

Thanks for reporting! 👍🏼

rendarz commented 9 months ago

Thank you for your promptly response. Your work is great. Keep it on!