build failed in substrate.dev Ink! tutorial. sp-aritmetic lack of type?

399 views Asked by At

My build has failed.

Everything looked good up until I tested my contract with the command:

cargo +nightly test

I got error [E0282]

Here is the whole error report:

error[E0282]: type annotations needed
      --> /home/mal/.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
      --> /home/mal/.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
      --> /home/mal/.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

  For more information about this error, try `rustc --explain E0282`.
  error: could not compile `sp-arithmetic`

This is part of a wider tutorial.

I believe rust is updated.

The problem seems to be the macro sp-aritmetic, however I am not sure how to give it a "type". My rust is non-existent...

Really eager to get into Ink! so any help is appreciated.

1

There are 1 answers

2
Alexander Theißen On

The cause of that error is a regression in the rust nightly compiler starting with version 2020-10-06. You need to rustup toolchain install 2020-10-05 and use that one for building your runtime until this issue is resolved. Usually, the latest nightly is automatically used to build your runtime. You can override this behaviour by setting the WASM_BUILD_TOOLCHAIN environment variable. In this case:

export WASM_BUILD_TOOLCHAIN='nightly-2020-10-05'

In case of building a contract with cargo contract you should use:

cargo +nightly-2020-10-05 contract build