'Getting `error: could not compile `libp2p-noise` due to previous error` while compiling a Substrate project

I have been trying to compile a Substarte project but getting this weird error.

error[E0282]: type annotations needed
   --> /Users/ayushkumarmishra/.cargo/registry/src/github.com-1ecc6299db9ec823/libp2p-noise-0.32.0/src/protocol/x25519.rs:221:45
    |
221 |         curve25519_sk.copy_from_slice(&hash.as_ref()[..32]);
    |                                        -----^^^^^^--
    |                                        |    |
    |                                        |    cannot infer type for type parameter `T` declared on the trait `AsRef`
    |                                        this method call resolves to `&T`
    |
    = note: type must be known at this point

For more information about this error, try `rustc --explain E0282`.
error: could not compile `libp2p-noise` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed

Can somebody please help me to fix this?

Below is the output of rustup show

installed toolchains

stable-aarch64-apple-darwin nightly-2021-08-31-aarch64-apple-darwin nightly-2021-11-07-aarch64-apple-darwin (default)

installed targets for active toolchain

aarch64-apple-darwin wasm32-unknown-unknown

active toolchain

nightly-2021-11-07-aarch64-apple-darwin (default)

rustc 1.58.0-nightly (072799443 2021-11-06)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source