Hi, I'm working on the above tutorial and after running the cargo +nightly test command, I see the following error.

error[E0158]: associated consts cannot be referenced in patterns
  --> flipper/lib.rs:9:5
9  | /     pub struct Flipper {
10 | |         value: bool,
11 | |     }
   | |_____^

Nothing has been changed from the source code here. What is a workaround for this please?


  • I just did git clone for ink repo and cargo +nightly test work just fine. What is your contract version? try cargo contract -h. mine is 1.3.0
    – Maario
    Commented Sep 14, 2022 at 11:35
  • I have the same problem. Mine is 1.5.0
    – marethyu
    Commented Sep 14, 2022 at 11:53
  • 1
    While it does not fix your issue, you can use cargo test instead, it will work.
    – Cromm
    Commented Sep 14, 2022 at 18:58
  • @Maario mine is also 1.5.0
    – kenta_desu
    Commented Sep 15, 2022 at 0:07
  • @Cromm you are right, the tests do run correctly without the nightly channel
    – kenta_desu
    Commented Sep 15, 2022 at 0:08

1 Answer 1


cargo-contract latest release currently is v1.5.0 which was released on 15th August 2022. So I used rust nightly build of that day and it worked. I have ran the following commands and I am able to build the contract.

rustup toolchain install nightly-2022-08-15
rustup target add wasm32-unknown-unknown --toolchain nightly-2022-08-15
rustup component add rust-src --toolchain nightly-2022-08-15
cargo +nightly-2022-08-15 contract build
  • Indeed this works, thanks! But that does not solve the issue, it shouldn't be needed to use the same specific release date ? Or does it ?
    – Cromm
    Commented Sep 15, 2022 at 19:01
  • 1
    For me this solved the issue. Commented Oct 7, 2022 at 16:27
  • I use cargo +nightly-2022-08-15 test rather cargo +nightly test to test and cargo +nightly-2022-08-15 contract build to build rather cargo +nightly contract build today and it works for me. My cargo contract version cargo-contract 1.5.0-unknown-x86_64-apple-darwin and rustc 1.66.0-nightly (c0983a9aa 2022-10-12))
    – go11li
    Commented Oct 14, 2022 at 2:11

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.