Repository: mozilla/cbindgen (language: rust)

Issue:
Upgrade to clap 4 (getting rid of `atty` as a transitive dependency)
`cbindgen` is still depending on `clap 3` which in turn depends no `atty`. An unmaintained crate with a [known unsoundness issue](https://rustsec.org/advisories/RUSTSEC-2021-0145.html). We are really trying to get rid of `atty` from our dependency tree, but we also need `cbindgen`. So this issue is about considering an upgrade to `clap 4`.


Discussion / hints:

Fix patch:
diff --git a/.clippy.toml b/.clippy.toml
index e9b576d3a..4785aed47 100644
--- a/.clippy.toml
+++ b/.clippy.toml
@@ -1,2 +1,2 @@
 # Specify the minimum supported Rust version
-msrv = "1.64.0"
+msrv = "1.70"
diff --git a/.github/workflows/cbindgen.yml b/.github/workflows/cbindgen.yml
index 13b1d042d..9b1811298 100644
--- a/.github/workflows/cbindgen.yml
+++ b/.github/workflows/cbindgen.yml
@@ -31,7 +31,7 @@ jobs:
 
     - name: Install minimum supported Rust version
       id: msrv
-      uses: dtolnay/rust-toolchain@1.64
+      uses: dtolnay/rust-toolchain@1.70
 
     - name: Build with minimum supported Rust version
       run: |
diff --git a/Cargo.lock b/Cargo.lock
index 7e117882c..f29ff098f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3,14 +3,51 @@
 version = 3
 
 [[package]]
-name = "atty"
-version = "0.2.14"
+name = "anstream"
+version = "0.6.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6"
 dependencies = [
- "hermit-abi",
- "libc",
- "winapi",
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
+
+[[package]]
+name = "anstyle-parse"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
+dependencies = [
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
+dependencies = [
+ "anstyle",
+ "windows-sys 0.52.0",
 ]
 
 [[package]]
@@ -25,6 +62,12 @@ version = "1.3.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
 
+[[package]]
+name = "bitflags"
+version = "2.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
+
 [[package]]
 name = "cbindgen"
 version = "0.26.0"
@@ -51,42 +94,77 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 
 [[package]]
 name = "clap"
-version = "3.2.25"
+version = "4.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2"
+dependencies = [
+ "clap_builder",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.4.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
+checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb"
 dependencies = [
- "atty",
- "bitflags",
+ "anstream",
+ "anstyle",
  "clap_lex",
- "indexmap",
  "strsim",
- "termcolor",
- "textwrap",
 ]
 
 [[package]]
 name = "clap_lex"
-version = "0.2.4"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
+
+[[package]]
+name = "colorchoice"
+version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
+checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
+
+[[package]]
+name = "dashmap"
+version = "5.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
 dependencies = [
- "os_str_bytes",
+ "cfg-if",
+ "hashbrown",
+ "lock_api",
+ "once_cell",
+ "parking_lot_core",
 ]
 
 [[package]]
-name = "fastrand"
-version = "1.9.0"
+name = "equivalent"
+version = "1.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
+checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
+
+[[package]]
+name = "errno"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
 dependencies = [
- "instant",
+ "libc",
+ "windows-sys 0.52.0",
 ]
 
+[[package]]
+name = "fastrand"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
+
 [[package]]
 name = "hashbrown"
-version = "0.12.3"
+version = "0.14.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
 
 [[package]]
 name = "heck"
@@ -94,39 +172,21 @@ version = "0.4.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
 
-[[package]]
-name = "hermit-abi"
-version = "0.1.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
-dependencies = [
- "libc",
-]
-
 [[package]]
 name = "indexmap"
-version = "1.9.3"
+version = "2.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
+checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
 dependencies = [
- "autocfg",
+ "equivalent",
  "hashbrown",
 ]
 
-[[package]]
-name = "instant"
-version = "0.1.12"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
-dependencies = [
- "cfg-if",
-]
-
 [[package]]
 name = "itoa"
-version = "1.0.6"
+version = "1.0.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
+checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
 
 [[package]]
 name = "lazy_static"
@@ -136,15 +196,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
 [[package]]
 name = "libc"
-version = "0.2.144"
+version = "0.2.151"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
+checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
 
 [[package]]
 name = "lock_api"
-version = "0.4.9"
+version = "0.4.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df"
+checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
 dependencies = [
  "autocfg",
  "scopeguard",
@@ -152,129 +218,144 @@ dependencies = [
 
 [[package]]
 name = "log"
-version = "0.4.17"
+version = "0.4.20"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
-dependencies = [
- "cfg-if",
-]
+checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
 
 [[package]]
-name = "os_str_bytes"
-version = "6.5.0"
+name = "memchr"
+version = "2.6.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267"
+checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
+
+[[package]]
+name = "once_cell"
+version = "1.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
 
 [[package]]
 name = "parking_lot"
-version = "0.11.2"
+version = "0.12.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
+checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
 dependencies = [
- "instant",
  "lock_api",
  "parking_lot_core",
 ]
 
 [[package]]
 name = "parking_lot_core"
-version = "0.8.6"
+version = "0.9.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc"
+checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
 dependencies = [
  "cfg-if",
- "instant",
  "libc",
  "redox_syscall",
  "smallvec",
- "winapi",
+ "windows-targets 0.48.5",
 ]
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.66"
+version = "1.0.71"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
+checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8"
 dependencies = [
  "unicode-ident",
 ]
 
 [[package]]
 name = "quote"
-version = "1.0.27"
+version = "1.0.33"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500"
+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
 dependencies = [
  "proc-macro2",
 ]
 
 [[package]]
 name = "redox_syscall"
-version = "0.2.16"
+version = "0.4.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
+checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
 dependencies = [
- "bitflags",
+ "bitflags 1.3.2",
 ]
 
 [[package]]
-name = "remove_dir_all"
-version = "0.5.3"
+name = "rustix"
+version = "0.38.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
+checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"
 dependencies = [
- "winapi",
+ "bitflags 2.4.1",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.52.0",
 ]
 
 [[package]]
 name = "ryu"
-version = "1.0.13"
+version = "1.0.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
+checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
 
 [[package]]
 name = "scopeguard"
-version = "1.1.0"
+version = "1.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
 
 [[package]]
 name = "serde"
-version = "1.0.163"
+version = "1.0.193"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2"
+checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
 dependencies = [
  "serde_derive",
 ]
 
 [[package]]
 name = "serde_derive"
-version = "1.0.163"
+version = "1.0.193"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e"
+checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.16",
+ "syn 2.0.43",
 ]
 
 [[package]]
 name = "serde_json"
-version = "1.0.96"
+version = "1.0.108"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
+checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
 dependencies = [
  "itoa",
  "ryu",
  "serde",
 ]
 
+[[package]]
+name = "serde_spanned"
+version = "0.6.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1"
+dependencies = [
+ "serde",
+]
+
 [[package]]
 name = "serial_test"
-version = "0.5.1"
+version = "2.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0bccbcf40c8938196944a3da0e133e031a33f4d6b72db3bda3cc556e361905d"
+checksum = "0e56dd856803e253c8f298af3f4d7eb0ae5e23a737252cd90bb4f3b435033b2d"
 dependencies = [
+ "dashmap",
  "lazy_static",
  "parking_lot",
  "serial_test_derive",
@@ -282,20 +363,20 @@ dependencies = [
 
 [[package]]
 name = "serial_test_derive"
-version = "0.5.1"
+version = "2.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5"
+checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 1.0.109",
+ "syn 2.0.43",
 ]
 
 [[package]]
 name = "smallvec"
-version = "1.10.0"
+version = "1.11.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
+checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
 
 [[package]]
 name = "strsim"
@@ -316,9 +397,9 @@ dependencies = [
 
 [[package]]
 name = "syn"
-version = "2.0.16"
+version = "2.0.43"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01"
+checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -327,75 +408,200 @@ dependencies = [
 
 [[package]]
 name = "tempfile"
-version = "3.3.0"
+version = "3.8.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
+checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5"
 dependencies = [
  "cfg-if",
  "fastrand",
- "libc",
  "redox_syscall",
- "remove_dir_all",
- "winapi",
+ "rustix",
+ "windows-sys 0.48.0",
 ]
 
 [[package]]
-name = "termcolor"
-version = "1.2.0"
+name = "toml"
+version = "0.8.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
+checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35"
 dependencies = [
- "winapi-util",
+ "serde",
+ "serde_spanned",
+ "toml_datetime",
+ "toml_edit",
 ]
 
 [[package]]
-name = "textwrap"
-version = "0.16.0"
+name = "toml_datetime"
+version = "0.6.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
+checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
+dependencies = [
+ "serde",
+]
 
 [[package]]
-name = "toml"
-version = "0.5.11"
+name = "toml_edit"
+version = "0.21.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
+checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03"
 dependencies = [
+ "indexmap",
  "serde",
+ "serde_spanned",
+ "toml_datetime",
+ "winnow",
 ]
 
 [[package]]
 name = "unicode-ident"
-version = "1.0.8"
+version = "1.0.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
 
 [[package]]
-name = "winapi"
-version = "0.3.9"
+name = "utf8parse"
+version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
+
+[[package]]
+name = "windows-sys"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
 dependencies = [
- "winapi-i686-pc-windows-gnu",
- "winapi-x86_64-pc-windows-gnu",
+ "windows-targets 0.48.5",
 ]
 
 [[package]]
-name = "winapi-i686-pc-windows-gnu"
-version = "0.4.0"
+name = "windows-sys"
+version = "0.52.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
+dependencies = [
+ "windows-targets 0.52.0",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
+dependencies = [
+ "windows_aarch64_gnullvm 0.48.5",
+ "windows_aarch64_msvc 0.48.5",
+ "windows_i686_gnu 0.48.5",
+ "windows_i686_msvc 0.48.5",
+ "windows_x86_64_gnu 0.48.5",
+ "windows_x86_64_gnullvm 0.48.5",
+ "windows_x86_64_msvc 0.48.5",
+]
 
 [[package]]
-name = "winapi-util"
-version = "0.1.5"
+name = "windows-targets"
+version = "0.52.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
 dependencies = [
- "winapi",
+ "windows_aarch64_gnullvm 0.52.0",
+ "windows_aarch64_msvc 0.52.0",
+ "windows_i686_gnu 0.52.0",
+ "windows_i686_msvc 0.52.0",
+ "windows_x86_64_gnu 0.52.0",
+ "windows_x86_64_gnullvm 0.52.0",
+ "windows_x86_64_msvc 0.52.0",
 ]
 
 [[package]]
-name = "winapi-x86_64-pc-windows-gnu"
-version = "0.4.0"
+name = "windows_aarch64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.48.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.48.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
+
+[[package]]
+name = "winnow"
+version = "0.5.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b5c3db89721d50d0e2a673f5043fc4722f76dcc352d7b1ab8b8288bed4ed2c5"
+dependencies = [
+ "memchr",
+]
diff --git a/Cargo.toml b/Cargo.toml
index ca6ab302e..5df80fd7f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,19 +13,19 @@ keywords = ["bindings", "ffi", "code-generation"]
 categories = ["external-ffi-bindings", "development-tools::ffi"]
 repository = "https://github.com/mozilla/cbindgen"
 edition = "2018"
-rust-version = "1.64"
+rust-version = "1.70"
 exclude = [
   "tests/profile.rs", # Test relies in a sub-crate, see https://github.com/rust-lang/cargo/issues/9017
 ]
 
 [dependencies]
-clap = { version = "3.1", optional = true }
-indexmap = "1"
+clap = { version = "4.3", optional = true }
+indexmap = "2.1.0"
 log = "0.4"
 serde = { version = "1.0.103", default-features = false, features = ["derive"] }
 serde_json = "1.0"
 tempfile = "3"
-toml = "0.5"
+toml = "0.8.8"
 proc-macro2 = "1.0.60"
 quote = "1"
 heck = "0.4"
@@ -36,7 +36,7 @@ default-features = false
 features = ["clone-impls", "extra-traits", "fold", "full", "parsing", "printing"]
 
 [dev-dependencies]
-serial_test = "0.5.0"
+serial_test = { version = "2.0.0", default-features = false }
 
 [features]
 default =  ["clap"]
diff --git a/README.md b/README.md
index 22183e4b3..77f7fdd2f 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# `cbindgen` &emsp; [![Build Status]][actions] [![Latest Version]][crates.io] [![Api Rustdoc]][rustdoc] [![Rust](https://img.shields.io/badge/rust-1.64%2B-blue.svg?maxAge=3600)](https://github.com/mozilla/cbindgen)
+# `cbindgen` &emsp; [![Build Status]][actions] [![Latest Version]][crates.io] [![Api Rustdoc]][rustdoc] [![Rust](https://img.shields.io/badge/rust-1.70%2B-blue.svg?maxAge=3600)](https://github.com/mozilla/cbindgen)
 
 [Build Status]: https://github.com/mozilla/cbindgen/workflows/cbindgen/badge.svg
 [actions]: https://github.com/mozilla/cbindgen/actions
diff --git a/src/bindgen/builder.rs b/src/bindgen/builder.rs
index a0328b409..4d2eee12b 100644
--- a/src/bindgen/builder.rs
+++ b/src/bindgen/builder.rs
@@ -375,7 +375,7 @@ impl Builder {
         }
 
         if let Some((lib_dir, binding_lib_name)) = self.lib.clone() {
-            let lockfile = self.lockfile.as_ref().and_then(|p| p.to_str());
+            let lockfile = self.lockfile.as_deref();
 
             let cargo = Cargo::load(
                 &lib_dir,
diff --git a/src/bindgen/cargo/cargo.rs b/src/bindgen/cargo/cargo.rs
index 69cf938b3..542f8e330 100644
--- a/src/bindgen/cargo/cargo.rs
+++ b/src/bindgen/cargo/cargo.rs
@@ -36,7 +36,7 @@ impl Cargo {
     /// need to be parsed.
     pub(crate) fn load(
         crate_dir: &Path,
-        lock_file: Option<&str>,
+        lock_file: Option<&Path>,
         binding_crate_name: Option<&str>,
         use_cargo_lock: bool,
         clean: bool,
diff --git a/src/main.rs b/src/main.rs
index eb78a080b..e9c5ffc35 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -20,60 +20,58 @@ extern crate quote;
 extern crate syn;
 extern crate toml;
 
-use clap::{Arg, ArgMatches, Command};
+use clap::{value_parser, Arg, ArgAction, ArgMatches, Command};
 
 mod bindgen;
 mod logging;
 
-use crate::bindgen::{Bindings, Builder, Cargo, Config, Error, Profile, Style};
+use bindgen::{Bindings, Builder, Cargo, Config, Error};
 
 fn apply_config_overrides(config: &mut Config, matches: &ArgMatches) {
     // We allow specifying a language to override the config default. This is
     // used by compile-tests.
-    if let Some(lang) = matches.value_of("lang") {
-        config.language = match lang.parse() {
-            Ok(lang) => lang,
-            Err(reason) => {
-                error!("{}", reason);
-                return;
-            }
+    match matches.try_get_one::<String>("lang") {
+        Ok(Some(lang)) => {
+            config.language = bindgen::Language::from_str(lang).unwrap();
+        }
+        Err(reason) => {
+            error!("{}", reason);
+            return;
         }
+        _ => (),
     }
 
-    if matches.is_present("cpp-compat") {
+    if matches.get_flag("cpp-compat") {
         config.cpp_compat = true;
     }
 
-    if matches.is_present("only-target-dependencies") {
+    if matches.get_flag("only-target-dependencies") {
         config.only_target_dependencies = true;
     }
 
-    if let Some(style) = matches.value_of("style") {
-        config.style = match style {
-            "Both" => Style::Both,
-            "both" => Style::Both,
-            "Tag" => Style::Tag,
-            "tag" => Style::Tag,
-            "Type" => Style::Type,
-            "type" => Style::Type,
-            _ => {
-                error!("Unknown style specified.");
-                return;
-            }
+    match matches.try_get_one::<String>("style") {
+        Ok(Some(style)) => {
+            config.style = bindgen::Style::from_str(style).unwrap();
+        }
+        Err(_) => {
+            error!("Unknown style specified.");
+            return;
         }
+        _ => (),
     }
 
-    if let Some(profile) = matches.value_of("profile") {
-        config.parse.expand.profile = match Profile::from_str(profile) {
-            Ok(p) => p,
-            Err(e) => {
-                error!("{}", e);
-                return;
-            }
+    match matches.try_get_one::<String>("profile") {
+        Ok(Some(profile)) => {
+            config.parse.expand.profile = bindgen::Profile::from_str(profile).unwrap();
+        }
+        Err(e) => {
+            error!("{}", e);
+            return;
         }
+        _ => (),
     }
 
-    if matches.is_present("d") {
+    if matches.get_flag("d") {
         config.parse.parse_deps = true;
     }
 }
@@ -82,7 +80,7 @@ fn load_bindings(input: &Path, matches: &ArgMatches) -> Result<Bindings, Error>
     // If a file is specified then we load it as a single source
     if !input.is_dir() {
         // Load any config specified or search in the input directory
-        let mut config = match matches.value_of("config") {
+        let mut config = match matches.get_one::<PathBuf>("config") {
             Some(c) => Config::from_file(c).unwrap(),
             None => Config::from_root_or_default(
                 input
@@ -102,16 +100,16 @@ fn load_bindings(input: &Path, matches: &ArgMatches) -> Result<Bindings, Error>
     // We have to load a whole crate, so we use cargo to gather metadata
     let lib = Cargo::load(
         input,
-        matches.value_of("lockfile"),
-        matches.value_of("crate"),
+        matches.get_one::<PathBuf>("lockfile").map(|s| s.as_path()),
+        matches.get_one::<String>("crate").map(|s| s.as_str()),
         true,
-        matches.is_present("clean"),
-        matches.is_present("only-target-dependencies"),
-        matches.value_of("metadata").map(Path::new),
+        matches.get_flag("clean"),
+        matches.get_flag("only-target-dependencies"),
+        matches.get_one::<PathBuf>("metadata").map(|p| p.as_path()),
     )?;
 
     // Load any config specified or search in the binding crate directory
-    let mut config = match matches.value_of("config") {
+    let mut config = match matches.get_one::<PathBuf>("config") {
         Some(c) => Config::from_file(c).unwrap(),
         None => {
             let binding_crate_dir = lib.find_crate_dir(&lib.binding_crate_ref());
@@ -140,12 +138,13 @@ fn main() {
         .arg(
             Arg::new("v")
                 .short('v')
-                .multiple_occurrences(true)
+                .action(ArgAction::Count)
                 .help("Enable verbose logging"),
         )
         .arg(
             Arg::new("verify")
                 .long("verify")
+                .action(ArgAction::SetTrue)
                 .help("Generate bindings and compare it to the existing bindings file and error if they are different"),
         )
         .arg(
@@ -153,6 +152,7 @@ fn main() {
                 .short('c')
                 .long("config")
                 .value_name("PATH")
+                .value_parser(value_parser!(PathBuf))
                 .help("Specify path to a `cbindgen.toml` config to use"),
         )
         .arg(
@@ -161,16 +161,18 @@ fn main() {
                 .long("lang")
                 .value_name("LANGUAGE")
                 .help("Specify the language to output bindings in")
-                .possible_values(["c++", "C++", "c", "C", "cython", "Cython"]),
+                .value_parser(["c++", "C++", "c", "C", "cython", "Cython"]),
         )
         .arg(
             Arg::new("cpp-compat")
                 .long("cpp-compat")
+                .action(ArgAction::SetTrue)
                 .help("Whether to add C++ compatibility to generated C bindings")
         )
         .arg(
             Arg::new("only-target-dependencies")
                 .long("only-target-dependencies")
+                .action(ArgAction::SetTrue)
                 .help("Only fetch dependencies needed by the target platform. \
                     The target platform defaults to the host platform; set TARGET to override.")
         )
@@ -180,17 +182,19 @@ fn main() {
                 .long("style")
                 .value_name("STYLE")
                 .help("Specify the declaration style to use for bindings")
-                .possible_values(["Both", "both", "Tag", "tag", "Type", "type"]),
+                .value_parser(["Both", "both", "Tag", "tag", "Type", "type"]),
         )
         .arg(
             Arg::new("d")
                 .short('d')
                 .long("parse-dependencies")
+                .action(ArgAction::SetTrue)
                 .help("Whether to parse dependencies when generating bindings"),
         )
         .arg(
             Arg::new("clean")
                 .long("clean")
+                .action(ArgAction::SetTrue)
                 .help(
                     "Whether to use a new temporary directory for expanding macros. \
                     Affects performance, but might be required in certain build processes.")
@@ -203,6 +207,7 @@ fn main() {
                     In general this is the folder where the Cargo.toml file of \
                     source Rust library resides.")
                 .required(false)
+                .value_parser(value_parser!(PathBuf))
                 .index(1),
         )
         .arg(
@@ -221,6 +226,7 @@ fn main() {
                 .long("output")
                 .value_name("PATH")
                 .help("The file to output the bindings to")
+                .value_parser(value_parser!(PathBuf))
                 .required(false),
         )
         .arg(
@@ -232,6 +238,7 @@ fn main() {
                     is not specified, the Cargo.lock file is searched for in the \
                     same folder as the Cargo.toml file. This option is useful for \
                     projects that use workspaces.")
+                .value_parser(value_parser!(PathBuf))
                 .required(false),
         )
         .arg(
@@ -247,6 +254,7 @@ fn main() {
                      `cargo metadata --all-features --format-version 1 \
                       --manifest-path <path/to/crate/Cargo.toml>"
                 )
+                .value_parser(value_parser!(PathBuf))
                 .required(false),
         )
         .arg(
@@ -257,12 +265,13 @@ fn main() {
                     "Specify the profile to use when expanding macros. \
                      Has no effect otherwise."
                 )
-                .possible_values(["Debug", "debug", "Release", "release"]),
+                .value_parser(["Debug", "debug", "Release", "release"]),
         )
         .arg(
             Arg::new("quiet")
                 .short('q')
                 .long("quiet")
+                .action(ArgAction::SetTrue)
                 .help("Report errors only (overrides verbosity options).")
                 .required(false),
         )
@@ -270,10 +279,9 @@ fn main() {
             Arg::new("depfile")
                 .value_name("PATH")
                 .long("depfile")
-                .takes_value(true)
-                .min_values(1)
-                .max_values(1)
+                .num_args(1)
                 .required(false)
+                .value_parser(value_parser!(PathBuf))
                 .help("Generate a depfile at the given Path listing the source files \
                     cbindgen traversed when generating the bindings. Useful when \
                     integrating cbindgen into 3rd party build-systems. \
@@ -282,7 +290,7 @@ fn main() {
         )
         .get_matches();
 
-    if !matches.is_present("out") && matches.is_present("verify") {
+    if matches.get_flag("verify") && !matches.contains_id("out") {
         error!(
             "Cannot verify bindings against `stdout`, please specify a file to compare against."
         );
@@ -290,10 +298,10 @@ fn main() {
     }
 
     // Initialize logging
-    if matches.is_present("quiet") {
+    if matches.get_flag("quiet") {
         logging::ErrorLogger::init().unwrap();
     } else {
-        match matches.occurrences_of("v") {
+        match matches.get_count("v") {
             0 => logging::WarnLogger::init().unwrap(),
             1 => logging::InfoLogger::init().unwrap(),
             _ => logging::TraceLogger::init().unwrap(),
@@ -301,10 +309,10 @@ fn main() {
     }
 
     // Find the input directory
-    let input = match matches.value_of("INPUT") {
-        Some(input) => PathBuf::from(input),
-        None => env::current_dir().unwrap(),
-    };
+    let input: PathBuf = matches
+        .get_one("INPUT")
+        .cloned()
+        .unwrap_or_else(|| env::current_dir().unwrap());
 
     let bindings = match load_bindings(&input, &matches) {
         Ok(bindings) => bindings,
@@ -316,15 +324,15 @@ fn main() {
     };
 
     // Write the bindings file
-    match matches.value_of("out") {
+    match matches.get_one::<PathBuf>("out") {
         Some(file) => {
             let changed = bindings.write_to_file(file);
 
-            if matches.is_present("verify") && changed {
-                error!("Bindings changed: {}", file);
+            if matches.get_flag("verify") && changed {
+                error!("Bindings changed: {}", file.display());
                 std::process::exit(2);
             }
-            if let Some(depfile) = matches.value_of("depfile") {
+            if let Some(depfile) = matches.get_one("depfile") {
                 bindings.generate_depfile(file, depfile)
             }
         }


Test patch:
diff --git a/tests/depfile.rs b/tests/depfile.rs
index 7d629f35d..512f69b09 100644
--- a/tests/depfile.rs
+++ b/tests/depfile.rs
@@ -44,7 +44,11 @@ fn test_project(project_path: &str) {
     let mut cmake_build = Command::new("cmake");
     cmake_build.arg("--build").arg(&build_dir);
     let output = cmake_build.output().expect("Failed to execute process");
-    assert!(output.status.success(), "Building test project failed");
+    assert!(
+        output.status.success(),
+        "Building test project failed: {:?}",
+        output
+    );
     let out_str = String::from_utf8(output.stdout).unwrap();
     assert!(
         out_str.contains("Running cbindgen"),
@@ -85,7 +89,11 @@ fn test_project(project_path: &str) {
     assert_eq!(dep_list, expected_dep_list);
 
     let output = cmake_build.output().expect("Failed to execute process");
-    assert!(output.status.success(), "Building test project failed");
+    assert!(
+        output.status.success(),
+        "Building test project failed: {:?}",
+        output
+    );
     let out_str = String::from_utf8(output.stdout).unwrap();
     assert!(
         !out_str.contains("Running cbindgen"),