diff --git a/Cargo.lock b/Cargo.lock index 3c17749..d5612ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -25,9 +25,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "anstream" -version = "0.6.21" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" dependencies = [ "anstyle", "anstyle-parse", @@ -40,44 +40,44 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" [[package]] name = "anstyle-parse" -version = "0.2.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.10" +version = "3.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "anyhow" -version = "1.0.100" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" [[package]] name = "ar" @@ -87,9 +87,9 @@ checksum = "d67af77d68a931ecd5cbd8a3b5987d63a1d1d1278f7f6a60ae33db485cdebb69" [[package]] name = "bitflags" -version = "2.9.4" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" [[package]] name = "byteorder" @@ -99,9 +99,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "camino" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276a59bf2b2c967788139340c9f0c5b12d7fd6630315c15c217e559de85d2609" +checksum = "e629a66d692cb9ff1a1c664e41771b3dcaf961985a9774c0eb0bd1b51cf60a48" dependencies = [ "serde_core", ] @@ -118,16 +118,16 @@ dependencies = [ "colored", "crossterm", "diff", - "fxhash", "gimli", "indoc", "is-terminal", "log", "object", "once_cell", + "ra-ap-rustc_lexer", "ratatui", - "rustc-ap-rustc_lexer", "rustc-demangle", + "rustc-hash", "serde", "serde_json", "tempfile", @@ -167,15 +167,15 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] name = "cfg-if" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "clap" -version = "4.5.48" +version = "4.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae" +checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" dependencies = [ "clap_builder", "clap_derive", @@ -183,9 +183,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.48" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" dependencies = [ "anstream", "anstyle", @@ -195,9 +195,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.47" +version = "4.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c" +checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -207,15 +207,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" [[package]] name = "colorchoice" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" [[package]] name = "colored" @@ -308,15 +308,15 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" [[package]] name = "fastrand" -version = "2.3.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" [[package]] name = "flate2" -version = "1.1.4" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc5a4e564e38c699f2880d3fda590bedc2e69f3f84cd48b457bd892ce61d0aa9" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" dependencies = [ "crc32fast", "miniz_oxide", @@ -328,25 +328,17 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "getrandom" -version = "0.3.3" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" dependencies = [ "cfg-if", "libc", "r-efi", - "wasi 0.14.7+wasi-0.2.4", + "wasip2", + "wasip3", ] [[package]] @@ -372,9 +364,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" [[package]] name = "heck" @@ -394,38 +386,49 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + [[package]] name = "indexmap" -version = "2.11.4" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown 0.17.0", + "serde", + "serde_core", ] [[package]] name = "indoc" -version = "2.0.6" +version = "2.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd" +checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706" +dependencies = [ + "rustversion", +] [[package]] name = "is-terminal" -version = "0.4.16" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" +checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] name = "is_terminal_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "itertools" @@ -438,9 +441,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "lazy_static" @@ -448,17 +451,23 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "libc" -version = "0.2.176" +version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] name = "linux-raw-sys" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "lock_api" @@ -471,9 +480,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "lru" @@ -486,9 +495,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.6" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "miniz_oxide" @@ -508,7 +517,7 @@ checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "wasi 0.11.1+wasi-snapshot-preview1", + "wasi", "windows-sys 0.48.0", ] @@ -525,15 +534,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.3" +version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "once_cell_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "parking_lot" @@ -564,29 +573,50 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.41" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] [[package]] name = "r-efi" -version = "5.3.0" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "ra-ap-rustc_lexer" +version = "0.162.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +checksum = "19f7c98243fd8a53ec2ad549feb09ddc38beef3f3d9c969284a123ce8f7b341a" +dependencies = [ + "memchr", + "unicode-ident", + "unicode-properties", +] [[package]] name = "ratatui" @@ -616,25 +646,22 @@ dependencies = [ ] [[package]] -name = "rustc-ap-rustc_lexer" -version = "727.0.0" +name = "rustc-demangle" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f40f26e7abdcd3b982f36c09a634cc6187988fbf6ec466c91f8d30a12ac0237" -dependencies = [ - "unicode-xid", -] +checksum = "b50b8869d9fc858ce7266cce0194bd74df58b9d0e3f6df3a9fc8eb470d95c09d" [[package]] -name = "rustc-demangle" -version = "0.1.26" +name = "rustc-hash" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" [[package]] name = "rustix" -version = "1.1.2" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ "bitflags", "errno", @@ -660,12 +687,6 @@ dependencies = [ "twox-hash", ] -[[package]] -name = "ryu" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" - [[package]] name = "scopeguard" version = "1.2.0" @@ -674,9 +695,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" dependencies = [ "serde", "serde_core", @@ -714,15 +735,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.145" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ "itoa", "memchr", - "ryu", "serde", "serde_core", + "zmij", ] [[package]] @@ -746,9 +767,9 @@ dependencies = [ [[package]] name = "signal-hook-mio" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" +checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc" dependencies = [ "libc", "mio", @@ -757,18 +778,19 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.6" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" dependencies = [ + "errno", "libc", ] [[package]] name = "simd-adler32" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" [[package]] name = "smallvec" @@ -778,9 +800,9 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "static_assertions" @@ -818,9 +840,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.106" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -829,9 +851,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.23.0" +version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", "getrandom", @@ -903,7 +925,7 @@ dependencies = [ "serde_spanned", "toml_datetime", "toml_write", - "winnow 0.7.13", + "winnow 0.7.15", ] [[package]] @@ -934,15 +956,21 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.19" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-properties" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" [[package]] name = "unicode-segmentation" -version = "1.12.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" [[package]] name = "unicode-width" @@ -969,21 +997,55 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] -name = "wasi" -version = "0.14.7+wasi-0.2.4" +name = "wasip2" +version = "1.0.3+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" +checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" dependencies = [ - "wasip2", + "wit-bindgen 0.57.1", ] [[package]] -name = "wasip2" -version = "1.0.1+wasi-0.2.4" +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen 0.51.0", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" dependencies = [ - "wit-bindgen", + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", ] [[package]] @@ -1032,15 +1094,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-sys" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets 0.53.5", -] - [[package]] name = "windows-sys" version = "0.61.2" @@ -1074,30 +1127,13 @@ dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", + "windows_i686_gnullvm", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] -[[package]] -name = "windows-targets" -version = "0.53.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" -dependencies = [ - "windows-link", - "windows_aarch64_gnullvm 0.53.1", - "windows_aarch64_msvc 0.53.1", - "windows_i686_gnu 0.53.1", - "windows_i686_gnullvm 0.53.1", - "windows_i686_msvc 0.53.1", - "windows_x86_64_gnu 0.53.1", - "windows_x86_64_gnullvm 0.53.1", - "windows_x86_64_msvc 0.53.1", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -1110,12 +1146,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" - [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -1128,12 +1158,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" - [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -1146,24 +1170,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" -[[package]] -name = "windows_i686_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" - [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" - [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -1176,12 +1188,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_i686_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" - [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -1194,12 +1200,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -1212,12 +1212,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" - [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -1230,12 +1224,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" - [[package]] name = "winnow" version = "0.5.40" @@ -1247,15 +1235,109 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.13" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" dependencies = [ "memchr", ] [[package]] name = "wit-bindgen" -version = "0.46.0" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck 0.5.0", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck 0.5.0", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "zmij" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index 1d56f9f..fcb01a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "cargo-acl" version = "0.8.0" -edition = "2021" -rust-version = "1.74" +edition = "2024" +rust-version = "1.95" license = "MIT OR Apache-2.0" description = "A Rust code ACL checker" readme = "README.md" @@ -10,27 +10,27 @@ repository = "https://github.com/cackle-rs/cackle" keywords = ["cargo", "plugin", "security", "supply-chain"] [dependencies] -anyhow = "1.0.33" -clap = { version = "4.2.1", features = [ "derive" ] } -serde = { version = "1.0.136", features = [ "derive", "rc" ] } -toml = "0.8.0" -serde_json = "1.0.95" -cargo_metadata = "0.18.0" -object = "0.32.0" +anyhow = "1.0.102" +clap = { version = "4.6.1", features = [ "derive" ] } +serde = { version = "1.0.228", features = [ "derive", "rc" ] } +toml = "0.8.23" +serde_json = "1.0.149" +cargo_metadata = "0.18.1" +object = "0.32.2" ar = "0.9.0" -gimli = { version = "0.28.0", default-features = false, features = ["read"] } -rustc-demangle = "0.1.22" -once_cell = "1.17.1" -is-terminal = "0.4.8" -colored = "2.0.0" -rustc-ap-rustc_lexer = "727.0.0" -indoc = "2.0.1" -log = { version = "0.4.19", features = [ "std" ] } +gimli = { version = "0.28.1", default-features = false, features = ["read"] } +rustc-demangle = "0.1.27" +once_cell = "1.21.4" +is-terminal = "0.4.17" +colored = "2.2.0" +ra-ap-rustc_lexer = "0.162.0" +indoc = "2.0.7" +log = { version = "0.4.29", features = [ "std" ] } addr2line = { version = "0.21.0", default-features = false, features = [ "std" ] } -tempfile = "3.6.0" -fxhash = "0.2.1" +tempfile = "3.27.0" +rustc-hash = "2.1.2" tui-input = "0.8.0" -toml_edit = { version = "0.20.0" } +toml_edit = { version = "0.20.7" } ratatui = { version = "0.24.0", optional = true } diff = { version = "0.1.13", optional = true } diff --git a/cackle.toml b/cackle.toml index 31edf9f..cf7a3ad 100644 --- a/cackle.toml +++ b/cackle.toml @@ -185,9 +185,6 @@ allow_unsafe = true [pkg.clap_lex] allow_unsafe = true -[pkg.ryu] -allow_unsafe = true - [pkg.itoa] allow_unsafe = true @@ -267,6 +264,7 @@ test.sandbox.make_writable = [ "test_crates/custom_target_dir", ] test.sandbox.allow_network = true +test.allow_unsafe = true [pkg.clap_builder] allow_apis = [ @@ -326,9 +324,6 @@ allow_unsafe = true [pkg.getrandom] allow_unsafe = true -build.allow_apis = [ - "process", -] [pkg.serde_core] allow_unsafe = true @@ -346,3 +341,15 @@ build.allow_apis = [ [pkg.simd-adler32] allow_unsafe = true + +[pkg.wit-bindgen-rust-macro] +allow_proc_macro = true + +[pkg.zmij] +build.allow_apis = [ + "process", +] +allow_unsafe = true + +[pkg.errno] +allow_unsafe = true diff --git a/src/build_script_checker.rs b/src/build_script_checker.rs index 36d4a6e..3a26db6 100644 --- a/src/build_script_checker.rs +++ b/src/build_script_checker.rs @@ -1,5 +1,5 @@ -use crate::config::permissions::PermSel; use crate::config::Config; +use crate::config::permissions::PermSel; use crate::crate_index::PackageId; use crate::problem::DisallowedBuildInstruction; use crate::problem::Problem; @@ -41,10 +41,10 @@ impl BuildScriptReport { allow_build_instructions, )); } - if let Some(rest) = line.strip_prefix("cargo:rustc-env=") { - if let Some((var_name, _value)) = rest.split_once('=') { - report.env_vars.push(var_name.to_owned()); - } + if let Some(rest) = line.strip_prefix("cargo:rustc-env=") + && let Some((var_name, _value)) = rest.split_once('=') + { + report.env_vars.push(var_name.to_owned()); } } Ok(report) @@ -96,8 +96,8 @@ fn matches(instruction: &str, rule: &str) -> bool { mod tests { use crate::config; use crate::config::SandboxConfig; - use crate::crate_index::testing::pkg_id; use crate::crate_index::CrateSel; + use crate::crate_index::testing::pkg_id; use crate::problem::DisallowedBuildInstruction; use crate::problem::Problem; use crate::problem::ProblemList; diff --git a/src/checker.rs b/src/checker.rs index 73e78c1..a08ccd9 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -1,8 +1,10 @@ +use crate::Args; +use crate::CheckState; use crate::build_script_checker; -use crate::config::permissions::PermSel; -use crate::config::permissions::PermissionScope; use crate::config::ApiName; use crate::config::Config; +use crate::config::permissions::PermSel; +use crate::config::permissions::PermissionScope; use crate::crate_index::CrateIndex; use crate::crate_index::CrateKind; use crate::crate_index::PackageId; @@ -20,20 +22,18 @@ use crate::proxy::cargo::profile_name; use crate::proxy::rpc; use crate::proxy::rpc::UnsafeUsage; use crate::proxy::subprocess::SubprocessConfig; -use crate::symbol_graph::backtrace::Backtracer; use crate::symbol_graph::NameSource; use crate::symbol_graph::UsageDebugData; +use crate::symbol_graph::backtrace::Backtracer; use crate::timing::TimingCollector; use crate::tmpdir::TempDir; -use crate::Args; -use crate::CheckState; -use anyhow::anyhow; -use anyhow::bail; use anyhow::Context; use anyhow::Result; -use fxhash::FxHashMap; -use fxhash::FxHashSet; +use anyhow::anyhow; +use anyhow::bail; use log::info; +use rustc_hash::FxHashMap; +use rustc_hash::FxHashSet; use std::borrow::Cow; use std::path::Path; use std::path::PathBuf; @@ -413,12 +413,12 @@ impl Checker { ) -> Result<()> { let api = &api_usage.api_name; let perm_sel = api_usage.perm_sel(); - if let Some(crate_info) = self.crate_infos.get_mut(&perm_sel) { - if crate_info.allowed_apis.contains(api) { - crate_info.unused_allowed_apis.remove(api); - self.mark_parent_allow_apis_used(api, &perm_sel); - return Ok(()); - } + if let Some(crate_info) = self.crate_infos.get_mut(&perm_sel) + && crate_info.allowed_apis.contains(api) + { + crate_info.unused_allowed_apis.remove(api); + self.mark_parent_allow_apis_used(api, &perm_sel); + return Ok(()); } // Partition all usages into on-tree and off-tree usages. On-tree are those usages that are @@ -430,25 +430,24 @@ impl Checker { let all_deps = self.crate_index.name_prefix_to_pkg_id(); if let Some(crate_deps) = self.crate_index.transitive_deps(&api_usage.pkg_id) { for usage in &api_usage.usages { - if let Some(first_name_part) = usage.to_name.parts.first() { - if !crate_deps.contains(first_name_part) { - if let Some(pkg_id) = all_deps.get(first_name_part) { - // If we detect an off-tree usage where the outer function/variable is - // defined by crate that also defined the restricted API that's being - // accessed, then we ignore it completely. - // - // This can happen if for example a macro defines a variable that is - // then referenced by an inlined function. The macro and the inlined - // function can both be from leaf crates, while the code calling the - // macro is from a higher level crate that provides a restricted API. - // The end effect is that it looks like the inlined function is - // referencing the restricted API. - if !self.is_to_name_from_outer_location(usage)? { - off_tree.entry(pkg_id).or_default().push(usage.clone()); - } - continue; - } + if let Some(first_name_part) = usage.to_name.parts.first() + && !crate_deps.contains(first_name_part) + && let Some(pkg_id) = all_deps.get(first_name_part) + { + // If we detect an off-tree usage where the outer function/variable is + // defined by crate that also defined the restricted API that's being + // accessed, then we ignore it completely. + // + // This can happen if for example a macro defines a variable that is + // then referenced by an inlined function. The macro and the inlined + // function can both be from leaf crates, while the code calling the + // macro is from a higher level crate that provides a restricted API. + // The end effect is that it looks like the inlined function is + // referencing the restricted API. + if !self.is_to_name_from_outer_location(usage)? { + off_tree.entry(pkg_id).or_default().push(usage.clone()); } + continue; } on_tree.push(usage.clone()); } @@ -566,12 +565,11 @@ impl Checker { continue; } } - if let Some(api_config) = self.config.raw.apis.get(&p.api) { - if api_config.no_auto_detect.contains(&perm_sel.package_name) - || api_config.include.contains(&p.api_path()) - { - continue; - } + if let Some(api_config) = self.config.raw.apis.get(&p.api) + && (api_config.no_auto_detect.contains(&perm_sel.package_name) + || api_config.include.contains(&p.api_path())) + { + continue; } problems.push(Problem::PossibleExportedApi(p.clone())); } diff --git a/src/checker/api_map.rs b/src/checker/api_map.rs index 8a617f8..83130be 100644 --- a/src/checker/api_map.rs +++ b/src/checker/api_map.rs @@ -1,6 +1,6 @@ use crate::config::ApiName; -use fxhash::FxHashMap; -use fxhash::FxHashSet; +use rustc_hash::FxHashMap; +use rustc_hash::FxHashSet; /// A map from a path prefix to a set of APIs. Stored as a tree where each level of the tree does /// lookup for the next part of the name. e.g. `std::path::PathBuf` would be stored as a tree with 4 diff --git a/src/checker/common_prefix.rs b/src/checker/common_prefix.rs index e87ffa1..378295e 100644 --- a/src/checker/common_prefix.rs +++ b/src/checker/common_prefix.rs @@ -4,7 +4,7 @@ use crate::demangle::DemangleToken; use crate::names::NamesIterator; use crate::names::SymbolOrDebugName; use anyhow::Result; -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; /// Returns a list of name prefixes that are common to all of the from-names in the supplied API /// usages. These are candidates for names that are missing from an API when an off-tree usage is diff --git a/src/config.rs b/src/config.rs index b474c10..cd7280e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,10 +4,10 @@ use crate::crate_index::PackageId; use crate::problem::AvailableApi; use crate::problem::Problem; use crate::problem::ProblemList; -use anyhow::anyhow; -use anyhow::bail; use anyhow::Context; use anyhow::Result; +use anyhow::anyhow; +use anyhow::bail; use serde::Deserialize; use serde::Serialize; use std::collections::BTreeMap; @@ -465,8 +465,8 @@ pub(crate) mod testing { #[cfg(test)] mod tests { use super::testing::parse; - use crate::config::permissions::PermSel; use crate::config::SandboxKind; + use crate::config::permissions::PermSel; #[test] fn empty() { @@ -533,10 +533,12 @@ mod tests { "#, ) .unwrap(); - assert!(config - .permissions - .get(&PermSel::for_build_script("foo")) - .is_some()); + assert!( + config + .permissions + .get(&PermSel::for_build_script("foo")) + .is_some() + ); } #[test] diff --git a/src/config/permissions.rs b/src/config/permissions.rs index 231bf08..cebac77 100644 --- a/src/config/permissions.rs +++ b/src/config/permissions.rs @@ -7,7 +7,7 @@ use crate::crate_index::CrateKind; use crate::crate_index::CrateSel; use crate::crate_index::PackageId; use anyhow::Result; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use serde::Deserialize; use serde::Serialize; use std::fmt::Display; diff --git a/src/config_editor.rs b/src/config_editor.rs index d20330f..62b85fb 100644 --- a/src/config_editor.rs +++ b/src/config_editor.rs @@ -1,21 +1,21 @@ //! This module is responsible for applying automatic edits to cackle.toml. use crate::checker::common_prefix::common_to_prefixes; -use crate::config::permissions::PermSel; -use crate::config::versions::Version; use crate::config::ApiName; use crate::config::ApiPath; use crate::config::Config; use crate::config::PackageName; use crate::config::SandboxKind; +use crate::config::permissions::PermSel; +use crate::config::versions::Version; use crate::problem::ApiUsages; use crate::problem::AvailableApi; use crate::problem::PossibleExportedApi; use crate::problem::Problem; use crate::problem::ProblemList; use crate::problem::UnusedAllowApi; -use anyhow::anyhow; use anyhow::Result; +use anyhow::anyhow; use std::borrow::Borrow; use std::borrow::Cow; use std::fmt::Display; @@ -1118,10 +1118,10 @@ fn set_table_value( opts: &EditOpts, ) { table[key] = item; - if let Some(comment) = &opts.comment { - if let Some(decor) = table.key_decor_mut(key) { - *decor = toml_edit::Decor::new(format!("# {comment}\n"), " "); - } + if let Some(comment) = &opts.comment + && let Some(decor) = table.key_decor_mut(key) + { + *decor = toml_edit::Decor::new(format!("# {comment}\n"), " "); } } @@ -1130,15 +1130,15 @@ mod tests { use super::ConfigEditor; use super::Edit; use super::InlineStdApi; - use crate::config::permissions::PermSel; - use crate::config::permissions::PermissionScope; use crate::config::ApiName; use crate::config::Config; use crate::config::SandboxConfig; + use crate::config::permissions::PermSel; + use crate::config::permissions::PermissionScope; use crate::config_editor::fixes_for_problem; - use crate::crate_index::testing::pkg_id; use crate::crate_index::CrateSel; use crate::crate_index::PackageId; + use crate::crate_index::testing::pkg_id; use crate::location::SourceLocation; use crate::problem::ApiUsages; use crate::problem::DisallowedBuildInstruction; diff --git a/src/config_validation.rs b/src/config_validation.rs index 4078dc2..81268bc 100644 --- a/src/config_validation.rs +++ b/src/config_validation.rs @@ -1,7 +1,7 @@ use crate::config::ApiName; use crate::config::Config; use crate::config::MAX_VERSION; -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use std::fmt::Display; use std::path::Path; use std::path::PathBuf; diff --git a/src/crate_index.rs b/src/crate_index.rs index 151ec54..b3cf2bb 100644 --- a/src/crate_index.rs +++ b/src/crate_index.rs @@ -2,17 +2,17 @@ //! to which crates, which are proc macros etc. use self::lib_tree::LibTree; +use crate::config::PackageName; use crate::config::permissions::PermSel; use crate::config::permissions::PermissionScope; -use crate::config::PackageName; -use anyhow::bail; use anyhow::Context; use anyhow::Result; +use anyhow::bail; +use cargo_metadata::DependencyKind; use cargo_metadata::camino::Utf8PathBuf; use cargo_metadata::semver::Version; -use cargo_metadata::DependencyKind; -use fxhash::FxHashMap; -use fxhash::FxHashSet; +use rustc_hash::FxHashMap; +use rustc_hash::FxHashSet; use serde::Deserialize; use serde::Serialize; use std::borrow::Cow; @@ -380,7 +380,7 @@ pub(crate) mod testing { use super::PackageId; use super::PackageInfo; use cargo_metadata::semver::Version; - use fxhash::FxHashSet; + use rustc_hash::FxHashSet; use std::sync::Arc; pub(crate) fn pkg_id(name: &str) -> PackageId { diff --git a/src/crate_index/lib_tree.rs b/src/crate_index/lib_tree.rs index 9aedfb4..2ed979a 100644 --- a/src/crate_index/lib_tree.rs +++ b/src/crate_index/lib_tree.rs @@ -1,11 +1,11 @@ use super::PackageId; -use anyhow::anyhow; -use anyhow::bail; use anyhow::Context; use anyhow::Result; +use anyhow::anyhow; +use anyhow::bail; use cargo_metadata::semver::Version; -use fxhash::FxHashMap; -use fxhash::FxHashSet; +use rustc_hash::FxHashMap; +use rustc_hash::FxHashSet; use std::path::Path; use std::process::Command; use std::sync::Arc; diff --git a/src/demangle.rs b/src/demangle.rs index 5ea92c0..854db57 100644 --- a/src/demangle.rs +++ b/src/demangle.rs @@ -4,9 +4,9 @@ //! avoiding heap allocation. This demangler was built experimentally based on observed mangled //! symbols. We almost certainly get stuff wrong. +use anyhow::Result; use anyhow::anyhow; use anyhow::bail; -use anyhow::Result; use std::sync::Arc; #[derive(Debug, PartialEq, Eq)] @@ -119,13 +119,13 @@ fn parse_disambiguator(data: &str) -> Option<&str> { fn parse_undisambiguated_identifier(data: &str) -> Option<(&str, &str)> { // Check for punycode (u followed by decimal length) if let Some(rest) = data.strip_prefix('u') { - if let Some((len, rest)) = parse_decimal(rest) { - if let Some(rest) = rest.strip_prefix('_') { - // Punycode identifier - for simplicity, we'll just extract the raw bytes - if len as usize <= rest.len() { - let (ident, rest) = rest.split_at(len as usize); - return Some((ident, rest)); - } + if let Some((len, rest)) = parse_decimal(rest) + && let Some(rest) = rest.strip_prefix('_') + { + // Punycode identifier - for simplicity, we'll just extract the raw bytes + if len as usize <= rest.len() { + let (ident, rest) = rest.split_at(len as usize); + return Some((ident, rest)); } } return None; @@ -320,14 +320,14 @@ impl<'data> Iterator for DemangleIterator<'data> { while let Some(rest) = data.strip_prefix('.') { *data = rest; } - if let Some(rest) = data.strip_prefix('$') { - if let Some(end_escape) = rest.find('$') { - *data = &rest[end_escape + 1..]; - if let Ok(ch) = symbol(&rest[..end_escape]) { - return Some(DemangleToken::Char(ch)); - } - return Some(DemangleToken::UnsupportedEscape(&rest[..end_escape])); + if let Some(rest) = data.strip_prefix('$') + && let Some(end_escape) = rest.find('$') + { + *data = &rest[end_escape + 1..]; + if let Ok(ch) = symbol(&rest[..end_escape]) { + return Some(DemangleToken::Char(ch)); } + return Some(DemangleToken::UnsupportedEscape(&rest[..end_escape])); } let end = data .bytes() @@ -555,24 +555,80 @@ mod tests { #[test] fn test_nested() { - check("_ZN58_$LT$alloc..string..String$u20$as$u20$core..fmt..Debug$GT$3fmt17h3b29bd412ff2951fE", - &["<", "alloc", "string", "String", " ", "as", " ", "core", "fmt", "Debug", ">", "fmt", "h3b29bd412ff2951f"] + check( + "_ZN58_$LT$alloc..string..String$u20$as$u20$core..fmt..Debug$GT$3fmt17h3b29bd412ff2951fE", + &[ + "<", + "alloc", + "string", + "String", + " ", + "as", + " ", + "core", + "fmt", + "Debug", + ">", + "fmt", + "h3b29bd412ff2951f", + ], ); } #[test] fn test_generics() { - check("_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h0bb7e9fe967fc41cE", - &["core", "ptr", "drop_in_place", "<", "std", "rt", "lang_start", "<", "(", ")", ">", - "{", "{", "closure", "}", "}", ">", "h0bb7e9fe967fc41c"] + check( + "_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h0bb7e9fe967fc41cE", + &[ + "core", + "ptr", + "drop_in_place", + "<", + "std", + "rt", + "lang_start", + "<", + "(", + ")", + ">", + "{", + "{", + "closure", + "}", + "}", + ">", + "h0bb7e9fe967fc41c", + ], ); } #[test] fn test_literal_number() { - check("_ZN104_$LT$proc_macro2..Span$u20$as$u20$syn..span..IntoSpans$LT$$u5b$proc_macro2..Span$u3b$$u20$1$u5d$$GT$$GT$10into_spans17h8cc941d826bfc6f7E", - &["<", "proc_macro2", "Span", " ", "as", " ", "syn", "span", "IntoSpans", "<", - "[", "proc_macro2", "Span", ";", " ", "1", "]", ">", ">", "into_spans", "h8cc941d826bfc6f7"] + check( + "_ZN104_$LT$proc_macro2..Span$u20$as$u20$syn..span..IntoSpans$LT$$u5b$proc_macro2..Span$u3b$$u20$1$u5d$$GT$$GT$10into_spans17h8cc941d826bfc6f7E", + &[ + "<", + "proc_macro2", + "Span", + " ", + "as", + " ", + "syn", + "span", + "IntoSpans", + "<", + "[", + "proc_macro2", + "Span", + ";", + " ", + "1", + "]", + ">", + ">", + "into_spans", + "h8cc941d826bfc6f7", + ], ); } diff --git a/src/deps.rs b/src/deps.rs index 732d0ae..9e85ff2 100644 --- a/src/deps.rs +++ b/src/deps.rs @@ -1,9 +1,9 @@ //! Locates and parses depinfo emitted by the rust compiler. -use anyhow::anyhow; -use anyhow::bail; use anyhow::Context; use anyhow::Result; +use anyhow::anyhow; +use anyhow::bail; use std::path::Path; use std::path::PathBuf; @@ -125,28 +125,32 @@ mod tests { #[test] fn test_source_files_from_rustc_args_missing_crate_name() { - assert!(deps_path(&[ - "rustc", - "--emit=dep-info,link", - "-C", - "extra-filename=-0188200cb614ae3d", - "--out-dir", - "/some/directory/target/debug/deps", - ]) - .is_err()); + assert!( + deps_path(&[ + "rustc", + "--emit=dep-info,link", + "-C", + "extra-filename=-0188200cb614ae3d", + "--out-dir", + "/some/directory/target/debug/deps", + ]) + .is_err() + ); } #[test] fn test_source_files_from_rustc_args_missing_out_dir() { - assert!(deps_path(&[ - "rustc", - "--emit=dep-info,link", - "--crate-name", - "foo", - "-C", - "extra-filename=-0188200cb614ae3d", - ]) - .is_err()); + assert!( + deps_path(&[ + "rustc", + "--emit=dep-info,link", + "--crate-name", + "foo", + "-C", + "extra-filename=-0188200cb614ae3d", + ]) + .is_err() + ); } #[test] diff --git a/src/link_info.rs b/src/link_info.rs index 47c1b9b..81e370c 100644 --- a/src/link_info.rs +++ b/src/link_info.rs @@ -1,6 +1,6 @@ use crate::crate_index::CrateSel; -use anyhow::bail; use anyhow::Result; +use anyhow::bail; use serde::Deserialize; use serde::Serialize; use std::path::Path; @@ -50,10 +50,10 @@ impl LinkInfo { fn get_output_file() -> Result> { let mut args = std::env::args(); while let Some(arg) = args.next() { - if arg == "-o" { - if let Some(output) = args.next() { - return Ok(Arc::from(Path::new(&output))); - } + if arg == "-o" + && let Some(output) = args.next() + { + return Ok(Arc::from(Path::new(&output))); } } bail!("Failed to find output file in linker command line"); diff --git a/src/logging.rs b/src/logging.rs index 23c527f..740e2f1 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -1,6 +1,6 @@ -use anyhow::anyhow; use anyhow::Context; use anyhow::Result; +use anyhow::anyhow; use clap::ValueEnum; use std::io::Write; use std::path::Path; diff --git a/src/main.rs b/src/main.rs index eccdb49..fe67a66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,10 +37,10 @@ mod ui; mod unsafe_checker; use crate::proxy::subprocess::PROXY_BIN_ARG; -use anyhow::anyhow; -use anyhow::bail; use anyhow::Context; use anyhow::Result; +use anyhow::anyhow; +use anyhow::bail; use checker::Checker; use clap::Parser; use clap::Subcommand; @@ -51,16 +51,16 @@ use outcome::ExitCode; use outcome::Outcome; use problem::Problem; use problem_store::ProblemStoreRef; -use proxy::cargo::profile_name; +use proxy::CargoOutputWaiter; use proxy::cargo::CargoOptions; +use proxy::cargo::profile_name; use proxy::rpc::Request; -use proxy::CargoOutputWaiter; use std::path::Path; use std::path::PathBuf; -use std::sync::mpsc::Receiver; -use std::sync::mpsc::Sender; use std::sync::Arc; use std::sync::Mutex; +use std::sync::mpsc::Receiver; +use std::sync::mpsc::Sender; use std::thread::JoinHandle; use summary::SummaryOptions; use symbol_graph::ScanOutputs; @@ -409,10 +409,10 @@ impl Cackle { abort_recv, self.abort_sender.clone(), |request| { - if self.args.save_requests { - if let Err(error) = self.save_request(&request) { - println!("Failed to save request: {error}"); - } + if self.args.save_requests + && let Err(error) = self.save_request(&request) + { + println!("Failed to save request: {error}"); } self.new_request_handler(Some(request)) }, diff --git a/src/names.rs b/src/names.rs index 3930a1f..5464a7a 100644 --- a/src/names.rs +++ b/src/names.rs @@ -2,9 +2,9 @@ use crate::cowarc::Utf8Bytes; use crate::demangle::DemangleToken; use crate::demangle::NonMangledIterator; use crate::symbol::Symbol; +use anyhow::Result; use anyhow::anyhow; use anyhow::bail; -use anyhow::Result; use std::fmt::Debug; use std::fmt::Display; use std::sync::Arc; diff --git a/src/problem.rs b/src/problem.rs index 9554f80..f1b8e62 100644 --- a/src/problem.rs +++ b/src/problem.rs @@ -2,11 +2,11 @@ //! multiple problems and report them all, although in the case of errors, we usually stop. use crate::checker::ApiUsage; -use crate::config::permissions::PermSel; -use crate::config::permissions::PermissionScope; use crate::config::ApiConfig; use crate::config::ApiName; use crate::config::ApiPath; +use crate::config::permissions::PermSel; +use crate::config::permissions::PermissionScope; use crate::crate_index::CrateKind; use crate::crate_index::CrateSel; use crate::crate_index::PackageId; diff --git a/src/problem_store.rs b/src/problem_store.rs index 6e3f0a0..4184d0b 100644 --- a/src/problem_store.rs +++ b/src/problem_store.rs @@ -2,15 +2,15 @@ use crate::events::AppEvent; use crate::outcome::Outcome; use crate::problem::Problem; use crate::problem::ProblemList; -use fxhash::FxHashMap; -use fxhash::FxHashSet; use log::info; +use rustc_hash::FxHashMap; +use rustc_hash::FxHashSet; use std::collections::hash_map::Entry; -use std::sync::mpsc::Receiver; -use std::sync::mpsc::Sender; use std::sync::Arc; use std::sync::Mutex; use std::sync::MutexGuard; +use std::sync::mpsc::Receiver; +use std::sync::mpsc::Sender; pub(crate) fn create(event_sender: Sender) -> ProblemStoreRef { ProblemStoreRef { @@ -211,10 +211,10 @@ impl NotificationEntry { return; } self.problem_ids.extend(replacements.iter()); - if self.problem_ids.is_empty() { - if let Some(sender) = self.sender.take() { - let _ = sender.send(Outcome::Continue); - } + if self.problem_ids.is_empty() + && let Some(sender) = self.sender.take() + { + let _ = sender.send(Outcome::Continue); } } } @@ -248,8 +248,8 @@ mod tests { use crate::problem::Problem; use crate::problem::ProblemList; use crate::problem_store::ProblemId; - use std::sync::mpsc::channel; use std::sync::mpsc::TryRecvError; + use std::sync::mpsc::channel; fn create_problems() -> ProblemList { let mut problems = ProblemList::default(); diff --git a/src/proxy.rs b/src/proxy.rs index 5afe1e8..0ec7bd5 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -21,16 +21,16 @@ //! * We can capture their output and check for any directives to cargo that haven't been permitted. use self::rpc::Request; +use crate::Args; +use crate::RequestHandler; use crate::config::CommonConfig; use crate::config::Config; use crate::crate_index::CrateIndex; use crate::outcome::ExitCode; use crate::outcome::Outcome; -use crate::Args; -use crate::RequestHandler; -use anyhow::bail; use anyhow::Context; use anyhow::Result; +use anyhow::bail; use std::io::Write; use std::os::unix::net::UnixListener; use std::os::unix::net::UnixStream; @@ -38,9 +38,9 @@ use std::path::Path; use std::path::PathBuf; use std::process::Command; use std::process::Stdio; -use std::sync::mpsc::channel; use std::sync::mpsc::Receiver; use std::sync::mpsc::Sender; +use std::sync::mpsc::channel; use std::thread::JoinHandle; use std::time::Duration; diff --git a/src/proxy/cargo.rs b/src/proxy/cargo.rs index 8b33300..baac119 100644 --- a/src/proxy/cargo.rs +++ b/src/proxy/cargo.rs @@ -1,5 +1,5 @@ -use crate::config::CommonConfig; use crate::Args; +use crate::config::CommonConfig; use clap::Parser; use std::path::Path; use std::process::Command; diff --git a/src/proxy/errors.rs b/src/proxy/errors.rs index b32db24..3770c43 100644 --- a/src/proxy/errors.rs +++ b/src/proxy/errors.rs @@ -23,15 +23,16 @@ fn get_disallowed_unsafe_locations_str(output: &str) -> Vec { let Ok(message) = serde_json::from_str::(line) else { continue; }; - if message.level == "error" && message.code.code == "unsafe_code" { - if let Some(first_span) = message.spans.first() { - let filename = Path::new(&first_span.file_name); - locations.push(SourceLocation::new( - std::fs::canonicalize(filename).unwrap_or_else(|_| filename.to_owned()), - first_span.line_start, - Some(first_span.column_start), - )); - } + if message.level == "error" + && message.code.code == "unsafe_code" + && let Some(first_span) = message.spans.first() + { + let filename = Path::new(&first_span.file_name); + locations.push(SourceLocation::new( + std::fs::canonicalize(filename).unwrap_or_else(|_| filename.to_owned()), + first_span.line_start, + Some(first_span.column_start), + )); } } locations diff --git a/src/proxy/rpc.rs b/src/proxy/rpc.rs index 5515037..6489447 100644 --- a/src/proxy/rpc.rs +++ b/src/proxy/rpc.rs @@ -7,9 +7,9 @@ use crate::location::SourceLocation; use crate::outcome::Outcome; use anyhow::Context; use anyhow::Result; -use serde::de::DeserializeOwned; use serde::Deserialize; use serde::Serialize; +use serde::de::DeserializeOwned; use std::io::Read; use std::io::Write; use std::os::unix::net::UnixStream; diff --git a/src/proxy/subprocess.rs b/src/proxy/subprocess.rs index 7a93b4c..d9caa99 100644 --- a/src/proxy/subprocess.rs +++ b/src/proxy/subprocess.rs @@ -1,17 +1,17 @@ //! This module contains code that is intended for running in a subprocess when we're proxying //! rustc, the linker or a build script. See comment on parent module for more details. +use super::CONFIG_PATH_ENV; +use super::ExitCode; use super::cackle_exe; use super::errors::get_disallowed_unsafe_locations; use super::rpc::BinExecutionOutput; use super::rpc::RustcOutput; use super::run_command; -use super::ExitCode; -use super::CONFIG_PATH_ENV; -use crate::config::permissions::PermSel; -use crate::config::permissions::Permissions; use crate::config::Config; use crate::config::RustcConfig; +use crate::config::permissions::PermSel; +use crate::config::permissions::Permissions; use crate::crate_index::CrateKind; use crate::crate_index::CrateSel; use crate::link_info::LinkInfo; @@ -20,10 +20,10 @@ use crate::outcome::Outcome; use crate::proxy::rpc::RpcClient; use crate::sandbox::RustcSandboxInputs; use crate::unsafe_checker; -use anyhow::anyhow; -use anyhow::bail; use anyhow::Context; use anyhow::Result; +use anyhow::anyhow; +use anyhow::bail; use serde::Deserialize; use serde::Serialize; use std::ffi::OsString; diff --git a/src/sandbox.rs b/src/sandbox.rs index 822fbbd..1f35d7e 100644 --- a/src/sandbox.rs +++ b/src/sandbox.rs @@ -1,11 +1,11 @@ -use crate::config::permissions::PermSel; use crate::config::RustcConfig; use crate::config::SandboxConfig; use crate::config::SandboxKind; +use crate::config::permissions::PermSel; use crate::crate_index::CrateSel; -use anyhow::bail; use anyhow::Context; use anyhow::Result; +use anyhow::bail; use std::ffi::OsStr; use std::fmt::Display; use std::path::Path; @@ -159,10 +159,10 @@ impl RustcSandboxInputs { result.output_directories.push(rest.into()); } } - if let Ok(socket_path) = std::env::var(crate::proxy::SOCKET_ENV) { - if let Some(dir) = Path::new(&socket_path).parent() { - result.output_directories.push(dir.to_owned()); - } + if let Ok(socket_path) = std::env::var(crate::proxy::SOCKET_ENV) + && let Some(dir) = Path::new(&socket_path).parent() + { + result.output_directories.push(dir.to_owned()); } result .output_directories @@ -234,7 +234,9 @@ pub(crate) fn verify_kind(kind: SandboxKind) -> Result<()> { .output() .is_err() { - anyhow::bail!("Failed to run `bwrap`, perhaps it needs to be installed? On systems with apt you can `sudo apt install bubblewrap`"); + anyhow::bail!( + "Failed to run `bwrap`, perhaps it needs to be installed? On systems with apt you can `sudo apt install bubblewrap`" + ); } Ok(()) } @@ -282,10 +284,10 @@ fn get_env(var_name: &str) -> Result { fn build_directory(executable: &Path) -> Option<&Path> { let parent = executable.parent()?; - if parent.file_name().is_some_and(|n| n == "deps") { - if let Some(grandparent) = parent.parent() { - return Some(grandparent); - } + if parent.file_name().is_some_and(|n| n == "deps") + && let Some(grandparent) = parent.parent() + { + return Some(grandparent); } Some(parent) } diff --git a/src/summary.rs b/src/summary.rs index 2ce8cf2..9c85d34 100644 --- a/src/summary.rs +++ b/src/summary.rs @@ -1,9 +1,9 @@ -use crate::config::permissions::PermSel; use crate::config::Config; use crate::config::PackageConfig; +use crate::config::permissions::PermSel; use crate::crate_index::CrateIndex; use clap::{Parser, ValueEnum}; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use serde_json::Value; use std::collections::BTreeMap; use std::collections::HashMap; diff --git a/src/symbol_graph.rs b/src/symbol_graph.rs index acbbf43..ce55af9 100644 --- a/src/symbol_graph.rs +++ b/src/symbol_graph.rs @@ -11,9 +11,9 @@ use self::object_file_path::ObjectFilePath; use crate::checker::ApiUsage; use crate::checker::BinLocation; use crate::checker::Checker; -use crate::config::permissions::PermissionScope; use crate::config::ApiConfig; use crate::config::ApiName; +use crate::config::permissions::PermissionScope; use crate::crate_index::CrateSel; use crate::crate_index::PackageId; use crate::link_info::LinkInfo; @@ -26,13 +26,11 @@ use crate::problem::ApiUsages; use crate::problem::PossibleExportedApi; use crate::problem::ProblemList; use crate::symbol::Symbol; -use anyhow::anyhow; -use anyhow::bail; use anyhow::Context; use anyhow::Result; +use anyhow::anyhow; +use anyhow::bail; use ar::Archive; -use fxhash::FxHashMap; -use fxhash::FxHashSet; use gimli::Dwarf; use gimli::EndianSlice; use gimli::LittleEndian; @@ -43,6 +41,8 @@ use object::ObjectSection; use object::ObjectSymbol; use object::RelocationTarget; use object::SectionIndex; +use rustc_hash::FxHashMap; +use rustc_hash::FxHashSet; use std::borrow::Cow; use std::collections::BTreeMap; use std::fmt::Display; @@ -369,10 +369,10 @@ impl<'input> ApiUsageCollector<'input, '_> { }); } for target_symbol in target_symbols { - if let Some(target_address) = self.bin.symbol_addresses.get(&target_symbol) { - if let Some(b) = self.backtracer.as_mut() { - b.add_reference(bin_location, *target_address); - } + if let Some(target_address) = self.bin.symbol_addresses.get(&target_symbol) + && let Some(b) = self.backtracer.as_mut() + { + b.add_reference(bin_location, *target_address); } let target = self.bin.get_symbol_and_name(&target_symbol); self.process_reference( @@ -653,10 +653,10 @@ impl<'obj, 'data> ObjectIndex<'obj, 'data> { .section_infos .get(section_index.0) .ok_or_else(|| anyhow!("Unnamed symbol has invalid section index"))?; - if let Some(first_symbol_info) = section_info.first_symbol.as_ref() { - if bin_symbols.contains_key(&first_symbol_info.symbol) { - return Ok(SymbolOrSection::Symbol(first_symbol_info.symbol.clone())); - } + if let Some(first_symbol_info) = section_info.first_symbol.as_ref() + && bin_symbols.contains_key(&first_symbol_info.symbol) + { + return Ok(SymbolOrSection::Symbol(first_symbol_info.symbol.clone())); } Ok(SymbolOrSection::Section(section_index)) } @@ -752,30 +752,28 @@ impl BinInfo<'_> { } } } - if !got_apis { - if let Some(symbol) = symbol_and_name.symbol.as_ref() { - let mut symbol_it = symbol.names()?; - while let Some((parts, name)) = symbol_it.next_name()? { - let apis = checker.apis_for_name_iterator(parts); - if !apis.is_empty() { - got_apis = true; - (callback)( - name.create_name()?, - NameSource::Symbol(symbol.clone()), - apis, - )?; - } + if !got_apis && let Some(symbol) = symbol_and_name.symbol.as_ref() { + let mut symbol_it = symbol.names()?; + while let Some((parts, name)) = symbol_it.next_name()? { + let apis = checker.apis_for_name_iterator(parts); + if !apis.is_empty() { + got_apis = true; + (callback)( + name.create_name()?, + NameSource::Symbol(symbol.clone()), + apis, + )?; } } } - if let Some(symbol) = symbol_and_name.symbol.as_ref() { - if !got_apis { - // The need to call `to_heap` here is just to get past an annoying variance issue. - // Fortunately it doesn't seem to affect performance significantly, so probably the - // optimiser is able to get rid of the allocation. - if let Some(x) = self.symbol_has_no_apis.get_mut(&symbol.to_heap()) { - *x = true; - } + if let Some(symbol) = symbol_and_name.symbol.as_ref() + && !got_apis + { + // The need to call `to_heap` here is just to get past an annoying variance issue. + // Fortunately it doesn't seem to affect performance significantly, so probably the + // optimiser is able to get rid of the allocation. + if let Some(x) = self.symbol_has_no_apis.get_mut(&symbol.to_heap()) { + *x = true; } } Ok(()) diff --git a/src/symbol_graph/backtrace.rs b/src/symbol_graph/backtrace.rs index 9440c38..36345ea 100644 --- a/src/symbol_graph/backtrace.rs +++ b/src/symbol_graph/backtrace.rs @@ -2,9 +2,9 @@ use crate::checker::BinLocation; use crate::location::SourceLocation; use anyhow::Context; use anyhow::Result; -use fxhash::FxHashMap; -use fxhash::FxHashSet; use gimli::Dwarf; +use rustc_hash::FxHashMap; +use rustc_hash::FxHashSet; use std::fmt::Display; use std::path::Path; use std::sync::Arc; diff --git a/src/symbol_graph/dwarf.rs b/src/symbol_graph/dwarf.rs index c6f82d0..cd22508 100644 --- a/src/symbol_graph/dwarf.rs +++ b/src/symbol_graph/dwarf.rs @@ -5,11 +5,10 @@ use crate::names::DebugName; use crate::names::Namespace; use crate::names::SymbolAndName; use crate::symbol::Symbol; -use anyhow::anyhow; -use anyhow::bail; use anyhow::Context; use anyhow::Result; -use fxhash::FxHashMap; +use anyhow::anyhow; +use anyhow::bail; use gimli::Attribute; use gimli::AttributeValue; use gimli::Dwarf; @@ -17,6 +16,7 @@ use gimli::EndianSlice; use gimli::LittleEndian; use gimli::Unit; use gimli::UnitOffset; +use rustc_hash::FxHashMap; use std::ffi::OsStr; use std::os::unix::prelude::OsStrExt; use std::path::Path; @@ -148,12 +148,11 @@ impl<'input> DwarfScanner<'input> { { self.out.inlined_functions.push(inlined_function); } - if tag == gimli::DW_TAG_subprogram || tag == gimli::DW_TAG_variable { - if let Some((symbol, debug_info)) = + if (tag == gimli::DW_TAG_subprogram || tag == gimli::DW_TAG_variable) + && let Some((symbol, debug_info)) = symbol_scanner.get_debug_info(&unit_state)? - { - self.out.symbol_debug_info.insert(symbol, debug_info); - } + { + self.out.symbol_debug_info.insert(symbol, debug_info); } } else if tag == gimli::DW_TAG_namespace || tag == gimli::DW_TAG_structure_type { namespace = unit_state.scan_namespace(&mut entries, abbrev.attributes())?; @@ -231,10 +230,10 @@ fn get_subprogram_namespaces( } } _ => { - if abbrev.tag() == gimli::DW_TAG_subprogram { - if let Some(parent_namespace) = stack.last().and_then(|e| e.as_ref()) { - subprogram_namespaces.insert(unit_offset, parent_namespace.clone()); - } + if abbrev.tag() == gimli::DW_TAG_subprogram + && let Some(parent_namespace) = stack.last().and_then(|e| e.as_ref()) + { + subprogram_namespaces.insert(unit_offset, parent_namespace.clone()); } entries.skip_attributes(abbrev.attributes())?; } @@ -570,14 +569,12 @@ impl<'input> InlinedFunctionScanner<'input> { if let Some(ranges_offset) = unit_state .dwarf .attr_ranges_offset(unit_state.unit, attr.value())? - { - if let Some(first_range) = unit_state + && let Some(first_range) = unit_state .dwarf .ranges(unit_state.unit, ranges_offset)? .next()? - { - self.low_pc = Some(first_range.begin); - } + { + self.low_pc = Some(first_range.begin); } } _ => (), diff --git a/src/timing.rs b/src/timing.rs index e301055..5b57f1a 100644 --- a/src/timing.rs +++ b/src/timing.rs @@ -3,7 +3,7 @@ use std::fmt::Display; use std::time::Duration; use std::time::Instant; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; /// Records how long different parts of execution take. #[derive(Default)] diff --git a/src/ui.rs b/src/ui.rs index 8cd5704..8cb0227 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,19 +1,19 @@ //! User interface for showing problems to the user and asking them what they'd like to do about //! them. +use crate::Args; use crate::checker::Checker; use crate::crate_index::CrateIndex; use crate::events::AppEvent; use crate::problem_store::ProblemStoreRef; -use crate::Args; use anyhow::Result; use clap::ValueEnum; use log::info; use std::path::Path; -use std::sync::mpsc::Receiver; -use std::sync::mpsc::Sender; use std::sync::Arc; use std::sync::Mutex; +use std::sync::mpsc::Receiver; +use std::sync::mpsc::Sender; use std::thread::JoinHandle; #[cfg(feature = "ui")] diff --git a/src/ui/basic_term.rs b/src/ui/basic_term.rs index e7dff60..e6252eb 100644 --- a/src/ui/basic_term.rs +++ b/src/ui/basic_term.rs @@ -4,8 +4,8 @@ use crate::checker::Checker; use crate::config; use crate::config::ApiName; -use crate::config::SandboxKind; use crate::config::MAX_VERSION; +use crate::config::SandboxKind; use crate::config_editor; use crate::config_editor::ConfigEditor; use crate::config_editor::Edit; @@ -14,9 +14,9 @@ use crate::outcome::Outcome; use crate::problem::Problem; use crate::problem_store::ProblemStoreRef; use crate::sandbox; -use anyhow::bail; use anyhow::Context; use anyhow::Result; +use anyhow::bail; use colored::Colorize; use indoc::indoc; use std::collections::VecDeque; @@ -24,10 +24,10 @@ use std::io::BufRead; use std::io::Write; use std::path::Path; use std::path::PathBuf; -use std::sync::mpsc; -use std::sync::mpsc::Receiver; use std::sync::Arc; use std::sync::Mutex; +use std::sync::mpsc; +use std::sync::mpsc::Receiver; use std::time::Duration; use std::time::SystemTime; diff --git a/src/ui/full_term.rs b/src/ui/full_term.rs index dd136da..efaffd0 100644 --- a/src/ui/full_term.rs +++ b/src/ui/full_term.rs @@ -7,6 +7,7 @@ use crate::problem_store::ProblemStoreRef; use anyhow::Result; use crossterm::event::Event; use crossterm::event::KeyCode; +use ratatui::Frame; use ratatui::backend::CrosstermBackend; use ratatui::layout::Constraint; use ratatui::layout::Direction; @@ -24,14 +25,13 @@ use ratatui::widgets::ListItem; use ratatui::widgets::ListState; use ratatui::widgets::Paragraph; use ratatui::widgets::Wrap; -use ratatui::Frame; use std::io::Stdout; use std::path::PathBuf; +use std::sync::Arc; +use std::sync::Mutex; use std::sync::mpsc::Receiver; use std::sync::mpsc::Sender; use std::sync::mpsc::TryRecvError; -use std::sync::Arc; -use std::sync::Mutex; use std::time::Duration; mod problems_ui; diff --git a/src/ui/full_term/problems_ui.rs b/src/ui/full_term/problems_ui.rs index a0f3f4d..943d7f5 100644 --- a/src/ui/full_term/problems_ui.rs +++ b/src/ui/full_term/problems_ui.rs @@ -20,12 +20,13 @@ use crate::problem_store::ProblemId; use crate::problem_store::ProblemStore; use crate::problem_store::ProblemStoreRef; use crate::symbol_graph::backtrace; -use anyhow::anyhow; -use anyhow::bail; use anyhow::Context; use anyhow::Result; +use anyhow::anyhow; +use anyhow::bail; use crossterm::event::KeyCode; use crossterm::event::KeyEvent; +use ratatui::Frame; use ratatui::layout::Constraint; use ratatui::layout::Direction; use ratatui::layout::Layout; @@ -43,7 +44,6 @@ use ratatui::widgets::Paragraph; use ratatui::widgets::Row; use ratatui::widgets::Table; use ratatui::widgets::Wrap; -use ratatui::Frame; use std::path::Path; use std::path::PathBuf; use std::rc::Rc; @@ -393,11 +393,11 @@ impl ProblemsUi { usages_for_problem(pstore_lock, self.problem_index, &self.crate_index); for (usage_index, usage) in usages.iter().enumerate() { items.push(ListItem::new(format!(" {}", usage.list_display()))); - if let Some(frames) = backtrace_frames { - if usage_index == self.usage_index { - for bt_frame in frames { - items.push(ListItem::new(format!(" {bt_frame}"))); - } + if let Some(frames) = backtrace_frames + && usage_index == self.usage_index + { + for bt_frame in frames { + items.push(ListItem::new(format!(" {bt_frame}"))); } } } @@ -784,8 +784,8 @@ fn usage_source_lines( fn format_line(out: &mut Vec, column: Option, line: &str) { let mut offset = 0; let column_offset = column.map(|c| (c as usize).saturating_sub(1)); - for token in rustc_ap_rustc_lexer::tokenize(line) { - let new_offset = offset + token.len; + for token in ra_ap_rustc_lexer::tokenize(line, ra_ap_rustc_lexer::FrontmatterAllowed::No) { + let new_offset = offset + usize::try_from(token.len).unwrap(); let token_text = &line[offset..new_offset]; let mut style = Style::default(); if let Some(colour) = syntax_styling::colour_for_token_kind(token.kind, token_text) { @@ -869,13 +869,17 @@ fn render_help(f: &mut Frame, mode: Option<&Mode>) { } fn render_auto_accept(f: &mut Frame) { - render_message(f, None, &[ - "Auto-accept edits for all problems that only have a single edit?", - "", - "It's recommended that you look over the resulting cackle.toml afterwards to see if there are any crates with permissions that you don't think they should have.", - "", - "Press enter to accept, or escape to cancel.", - ]); + render_message( + f, + None, + &[ + "Auto-accept edits for all problems that only have a single edit?", + "", + "It's recommended that you look over the resulting cackle.toml afterwards to see if there are any crates with permissions that you don't think they should have.", + "", + "Press enter to accept, or escape to cancel.", + ], + ); } fn render_message>(f: &mut Frame, title: Option<&str>, raw_lines: &[S]) { diff --git a/src/ui/full_term/problems_ui/syntax_styling.rs b/src/ui/full_term/problems_ui/syntax_styling.rs index 08199b0..46fb63f 100644 --- a/src/ui/full_term/problems_ui/syntax_styling.rs +++ b/src/ui/full_term/problems_ui/syntax_styling.rs @@ -1,6 +1,6 @@ +use ra_ap_rustc_lexer::LiteralKind; +use ra_ap_rustc_lexer::TokenKind; use ratatui::style::Color; -use rustc_ap_rustc_lexer::LiteralKind; -use rustc_ap_rustc_lexer::TokenKind; pub(super) fn colour_for_token_kind(kind: TokenKind, token_text: &str) -> Option { match kind { diff --git a/src/ui/null_ui.rs b/src/ui/null_ui.rs index 18aa397..1bc9f2a 100644 --- a/src/ui/null_ui.rs +++ b/src/ui/null_ui.rs @@ -1,5 +1,6 @@ //! A user-interface that never prompts. This is used when non-interactive mode is selected. +use crate::Args; use crate::checker::Checker; use crate::config::Config; use crate::config_editor; @@ -10,15 +11,14 @@ use crate::problem::Severity; use crate::problem_store::ProblemId; use crate::problem_store::ProblemStore; use crate::problem_store::ProblemStoreRef; -use crate::Args; use anyhow::Result; use colored::Colorize; use std::path::PathBuf; -use std::sync::mpsc::Receiver; -use std::sync::mpsc::Sender; use std::sync::Arc; use std::sync::Mutex; use std::sync::MutexGuard; +use std::sync::mpsc::Receiver; +use std::sync::mpsc::Sender; pub(crate) struct NullUi { args: Arc, diff --git a/src/unsafe_checker.rs b/src/unsafe_checker.rs index 14ffcf2..e94eba2 100644 --- a/src/unsafe_checker.rs +++ b/src/unsafe_checker.rs @@ -22,8 +22,8 @@ pub(crate) fn scan_path(path: &Path) -> Result> { fn scan_string(source: &str, path: &Path) -> Vec { let mut offset = 0; let mut locations = Vec::new(); - for token in rustc_ap_rustc_lexer::tokenize(source) { - let new_offset = offset + token.len; + for token in ra_ap_rustc_lexer::tokenize(source, ra_ap_rustc_lexer::FrontmatterAllowed::No) { + let new_offset = offset + usize::try_from(token.len).unwrap(); let token_text = &source[offset..new_offset]; if token_text == "unsafe" { let column = source[..new_offset] diff --git a/test_crates/crab-2/build.rs b/test_crates/crab-2/build.rs index 0bffe22..23efdd7 100644 --- a/test_crates/crab-2/build.rs +++ b/test_crates/crab-2/build.rs @@ -8,6 +8,7 @@ fn main() { run(Command::new("cc") .arg("-c") .arg(base_dir.join("nothing.c")) + .arg("-fPIC") .arg("-o") .arg(&object_file)); run(Command::new("ar") diff --git a/test_crates/pmacro-1/src/lib.rs b/test_crates/pmacro-1/src/lib.rs index e000e52..3cabc04 100644 --- a/test_crates/pmacro-1/src/lib.rs +++ b/test_crates/pmacro-1/src/lib.rs @@ -18,7 +18,7 @@ pub fn create_write_to_file(_item: TokenStream) -> TokenStream { .unwrap() } -#[proc_macro_derive(FooBar, attributes(marker))] +#[proc_macro_derive(FooBar)] pub fn derive_foo_bar(_item: TokenStream) -> TokenStream { "impl FooBar for Foo { fn foo_bar() -> u32 { 42 } }" .parse() diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 61728d4..a15fb7c 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -7,8 +7,19 @@ use tempfile::TempDir; #[test] fn integration_test() -> Result<()> { - fn run_with_args(tmpdir: &TempDir, args: &[&str], expect_failure: bool) -> Result { + fn run_with_args( + tmpdir: &TempDir, + args: &[&str], + expect_failure: bool, + env_key: Option<&'static str>, + env_val: Option<&'static str>, + ) -> Result { let mut command = Command::new(cackle_exe()); + if let Some(key) = env_key + && let Some(val) = env_val + { + command.env(key, val); + } // Remove cargo and rust-related environment variables. In particular we want to remove // variables that cargo sets, but which won't always be set. For example CARGO_PKG_NAME is // set by cargo when it invokes rustc, but only when it's compiling a package, not when it @@ -66,18 +77,24 @@ fn integration_test() -> Result<()> { let tmpdir = TempDir::new()?; - run_with_args(&tmpdir, &[], false)?; + run_with_args(&tmpdir, &[], false, None, None)?; // Trigger crab-2 to rebuild its test, but not rerun its build script. This ensures that // variables set by the build script survive between runs even if the build script doesn't // rerun. - std::env::set_var("CRAB_2_EXT_ENV", "1"); - - run_with_args(&tmpdir, &["test", "-v"], false)?; + run_with_args( + &tmpdir, + &["test", "-v"], + false, + Some("CRAB_2_EXT_ENV"), + Some("1"), + )?; let out = run_with_args( &tmpdir, &["run", "--bin", "c2-bin", "--", "40", "4", "-2"], false, + None, + None, )?; let out = out.trim(); let n: i32 = match out.parse() { @@ -86,7 +103,6 @@ fn integration_test() -> Result<()> { }; assert_eq!(n, 42); - std::env::set_var("CRAB_9_CRASH_TEST", "1"); let out = run_with_args( &tmpdir, &[ @@ -98,6 +114,8 @@ fn integration_test() -> Result<()> { "conditional_crash", ], true, + Some("CRAB_9_CRASH_TEST"), + Some("1"), )?; if !out.contains("Deliberate crash") { panic!("Test failed, but didn't contain expected message. Output was:\n{out}");