Anupam
Anupam

Reputation: 538

What to do about "match is not allowed in a const fn" error?

When running the command:

cargo install cargo-generate --features vendored-openssl

I am getting the following error:

error[E0658]: `match` is not allowed in a `const fn`
   --> /home/pam/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.0/src/lib.rs:156:9
    |
156 | /         match address {
157 | |             SocketAddr::V4(_) => Domain::IPV4,
158 | |             SocketAddr::V6(_) => Domain::IPV6,
159 | |         }
    | |_________^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/49146

error[E0599]: no associated item named `MAX` found for type `usize` in the current scope
   --> /home/pam/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.0/src/sys/unix.rs:680:46
    |
680 |     msg.msg_iovlen = min(bufs.len(), IovLen::MAX as usize) as IovLen;
    |                                              ^^^ associated item not found in `usize`

error[E0599]: no associated item named `MAX` found for type `usize` in the current scope
   --> /home/pam/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.0/src/sys/unix.rs:740:46
    |
740 |     msg.msg_iovlen = min(bufs.len(), IovLen::MAX as usize) as IovLen;
    |                                              ^^^ associated item not found in `usize`

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0599, E0658.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `socket2`.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-generate v0.6.1`, intermediate artifacts can be found at `/tmp/cargo-install7B7MDG`

Caused by:
  build failed

Using Rust version 1.41.0 on Ubuntu 20.04.2 LTS. What am I missing here?

Upvotes: 6

Views: 3301

Answers (1)

Anupam
Anupam

Reputation: 538

Updating Rust worked for me:

curl https://sh.rustup.rs -sSf | sh

New version 1.52.0

Upvotes: 7

Related Questions