3

This Substrate PR removed TryInto from the sp_std's prelude: https://github.com/paritytech/substrate/pull/11136

While attempting to update to v0.9.19, which includes this PR, I am encountering this error:

error[E0433]: failed to resolve: use of undeclared type `TryInto`
   --> pallets/parachain-staking/src/lib.rs:160:12
    |
160 |     #[pallet::error]
    |               ^^^^^ not found in this scope
    |
    = note: 'sp_std::convert::TryInto' is included in the prelude starting in Edition 2021
    = note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021
    = note: 'core::convert::TryInto' is included in the prelude starting in Edition 2021
help: consider importing one of these items
    |
72  |     use core::convert::TryInto;
    |
72  |     use sp_std::convert::TryInto;
    |
72  |     use std::convert::TryInto;

The error suggests that TryInto should be included in Edition 2021, but this constraint seems to be satisfied. Here is rustup show output:

Default host: x86_64-unknown-linux-gnu
rustup home:  /home/stephen/.rustup

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

nightly-2022-02-20-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)

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

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.62.0-nightly (082e4ca49 2022-04-26)

If I revert the Substrate commit/PR mentioned above, the problem goes away.

I'm able to compile substrate itself as well as polkadot and cumulus at their respective v0.9.19 branches without any errors.

The exact line of code that produced this error can be found on the Moonbeam repository: https://github.com/PureStake/moonbeam/blob/bc4d3dbd6159893fab4d9adb265a581d7c502563/pallets/parachain-staking/src/lib.rs#L161

And can be reproduced by compiling that pallet with cargo build -p parachain-staking.

Any suggestions would be greatly appreciated, thanks!

3
  • can you provide source of the code that is misbehaving?
    – Nuke
    Commented Apr 27, 2022 at 16:44
  • 1
    I added a link to the exact LOC that produced the error. It appears to come from any case of #[pallet::error] in our repo.
    – notlesh
    Commented Apr 27, 2022 at 18:24
  • 2
    the Cargo.toml says edition 2018, though. github.com/PureStake/moonbeam/blob/…
    – apopiak
    Commented Apr 27, 2022 at 19:29

1 Answer 1

4

As @apopiak had suggested in the comments, your Cargo.toml is still set as the 2018 edition of Rust, hence it is not able to locate TryInto in the prelude. My guess is that if you change it to 2021, it will fix your issue.

1
  • Thanks, that was indeed the problem!
    – notlesh
    Commented Apr 27, 2022 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.