2
  1. 我尝试“https://substrate.dev/substrate-contracts-workshop/#/”
  2. 我按照教程创建了一个 Rust 环境。
  3. 我执行了“货物+夜间测试”
  4. 我得到以下错误。
error[E0658]: function pointers cannot appear in constant functions
   --> /Users/shin.takahashi/.cargo/git/checkouts/ink-1add513eda8f5a89/cca3154/lang/src/dispatcher.rs:186:30
    |
186 |               pub const fn new(dispatchable: $dispatchable_fn<Msg, S>) -> Self {
    |                                ^^^^^^^^^^^^
...
237 | / impl_dispatcher_for! {
238 | |     /// Dispatcher for storage preserving messages.
239 | |     struct Dispatcher(DispatchableFn);
240 | | }
    | |_- in this macro invocation
    |
    = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
    = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

请告诉我有什么问题???

4

2 回答 2

2

我无法解决它,但我能够使其可编译和可执行。更正~/.cargo/git/checkouts/ink-XXXXX/cca-XXXX/lang/source/disposacher.rs的错误部分如下。

//pub const fn new(dispatchable: $dispatchable_fn<Msg, S>) -> Self { // before
pub fn new(dispatchable: $dispatchable_fn<Msg, S>) -> Self { // after
于 2020-10-10T22:57:45.457 回答
0

墨水似乎已更新。我运行了货物更新,然后毫无错误地建立了合同。

$ testcontract % cargo update
    Updating git repository `https://github.com/paritytech/ink`
    Updating crates.io index
    Updating git repository `https://github.com/type-metadata/type-metadata.git`
    Updating aho-corasick v0.7.13 -> v0.7.14
    Updating regex v1.3.9 -> v1.4.1
    Updating regex-syntax v0.6.18 -> v0.6.20
    Updating serde_json v1.0.58 -> v1.0.59
    Updating syn v1.0.43 -> v1.0.44
    Updating toml v0.5.6 -> v0.5.7
$ testcontract % sh build.sh
 [1/4] Collecting crate metadata
 [2/4] Building cargo project
   Compiling compiler_builtins v0.1.35
   Compiling core v0.0.0 (/Users/home/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
   Compiling rustc-std-workspace-core v1.99.0 (/Users/home/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/var/folders/xj/m862kvrj73x04dvsfr6vs_fm0000gn/T/cargo-xbuild8YkYwG)
    Finished release [optimized] target(s) in 13.19s
   Compiling cfg-if v0.1.10
   Compiling serde_json v1.0.59
   Compiling byte-slice-cast v0.3.5
   Compiling arrayvec v0.5.1
   Compiling memory_units v0.4.0
   Compiling regex-syntax v0.6.20
   Compiling smallvec v1.4.2
   Compiling crunchy v0.2.2
   Compiling paste v0.1.18
   Compiling aho-corasick v0.7.14
   Compiling num-traits v0.2.12
   Compiling toml v0.5.7
   Compiling ink_prelude v2.1.0 (https://github.com/paritytech/ink?tag=latest-v2#cca31543)
   Compiling tiny-keccak v2.0.2
   Compiling wee_alloc v0.4.5
   Compiling ink_alloc v2.1.0 (https://github.com/paritytech/ink?tag=latest-v2#cca31543)
   Compiling proc-macro-crate v0.1.5
   Compiling parity-scale-codec-derive v1.2.2
   Compiling regex v1.4.1
   Compiling parity-scale-codec v1.3.5
   Compiling ink_primitives v2.1.0 (https://github.com/paritytech/ink?tag=latest-v2#cca31543)
   Compiling ink_core_derive v2.1.0 (https://github.com/paritytech/ink?tag=latest-v2#cca31543)
   Compiling ink_lang_macro v2.1.0 (https://github.com/paritytech/ink?tag=latest-v2#cca31543)
   Compiling ink_core v2.1.0 (https://github.com/paritytech/ink?tag=latest-v2#cca31543)
   Compiling ink_lang v2.1.0 (https://github.com/paritytech/ink?tag=latest-v2#cca31543)
   Compiling testcontract v0.1.0 (/var/folders/xj/m862kvrj73x04dvsfr6vs_fm0000gn/T/.cargo-contract_rKI7GO)
    Finished release [optimized] target(s) in 13.91s
 [3/4] Post processing wasm file
 [4/4] Optimizing wasm file
 Original wasm size: 21.8K, Optimized: 5.0K

Your contract is ready. You can find it here:
/Users/home/projects/testcontract/target/testcontract.wasm
于 2020-10-14T01:00:17.077 回答