From bff6070fcd23b28a6a290e4a7b564f7f55c275f5 Mon Sep 17 00:00:00 2001 From: Herman Venter Date: Mon, 9 Oct 2023 10:32:13 -0700 Subject: [PATCH] Upgrade to Clap 4 (#1242) --- Cargo.lock | 272 +++++++++++++++++-------------------- binaries/summary_store.tar | Bin 2999296 -> 2991104 bytes checker/Cargo.toml | 2 +- checker/src/options.rs | 81 ++++++----- 4 files changed, 177 insertions(+), 178 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3db02b1a..edacd57c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,31 +4,68 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" dependencies = [ "memchr", ] [[package]] -name = "archery" +name = "anstream" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +dependencies = [ + "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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7d8a6d00b222909638a01ddcc8c533219e9d5bfada1613afae43481f2fc699" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ - "static_assertions", + "windows-sys", ] [[package]] -name = "atty" -version = "0.2.14" +name = "anstyle-wincon" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", + "anstyle", + "windows-sys", +] + +[[package]] +name = "archery" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab7d8a6d00b222909638a01ddcc8c533219e9d5bfada1613afae43481f2fc699" +dependencies = [ + "static_assertions", ] [[package]] @@ -63,7 +100,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.36", + "syn 2.0.38", ] [[package]] @@ -80,9 +117,9 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "camino" @@ -95,9 +132,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" +checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" dependencies = [ "serde", ] @@ -153,27 +190,30 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.25" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" dependencies = [ - "atty", - "bitflags 1.3.2", + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +dependencies = [ + "anstream", + "anstyle", "clap_lex", - "indexmap 1.9.3", "strsim 0.10.0", - "termcolor", - "textwrap", ] [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "cmake" @@ -184,6 +224,12 @@ dependencies = [ "cc", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "contracts" version = "0.6.3" @@ -204,16 +250,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -309,30 +345,19 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ - "errno-dragonfly", "libc", "windows-sys", ] -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "filetime" @@ -396,30 +421,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "humantime" @@ -435,22 +445,12 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "indexmap" -version = "1.9.3" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - -[[package]] -name = "indexmap" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown", ] [[package]] @@ -468,7 +468,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi", "rustix", "windows-sys", ] @@ -502,9 +502,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.148" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libloading" @@ -518,9 +518,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" +checksum = "45786cec4d5e54a224b15cb9f06751883103a27c19c93eda09b0b4f5f08fefac" [[package]] name = "lock_api" @@ -552,9 +552,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memoffset" @@ -623,22 +623,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.2", - "libc", -] - -[[package]] -name = "os_str_bytes" -version = "6.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" - [[package]] name = "parking_lot" version = "0.11.2" @@ -677,7 +661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.0", + "indexmap", ] [[package]] @@ -688,9 +672,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "5b1106fec09662ec6dd98ccac0f81cef56984d0b49f75c92d8cbad76e20c005c" dependencies = [ "unicode-ident", ] @@ -736,9 +720,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -746,14 +730,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -776,9 +758,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.5" +version = "1.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" dependencies = [ "aho-corasick", "memchr", @@ -788,9 +770,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" dependencies = [ "aho-corasick", "memchr", @@ -827,9 +809,9 @@ checksum = "8ba09476327c4b70ccefb6180f046ef588c26a24cf5d269a9feba316eb4f029f" [[package]] name = "rustix" -version = "0.38.13" +version = "0.38.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" +checksum = "f25469e9ae0f3d0047ca8b93fc56843f38e6774f0914a107ff8b41be8be8e0b7" dependencies = [ "bitflags 2.4.0", "errno", @@ -861,9 +843,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" dependencies = [ "serde", ] @@ -885,7 +867,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.36", + "syn 2.0.38", ] [[package]] @@ -941,9 +923,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "static_assertions" @@ -976,9 +958,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.36" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e02e55d62894af2a08aca894c6577281f76769ba47c94d5756bec8ac6e7373" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -1025,37 +1007,31 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "thiserror" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.36", + "syn 2.0.38", ] [[package]] @@ -1086,6 +1062,12 @@ dependencies = [ "mirai-annotations", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "verification_status" version = "0.1.0" @@ -1127,9 +1109,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] diff --git a/binaries/summary_store.tar b/binaries/summary_store.tar index 9054b15fdcc7f5d850659ff913b21f02855f3fb4..611834144f2f3d98c64d2f016bd278f7c95f3e6e 100644 GIT binary patch delta 346 zcmZ9|%TB^j5XNyv1;Jaj6ui;edKYMNYTMJ5D<8_GBrGs-g(mVC#+c9z?0pE0@kx$< zLedZ>`R%@ZlbPOAF1@d@yi}jd`lr^DcWsDe+a)#cT(9~Ki?7AMPz zR*^{Q$RbTb%{%(y4#X9#U=?d9qk?r*QNso{v4w5yz``!}V51HP4K%Tj103QA$7o@; z)5FO~T;Etf-_s9cehu^Ze)l)9JRbp0afWkT;1XB3#tqu&pqpD>SbiHhld!mT_OC2e Ly0|r$X=p0{($!O{ delta 1997 zcmd7TOHUI)00;1$+6OI_B2Q7!sSiY@>&(7}J#bhEq$C)%;42>L(yqoxDYRAb1c?Vs zJQX5vz!M+AM81NbLW5t!L;ZKDX$wWXkaW{uvYm9(`R6|~yZZebS^c<2y5*#tf0N1B zx%bI@A)9mL{JfJcM#qaRTujqGMN=u)bjA&#s6wTT3&sqIGWRFZ4MIw?P}@dvc0%C@5qa} z>|1BSUPw6-k)-`}!Sj6LN8J5qt;lLWJp=dc<+x*~o!p({@_5}moYm)1n67FPU9RR? zQ5nq?US*t7ZkU=mB6P0HoN>lXRWn1npwm-hR$@Fp^=Lv~whM)v+-S<9)&tAZ9w(TU z8JkpJzYJ+6oxwxXPyh80at8kf4K+&2*F9auu6G?ZjTnZ81o}aOuY`1xfSjD0&(7uD zA%DXj6$BE^*CWzJs#R7(SdE+GhN}Nhb4+k<3cU%M`&3(-5E`amTbox-rsv$wf?MgG zSi{|?3f7dZg{!T(8Mab8v1p&d#G&oRxpHW`Ddy4bHlpgxFctOmJKJxm94ifXo3ie$ z?~Dt~zH<0|Aig!?BjABE;Dz#-9|F((running_test_harness: bool) -> Command<'help> { +fn make_options_parser(running_test_harness: bool) -> Command { // We could put this into lazy_static! with a Mutex around, but we really do not expect // to construct this more then once per regular program run. let mut parser = Command::new("MIRAI") @@ -18,50 +20,51 @@ fn make_options_parser<'help>(running_test_harness: bool) -> Command<'help> { .version("v1.1.7") .arg(Arg::new("single_func") .long("single_func") - .takes_value(true) + .num_args(1) .help("Focus analysis on the named function.") .long_help("Name is the simple name of a top-level crate function or a MIRAI summary key.")) .arg(Arg::new("diag") .long("diag") - .possible_values(["default", "verify", "library", "paranoid"]) + .num_args(1) + .value_parser(["default", "verify", "library", "paranoid"]) .default_value("default") .help("Level of diagnostics.\n") .long_help("With `default`, false positives will be avoided where possible.\nWith 'verify' errors are reported for incompletely analyzed functions.\nWith `paranoid`, all possible errors will be reported.\n")) .arg(Arg::new("constant_time") .long("constant_time") - .takes_value(true) + .num_args(1) .help("Enable verification of constant-time security.") .long_help("Name is a top-level crate type")) .arg(Arg::new("body_analysis_timeout") .long("body_analysis_timeout") - .takes_value(true) + .num_args(1) .default_value("30") .help("The maximum number of seconds that MIRAI will spend analyzing a function body.") .long_help("The default is 30 seconds.")) .arg(Arg::new("crate_analysis_timeout") .long("crate_analysis_timeout") - .takes_value(true) + .num_args(1) .default_value("240") .help("The maximum number of seconds that MIRAI will spend analyzing a function body.") .long_help("The default is 240 seconds.")) .arg(Arg::new("statistics") .long("statistics") - .takes_value(false) + .num_args(0) .help("Just print out whether crates were analyzed, etc.") .long_help("Just print out whether crates were analyzed and how many diagnostics were produced for each crate.")) .arg(Arg::new("call_graph_config") .long("call_graph_config") - .takes_value(true) + .num_args(1) .help("Path call graph config.") .long_help(r#"Path to a JSON file that configures call graph output. Please see the documentation for details (https://github.com/facebookexperimental/MIRAI/blob/main/documentation/CallGraph.md)."#)) .arg(Arg::new("print_function_names") .long("print_function_names") - .takes_value(false) + .num_args(0) .help("Just print out the signatures of functions in the crate")); if running_test_harness { parser = parser.arg(Arg::new("test_only") .long("test_only") - .takes_value(false) + .num_args(0) .help("Focus analysis on #[test] methods.") .long_help("Only #[test] methods and their usage are analyzed. This must be used together with the rustc --test option.")); } @@ -169,11 +172,11 @@ impl Options { make_options_parser(running_test_harness).get_matches_from(mirai_args.iter()) }; - if matches.is_present("single_func") { - self.single_func = matches.value_of("single_func").map(|s| s.to_string()); + if matches.contains_id("single_func") { + self.single_func = matches.get_one::("single_func").cloned(); } - if matches.is_present("diag") { - self.diag_level = match matches.value_of("diag").unwrap() { + if matches.contains_id("diag") { + self.diag_level = match matches.get_one::("diag").unwrap().as_str() { "default" => DiagLevel::Default, "verify" => DiagLevel::Verify, "library" => DiagLevel::Library, @@ -181,26 +184,34 @@ impl Options { _ => assume_unreachable!(), }; } - if running_test_harness && matches.is_present("test_only") { + if running_test_harness + && !matches!( + matches.value_source("test_only"), + Some(ValueSource::DefaultValue) + ) + { self.test_only = true; if self.diag_level != DiagLevel::Paranoid { self.diag_level = DiagLevel::Library; } } - if matches.is_present("constant_time") { - self.constant_time_tag_name = matches.value_of("constant_time").map(|s| s.to_owned()); + if matches.contains_id("constant_time") { + self.constant_time_tag_name = matches.get_one::("constant_time").cloned(); } - if matches.is_present("body_analysis_timeout") { - self.max_analysis_time_for_body = match matches.value_of("body_analysis_timeout") { - Some(s) => match s.parse::() { - Ok(v) => v, - Err(_) => handler.early_error("--body_analysis_timeout expects an integer"), - }, - None => assume_unreachable!(), - } + if matches.contains_id("body_analysis_timeout") { + self.max_analysis_time_for_body = + match matches.get_one::("body_analysis_timeout") { + Some(s) => match s.parse::() { + Ok(v) => v, + Err(_) => handler.early_error("--body_analysis_timeout expects an integer"), + }, + None => assume_unreachable!(), + } } - if matches.is_present("crate_analysis_timeout") { - self.max_analysis_time_for_crate = match matches.value_of("crate_analysis_timeout") { + if matches.contains_id("crate_analysis_timeout") { + self.max_analysis_time_for_crate = match matches + .get_one::("crate_analysis_timeout") + { Some(s) => match s.parse::() { Ok(v) => v, Err(_) => handler.early_error("--crate_analysis_timeout expects an integer"), @@ -208,13 +219,19 @@ impl Options { None => assume_unreachable!(), } } - if matches.is_present("statistics") { + if !matches!( + matches.value_source("statistics"), + Some(ValueSource::DefaultValue) + ) { self.statistics = true; } - if matches.is_present("call_graph_config") { - self.call_graph_config = matches.value_of("call_graph_config").map(|s| s.to_string()); + if matches.contains_id("call_graph_config") { + self.call_graph_config = matches.get_one::("call_graph_config").cloned(); } - if matches.is_present("print_function_names") { + if !matches!( + matches.value_source("print_function_names"), + Some(ValueSource::DefaultValue) + ) { self.print_function_names = true; } args[rustc_args_start..].to_vec()