JoshOrndorff / recipes

A Hands-On Cookbook for Aspiring Blockchain Chefs
GNU General Public License v3.0
378 stars 188 forks source link

Missing type for accuracy #415

Closed ltfschoen closed 3 years ago

ltfschoen commented 3 years ago

I just did a fresh clone of the 'master' branch of this repo and got the following error when i ran cargo build --release. I haven't investigated why yet, but just thought I'd report it. rustc 1.52.0-nightly (35dbef235 2021-03-02)

     Compiling primitive-types v0.7.2
  error[E0282]: type annotations needed
      --> /Users/ls2/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
       |
  541  |                   let accuracy = P::ACCURACY.saturated_into();
       |                       ^^^^^^^^ consider giving `accuracy` a type
  ...
  1595 | / implement_fixed!(
  1596 | |     FixedI64,
  1597 | |     test_fixed_i64,
  1598 | |     i64,
  ...    |
  1601 | |     "_Fixed Point 64 bits signed, range = [-9223372036.854775808, 9223372036.854775807]_",
  1602 | | );
       | |__- in this macro invocation
       |
       = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

  error[E0282]: type annotations needed
      --> /Users/ls2/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
       |
  541  |                   let accuracy = P::ACCURACY.saturated_into();
       |                       ^^^^^^^^ consider giving `accuracy` a type
  ...
  1604 | / implement_fixed!(
  1605 | |     FixedI128,
  1606 | |     test_fixed_i128,
  1607 | |     i128,
  ...    |
  1611 | |         [-170141183460469231731.687303715884105728, 170141183460469231731.687303715884105727]_",
  1612 | | );
       | |__- in this macro invocation
       |
       = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

  error[E0282]: type annotations needed
      --> /Users/ls2/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
       |
  541  |                   let accuracy = P::ACCURACY.saturated_into();
       |                       ^^^^^^^^ consider giving `accuracy` a type
  ...
  1614 | / implement_fixed!(
  1615 | |     FixedU128,
  1616 | |     test_fixed_u128,
  1617 | |     u128,
  ...    |
  1621 | |         [0.000000000000000000, 340282366920938463463.374607431768211455]_",
  1622 | | );
       | |__- in this macro invocation
       |
       = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

  error: aborting due to 3 previous errors
JoshOrndorff commented 3 years ago

I've hit this issue too. I think it is a compiler version thing, but I honestly don't remember. Try downgrading?

ltfschoen commented 3 years ago

great call, yes downgrading with rustup default nightly-2020-10-06-x86_64-apple-darwin worked. it also worked with the latest version nightly-2021-03-10-x86_64-apple-darwin, so there must have been an issue with the initial version that i tried nightly-2021-03-03-x86_64-apple-darwin.

it might be worth adding a rust-toolchain file (doesn't have a file extension). example: https://github.com/HKalbasi/rust-arduino-generator/issues/1. it was also mentioned here https://github.com/rust-lang/cargo/issues/837

[toolchain]
channel = "nightly-2021-03-10"
components = ["rust-src"]

and add the latest known version of rust that works to it, so a user just has to run cargo build --release and it'll automatically download, switch to, and install the rustc version specified in the file. then when you run rustup toolchain list, it'll show it installed that version as:

nightly-2021-03-10-x86_64-apple-darwin (override)
ltfschoen commented 3 years ago

heres a rust blogpost that shows the formatting of the rust-toolchain file https://blog.rust-lang.org/2020/11/27/Rustup-1.23.0.html#new-format-for-rust-toolchain

ltfschoen commented 3 years ago

@JoshOrndorff we can close this issue, but just wondering whether you think it would be helpful to use the rust-toochain file in the repo?

JoshOrndorff commented 3 years ago

Glad that helped you

Yeah, I think a rust-toolchain file would be great. Moonbeam uses one and I've really enjoyed not having to guess what nightly compiler might work.

I'm no longer the maintainer of this repo anymore though; just an open source contributor. Maybe open another ticket to add that. (Or even a PR :) )

JoshOrndorff commented 3 years ago

Nice example from the arduino work. Out of curiosity, were you doing some embedded development?

jimmychu0807 commented 3 years ago

If we just upgrade recipe to Substrate to v3 and using the latest stable Rust compiler and that would solve it.

JoshOrndorff commented 3 years ago

I started working on the update. I hope to stick with it this week, but we'll see if time permits. Feel free to keep working (especially on the pallet tests) https://github.com/joshOrndorff/recipes/tree/joshy-3.0

jimmychu0807 commented 3 years ago

close with #419