`const fn` 中不允许带有 match` 的货物编译错误

cargo compile errors with match` is not allowed in a `const fn`

如标题所示,以下命令失败:

cargo install cargo-generate --features vendored-openssl

我收到以下错误:

pam@g3:~$ cargo install cargo-generate --features vendored-openssl
    Updating crates.io index
  Installing cargo-generate v0.6.1
   Compiling libc v0.2.94
   Compiling autocfg v1.0.1
   Compiling proc-macro2 v1.0.26
   Compiling unicode-xid v0.2.2
   Compiling pkg-config v0.3.19
   Compiling syn v1.0.72
   Compiling cfg-if v1.0.0
   Compiling serde_derive v1.0.125
   Compiling memchr v2.4.0
   Compiling serde v1.0.125
   Compiling version_check v0.9.3
   Compiling regex-syntax v0.6.25
   Compiling bitflags v1.2.1
   Compiling log v0.4.14
   Compiling matches v0.1.8
   Compiling getrandom v0.2.2
   Compiling percent-encoding v2.1.0
   Compiling proc-macro-hack v0.5.19
   Compiling tinyvec_macros v0.1.0
   Compiling unicode-width v0.1.8
   Compiling ucd-trie v0.1.3
   Compiling once_cell v1.7.2
   Compiling lazy_static v1.4.0
   Compiling ryu v1.0.5
   Compiling maplit v1.0.2
   Compiling typenum v1.13.0
   Compiling crc32fast v1.2.1
   Compiling curl v0.4.36
   Compiling anyhow v1.0.40
   Compiling serde_json v1.0.64
   Compiling openssl-probe v0.1.2
   Compiling ppv-lite86 v0.2.10
   Compiling unicode-segmentation v1.7.1
   Compiling foreign-types-shared v0.1.1
   Compiling either v1.6.1
   Compiling itoa v0.4.7
   Compiling openssl v0.10.34
   Compiling vec_map v0.8.2
   Compiling strsim v0.8.0
   Compiling fnv v1.0.7
   Compiling rand_core v0.5.1
   Compiling utf8parse v0.1.1
   Compiling remove_dir_all v0.5.3
   Compiling same-file v1.0.6
   Compiling doc-comment v0.3.3
   Compiling ansi_term v0.11.0
   Compiling anymap v0.12.1
   Compiling termcolor v1.1.2
   Compiling hex v0.3.2
   Compiling semver-parser v0.7.0
   Compiling humantime v2.1.0
   Compiling lazycell v1.3.0
   Compiling zeroize v1.3.0
   Compiling rustc-workspace-hack v1.0.0
   Compiling bytesize v1.0.1
   Compiling glob v0.3.0
   Compiling hex v0.4.3
   Compiling number_prefix v0.3.0
   Compiling opener v0.4.1
   Compiling shell-escape v0.1.5
   Compiling home v0.5.3
   Compiling unicode-bidi v0.3.5
   Compiling form_urlencoded v1.0.1
   Compiling tinyvec v1.2.0
   Compiling textwrap v0.11.0
   Compiling pest v2.1.3
   Compiling thread_local v1.1.3
   Compiling foreign-types v0.3.2
   Compiling itertools v0.10.0
   Compiling heck v0.3.2
   Compiling vte v0.3.3
   Compiling num-traits v0.2.14
   Compiling num-integer v0.1.44
   Compiling crossbeam-utils v0.8.4
   Compiling rand_xoshiro v0.4.0
   Compiling walkdir v2.3.2
   Compiling proc-macro-error-attr v1.0.4
   Compiling proc-macro-error v1.0.4
   Compiling im-rc v15.0.0
   Compiling strip-ansi-escapes v0.1.0
   Compiling unicode-normalization v0.1.17
   Compiling pest_meta v2.1.3
   Compiling quote v1.0.9
   Compiling aho-corasick v0.7.18
   Compiling bstr v0.2.16
   Compiling jobserver v0.1.22
   Compiling atty v0.2.14
   Compiling filetime v0.2.14
   Compiling time v0.1.43
   Compiling socket2 v0.4.0
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

货物版本:

pam@g3:~$ cargo --version
cargo 1.41.0

rustc 版本:

pam@g3:~$ rustc --version
rustc 1.41.0

Ubuntu 版本:Ubuntu 20.04.2 LTS

我在这里错过了什么?

更新 cargo 命令对我有用。

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

新版本:

cargo 1.52.0 (69767412a 2021-04-21)