构建错误时出错[E0282]:需要类型注释 注意:这应该很快在基板 v2.0.1 中修复

问题描述

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

我使用的是 Ubuntu 20.04,两者都给出了相同的错误
WASM_BUILD_TOOLCHAIN=nightly-2020-08-23 货物构建 --release

WASM_BUILD_TOOLCHAIN=nightly-2020-10-05 货物构建 --release

https://github.com/substrate-developer-hub/substrate-node-template/blob/4d97032c11b8c65936e53a61607d4522d45a29ea/Makefile

https://stackoverflow.com/a/63993797/1566713

解决方法

注意:这应该很快在基板 v2.0.1 中修复

现在您可能需要降级您的工具链:https://substrate.dev/docs/en/knowledgebase/getting-started/#downgrading-rust-nightly

对我来说,所有工具链的已知工作日期是 2020-10-5,并且默认使用从那个日期开始的每晚。

我也在 Ubuntu 20.04LTS 上,并且使用:

$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  ....

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu
nightly-2020-10-05-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu

installed targets for active toolchain
--------------------------------------

wasm32-unknown-unknown
x86_64-unknown-linux-gnu

active toolchain
----------------

nightly-2020-10-05-x86_64-unknown-linux-gnu (default)
rustc 1.49.0-nightly (beb5ae474 2020-10-04)
,

这里是问题 https://github.com/paritytech/substrate/issues/7287

只用这一行解决

rustup default nightly-2020-10-06 && rustup target add wasm32-unknown-unknown
,

此问题已在 v2.0.1 中修复,请尝试使用以下命令删除项目并再次克隆。

git clone -b v2.0.1 --depth 1 https://github.com/substrate-developer-hub/substrate-node-template