i know that this is a duplicate, but problem must be resolved...

So, there are 2 "solutions":

  1. Contract flipper build fails
  2. error[E0158] when testing default contract from flipper

But not a single one worked for me. I still get error that : "associated consts cannot be referenced in patter" rustc(E0158).

Is there anything else that could be done to resolve this?


  1. cargo contract: cargo-contract 1.5.0-unknown-x86_64-pc-windows-msvc
  2. rustc: rustc 1.66.0-nightly (470e518c4 2022-09-27)
  • have you used latest nightly rust? Have a look this link you may find solution.
    – Ganesh11
    Sep 29, 2022 at 0:27
  • 1
    "associated consts cannot be referenced in pattern" This is a known issue see github.com/paritytech/ink/pull/1418. We will try and get a release out soon with this fix Sep 29, 2022 at 8:06
  • Okay then, Thanks! Sep 29, 2022 at 18:41

2 Answers 2


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))


You can use the following configuration

cargo-contract v2.0.0-alpha.4 (https://github.com/paritytech/cargo-contract#6626f56f):
cargo 1.64.0 (387270bc7 2022-09-16)

and use ink! version 4 https://crates.io/crates/ink/4.0.0-alpha.3

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.