【问题标题】:Error while build error[E0282]: type annotations needed构建错误时出错 [E0282]:需要类型注释
【发布时间】:2021-04-12 11:32:27
【问题描述】:
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 cargo build --release

WASM_BUILD_TOOLCHAIN=nightly-2020-10-05 cargo build --release

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

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

【问题讨论】:

  • 抱歉,这个命令有效:cargo +nightly-2020-08-23 build --release

标签: substrate polkadot


【解决方案1】:

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

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

对于我来说,所有工具链的已知工作日期是 2020-10-5,并且从该日期起默认使用 nightly。

我也在使用 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)

【讨论】:

    【解决方案2】:

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

    只用这一行来解决

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

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-07-22
        • 2015-08-08
        • 1970-01-01
        • 1970-01-01
        • 2018-09-07
        • 2017-12-15
        • 2017-09-30
        • 2018-12-30
        相关资源
        最近更新 更多