diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 6fad6f4..a34dd8f 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -6,7 +6,7 @@ concurrency: cancel-in-progress: true env: - toolchain: nightly-2024-02-22 + toolchain: nightly-2024-07-25 jobs: fmt: @@ -35,7 +35,7 @@ jobs: - name: Install dylint run: | if ! command -v cargo-dylint &> /dev/null || ! command -v dylint-link &> /dev/null; then - cargo +stable install cargo-dylint@3.0.0 dylint-link@3.0.0 + cargo install cargo-dylint dylint-link fi - name: cargo fmt --check @@ -71,7 +71,7 @@ jobs: - name: Install dylint run: | if ! command -v cargo-dylint &> /dev/null || ! command -v dylint-link &> /dev/null; then - cargo +stable install cargo-dylint@3.0.0 dylint-link@3.0.0 + cargo install cargo-dylint dylint-link fi - name: cargo clippy @@ -103,7 +103,7 @@ jobs: - name: Install dylint run: | if ! command -v cargo-dylint &> /dev/null || ! command -v dylint-link &> /dev/null; then - cargo +stable install cargo-dylint@3.0.0 dylint-link@3.0.0 + cargo install cargo-dylint dylint-link fi - name: cargo test diff --git a/Cargo.lock b/Cargo.lock index d8c997d..57ad9e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,21 +71,21 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bitflags" @@ -95,9 +95,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block-buffer" @@ -110,9 +110,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", "serde", @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.6" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" dependencies = [ "serde", ] @@ -152,12 +152,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.90" +version = "1.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "50d2eb3cd3d1bf4529e31c215ee6f93ec5a3d536d9f578f93d9d33ee19562932" dependencies = [ "jobserver", "libc", + "shlex", ] [[package]] @@ -168,8 +169,8 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clippy_config" -version = "0.1.78" -source = "git+https://github.com/rust-lang/rust-clippy?rev=aa2c94e416d346341fe3a875160a7d064596f4d3#aa2c94e416d346341fe3a875160a7d064596f4d3" +version = "0.1.82" +source = "git+https://github.com/rust-lang/rust-clippy?rev=37f4fbb92913586b73a35772efd00eccd1cbbe13#37f4fbb92913586b73a35772efd00eccd1cbbe13" dependencies = [ "rustc-semver", "serde", @@ -178,13 +179,14 @@ dependencies = [ [[package]] name = "clippy_utils" -version = "0.1.78" -source = "git+https://github.com/rust-lang/rust-clippy?rev=aa2c94e416d346341fe3a875160a7d064596f4d3#aa2c94e416d346341fe3a875160a7d064596f4d3" +version = "0.1.82" +source = "git+https://github.com/rust-lang/rust-clippy?rev=37f4fbb92913586b73a35772efd00eccd1cbbe13#37f4fbb92913586b73a35772efd00eccd1cbbe13" dependencies = [ "arrayvec", "clippy_config", "itertools", "rustc-semver", + "rustc_apfloat", ] [[package]] @@ -217,9 +219,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" dependencies = [ "libc", ] @@ -245,9 +247,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crypto-common" @@ -346,7 +348,7 @@ checksum = "9c0765e595bad79b47a2be4abfa4813a7ac082b2df0f6e863a0422dc9090c7c3" dependencies = [ "ansi_term", "anyhow", - "bitflags 2.5.0", + "bitflags 2.6.0", "cargo_metadata", "git2", "home", @@ -358,7 +360,7 @@ dependencies = [ "rust-embed", "serde", "thiserror", - "toml 0.8.12", + "toml 0.8.19", ] [[package]] @@ -373,7 +375,7 @@ dependencies = [ "rustversion", "serde", "thiserror", - "toml 0.8.12", + "toml 0.8.19", ] [[package]] @@ -396,9 +398,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "env_filter" @@ -431,9 +433,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -441,20 +443,20 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.2" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "filetime" -version = "0.2.23" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550" dependencies = [ "cfg-if", "libc", - "redox_syscall", - "windows-sys 0.52.0", + "libredox", + "windows-sys 0.59.0", ] [[package]] @@ -606,9 +608,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -621,7 +623,7 @@ version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "232e6a7bfe35766bf715e55a88b39a700596c0ccfd88cd3680b4cdb40d66ef70" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", "libgit2-sys", "log", @@ -645,9 +647,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hermit-abi" @@ -655,6 +657,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "home" version = "0.5.9" @@ -688,9 +696,9 @@ checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown", @@ -698,11 +706,11 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" dependencies = [ - "hermit-abi", + "hermit-abi 0.4.0", "libc", "windows-sys 0.52.0", ] @@ -724,30 +732,30 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.28" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libgit2-sys" @@ -765,11 +773,11 @@ dependencies = [ [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", "redox_syscall", ] @@ -790,9 +798,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.16" +version = "1.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e143b5e666b2695d28f6bca6497720813f699c9602dd7f5cac91008b8ada7f9" +checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" dependencies = [ "cc", "libc", @@ -802,15 +810,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "map" @@ -824,7 +832,7 @@ dependencies = [ [[package]] name = "mate" -version = "0.1.5" +version = "0.1.6" dependencies = [ "dylint_linting", "dylint_testing", @@ -840,9 +848,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miow" @@ -859,7 +867,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] @@ -877,9 +885,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" dependencies = [ "cc", "libc", @@ -918,9 +926,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "percent-encoding" @@ -930,9 +938,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -948,18 +956,18 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -997,18 +1005,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", ] [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", @@ -1017,9 +1025,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -1029,9 +1037,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -1040,9 +1048,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rust-embed" @@ -1085,6 +1093,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5be1bdc7edf596692617627bbfeaba522131b18e06ca4df2b6b689e3c5d5ce84" +[[package]] +name = "rustc_apfloat" +version = "0.2.1+llvm-462a31f5a5ab" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "886d94c63c812a8037c4faca2607453a0fa4cf82f734665266876b022244543f" +dependencies = [ + "bitflags 1.3.2", + "smallvec", +] + [[package]] name = "rustfix" version = "0.6.1" @@ -1099,11 +1117,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -1112,15 +1130,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -1133,27 +1151,27 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.197" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1162,20 +1180,21 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -1191,6 +1210,12 @@ dependencies = [ "digest", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "slab" version = "0.4.9" @@ -1200,11 +1225,17 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "syn" -version = "2.0.55" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -1213,14 +1244,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1249,18 +1281,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", @@ -1269,9 +1301,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -1306,21 +1338,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.12" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.9", + "toml_edit 0.22.20", ] [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] @@ -1340,15 +1372,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.9" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.5", + "winnow 0.6.18", ] [[package]] @@ -1380,15 +1412,15 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -1416,9 +1448,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" @@ -1454,11 +1486,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -1482,7 +1514,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -1502,17 +1543,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 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]] @@ -1523,9 +1565,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -1535,9 +1577,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -1547,9 +1589,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -1559,9 +1607,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -1571,9 +1619,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -1583,9 +1631,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -1595,9 +1643,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -1610,9 +1658,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.5" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 86e1277..09312fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "mate" -version = "0.1.5" +version = "0.1.6" authors = [ - "Cameron Low ", "Luca Carlig ", ] description = "library of lints for automatic parallelization" edition = "2021" @@ -45,9 +45,13 @@ members = [ dylint_testing = "3.1.2" [workspace.dependencies] -clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "aa2c94e416d346341fe3a875160a7d064596f4d3" } +clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "37f4fbb92913586b73a35772efd00eccd1cbbe13" } utils = { path = "utils" } +[workspace.lints.rust.unexpected_cfgs] +level = "deny" +check-cfg = ["cfg(dylint_lib, values(any()))"] + [workspace.metadata.dylint] clibraries = [{ path = "../mate" }] diff --git a/README.md b/README.md index 611817a..50e9f8f 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ prerequisites: - rustup - latest version of rust stable if not run `rustup updat 1. Install `cargo-dylint` and `dylint-link`: ```sh - cargo +stable install cargo-dylint@3.0.0 dylint-link@3.0.0 + cargo install cargo-dylint dylint-link ``` 2. Add the following to the workspace's `Cargo.toml` file: diff --git a/lints/filter/src/simple.rs b/lints/filter/src/simple.rs index d37b7ae..924e2af 100644 --- a/lints/filter/src/simple.rs +++ b/lints/filter/src/simple.rs @@ -81,19 +81,15 @@ impl<'tcx> LateLintPass<'tcx> for FilterSimple { let cond_snip = span_to_snippet_macro(src_map, cond.span); let suggestion = format!("filter(|{pat_snip}| {{ {local_defs_snip} {cond_snip} }}).for_each(|{pat_snip}| {{ {local_defs_snip} {then_snip} }})"); - cx.span_lint( - FILTER_SIMPLE, - *span, - "implicit filter inside `for_each`", - |diag| { - diag.span_suggestion( - *span, - "try lifting the filter iterator", - suggestion, - Applicability::MachineApplicable, - ); - }, - ); + cx.span_lint(FILTER_SIMPLE, *span, |diag| { + diag.primary_message("implicit filter inside `for_each`"); + diag.span_suggestion( + *span, + "try lifting the filter iterator", + suggestion, + Applicability::MachineApplicable, + ); + }); } } } diff --git a/lints/filter/src/simple_flipped.rs b/lints/filter/src/simple_flipped.rs index 0ee80db..e48edca 100644 --- a/lints/filter/src/simple_flipped.rs +++ b/lints/filter/src/simple_flipped.rs @@ -95,19 +95,15 @@ impl<'tcx> LateLintPass<'tcx> for FilterSimpleFlipped { let cond_snip = span_to_snippet_macro(src_map, cond.span); let suggestion = format!("filter(|{pat_snip}| {{ {local_defs_snip} !({cond_snip}) }}).for_each(|{pat_snip}| {{ {local_defs_snip} {then_snip} {body_snip} }})"); - cx.span_lint( - FILTER_SIMPLE_FLIPPED, - *span, - "implicit filter inside `for_each`", - |diag| { - diag.span_suggestion( - *span, - "try lifting the filter iterator", - suggestion, - Applicability::MachineApplicable, - ); - }, - ); + cx.span_lint(FILTER_SIMPLE_FLIPPED, *span, |diag| { + diag.primary_message("implicit filter inside `for_each`"); + diag.span_suggestion( + *span, + "try lifting the filter iterator", + suggestion, + Applicability::MachineApplicable, + ); + }); } } } diff --git a/lints/fold/src/simple.rs b/lints/fold/src/simple.rs index 16c35f1..596ee04 100644 --- a/lints/fold/src/simple.rs +++ b/lints/fold/src/simple.rs @@ -104,7 +104,8 @@ impl<'tcx> LateLintPass<'tcx> for FoldSimple { let lhs_snip = span_to_snippet_macro(src_map, lhs.span); let suggestion = format!("{lhs_snip} {op_snip} {recv_snip}.map(|{pat_snip}| {{{local_defs_snip} {rhs_snip}}}).fold({id_snip}, |mut {lhs_snip}, v| {{ {lhs_snip} {op_snip} v; {lhs_snip} }})"); - cx.span_lint(FOLD_SIMPLE, expr.span, "implicit fold", |diag| { + cx.span_lint(FOLD_SIMPLE, expr.span, |diag| { + diag.primary_message("implicit fold"); diag.span_suggestion( expr.span, "try using `fold` instead", diff --git a/lints/for_each/src/lib.rs b/lints/for_each/src/lib.rs index 5614969..7f22188 100644 --- a/lints/for_each/src/lib.rs +++ b/lints/for_each/src/lib.rs @@ -1,12 +1,12 @@ #![feature(rustc_private)] #![warn(unused_extern_crates)] #![feature(let_chains)] +#![feature(unwrap_infallible)] extern crate rustc_errors; extern crate rustc_hash; extern crate rustc_hir; extern crate rustc_hir_typeck; -extern crate rustc_infer; extern crate rustc_middle; mod variable_check; @@ -77,21 +77,17 @@ impl<'tcx> LateLintPass<'tcx> for ForEach { if validator.has_continue { body_snip = body_snip.replace("continue", "return"); } - cx.span_lint( - FOR_EACH, - expr.span, - "use a for_each to enable iterator refinement", - |diag| { - diag.multipart_suggestion( - "try using `for_each` on the iterator", - vec![( - expr.span, - format!("({iter_snip}){mc_snip}.for_each(|{pat_snip}| {body_snip});"), - )], - Applicability::MachineApplicable, - ); - }, - ); + cx.span_lint(FOR_EACH, expr.span, |diag| { + diag.primary_message("use a for_each to enable iterator refinement"); + diag.multipart_suggestion( + "try using `for_each` on the iterator", + vec![( + expr.span, + format!("({iter_snip}){mc_snip}.for_each(|{pat_snip}| {body_snip});"), + )], + Applicability::MachineApplicable, + ); + }); } } } diff --git a/lints/for_each/src/variable_check.rs b/lints/for_each/src/variable_check.rs index 22b3a9c..955f25e 100644 --- a/lints/for_each/src/variable_check.rs +++ b/lints/for_each/src/variable_check.rs @@ -1,11 +1,9 @@ -use clippy_utils::visitors::for_each_expr_with_closures; +use clippy_utils::visitors::for_each_expr; use rustc_hash::FxHashSet; -use rustc_hir as hir; -use rustc_hir_typeck::expr_use_visitor as euv; -use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; +use rustc_hir::{self as hir, def_id::LocalDefId}; +use rustc_hir_typeck::expr_use_visitor::{self as euv}; use rustc_lint::LateContext; use rustc_middle::{ - hir::map::associated_body, mir::FakeReadCause, ty::{self, Ty, UpvarId, UpvarPath}, }; @@ -37,28 +35,22 @@ pub fn check_variables<'tcx>(cx: &LateContext<'tcx>, ex: &'tcx hir::Expr) -> boo prev_bind: None, prev_move_to_closure: hir::HirIdSet::default(), }; - let infcx = cx.tcx.infer_ctxt().build(); - euv::ExprUseVisitor::new( - &mut ctx, - &infcx, - body_owner, - cx.param_env, - cx.typeck_results(), - ) - .walk_expr(ex); + euv::ExprUseVisitor::for_clippy(cx, body_owner, &mut ctx) + .walk_expr(ex) + .into_ok(); let mut checked_closures = FxHashSet::default(); // We retrieve all the closures declared in the function because they will not be found // by `euv::Delegate`. - let mut closures: FxHashSet = FxHashSet::default(); - for_each_expr_with_closures(cx, ex, |expr| { + let mut closures: FxHashSet = FxHashSet::default(); + for_each_expr(cx, ex, |expr| { if let hir::ExprKind::Closure(closure) = expr.kind { closures.insert(closure.def_id); } ControlFlow::<()>::Continue(()) }); - check_closures(&mut ctx, cx, &infcx, &mut checked_closures, closures); + check_closures(&mut ctx, cx, &mut checked_closures, closures); ctx }; @@ -69,7 +61,6 @@ pub fn check_variables<'tcx>(cx: &LateContext<'tcx>, ex: &'tcx hir::Expr) -> boo pub fn check_closures<'tcx, S: ::std::hash::BuildHasher>( ctx: &mut MutablyUsedVariablesCtxt<'tcx>, cx: &LateContext<'tcx>, - infcx: &InferCtxt<'tcx>, checked_closures: &mut HashSet, closures: HashSet, ) { @@ -82,12 +73,13 @@ pub fn check_closures<'tcx, S: ::std::hash::BuildHasher>( ctx.prev_move_to_closure.clear(); if let Some(body) = cx .tcx - .opt_hir_node_by_def_id(closure) - .and_then(associated_body) + .hir_node_by_def_id(closure) + .associated_body() .map(|(_, body_id)| hir.body(body_id)) { - euv::ExprUseVisitor::new(ctx, infcx, closure, cx.param_env, cx.typeck_results()) - .consume_body(body); + euv::ExprUseVisitor::for_clippy(cx, closure, &mut *ctx) + .consume_body(body) + .into_ok(); } } } diff --git a/lints/map/src/builder.rs b/lints/map/src/builder.rs index dbd60ae..8f9612a 100644 --- a/lints/map/src/builder.rs +++ b/lints/map/src/builder.rs @@ -113,7 +113,8 @@ impl<'tcx> LateLintPass<'tcx> for $struct_name { let suggestion = format!("{coll}.extend({recv}.map(|{pat}| {{ {local_defs} {args} }}).collect::<{}<{type_args}>>())", $type_name); - cx.span_lint($lint_name, expr.span, "implicit map", |diag| { + cx.span_lint($lint_name, expr.span, |diag| { + diag.primary_message("implicit map"); diag.span_suggestion( expr.span, "try using `map` instead", diff --git a/lints/par_fold/src/par_fold_simple.rs b/lints/par_fold/src/par_fold_simple.rs index 6521146..d9fd855 100644 --- a/lints/par_fold/src/par_fold_simple.rs +++ b/lints/par_fold/src/par_fold_simple.rs @@ -56,7 +56,8 @@ impl<'tcx> LateLintPass<'tcx> for ParFoldSimple { ir.suggestions .extend_from_slice(&[(path.ident.span, suggestion), (id_expr.span, suggestion2)]); - cx.span_lint(WARN_PAR_FOLD_SIMPLE, expr.span, "sequential fold", |diag| { + cx.span_lint(WARN_PAR_FOLD_SIMPLE, expr.span, |diag| { + diag.primary_message("sequential fold"); diag.multipart_suggestion( "try using a parallel fold on the iterator", ir.suggestions, diff --git a/lints/par_iter/src/lib.rs b/lints/par_iter/src/lib.rs index 48cebd8..a533c10 100644 --- a/lints/par_iter/src/lib.rs +++ b/lints/par_iter/src/lib.rs @@ -1,6 +1,7 @@ #![feature(rustc_private)] #![warn(unused_extern_crates)] #![feature(let_chains)] +#![feature(unwrap_infallible)] extern crate rustc_data_structures; extern crate rustc_errors; @@ -20,7 +21,6 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_expr, Visitor}; use rustc_hir::{self as hir}; -use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::{Obligation, ObligationCause}; use rustc_lint::{LateContext, LateLintPass, LintContext}; @@ -117,18 +117,14 @@ impl<'tcx> LateLintPass<'tcx> for ParIter { return; } - cx.span_lint( - PAR_ITER, - expr.span, - "found iterator that can be parallelized", - |diag| { - diag.multipart_suggestion( - "try using a parallel iterator", - vec![(expr.span, suggestion)], - Applicability::MachineApplicable, - ); - }, - ); + cx.span_lint(PAR_ITER, expr.span, |diag| { + diag.primary_message("found iterator that can be parallelized"); + diag.multipart_suggestion( + "try using a parallel iterator", + vec![(expr.span, suggestion)], + Applicability::MachineApplicable, + ); + }); } } } @@ -176,8 +172,8 @@ fn get_all_methods<'tcx>( ) -> Vec<&'tcx str> { let mut res = Vec::new(); if let (Some(parallel_iterator_def_id), Some(parallel_indexed_iterator_def_id)) = ( - get_trait_def_id(cx, &["rayon", "iter", "ParallelIterator"]), - get_trait_def_id(cx, &["rayon", "iter", "IndexedParallelIterator"]), + get_trait_def_id(cx.tcx, &["rayon", "iter", "ParallelIterator"]), + get_trait_def_id(cx.tcx, &["rayon", "iter", "IndexedParallelIterator"]), ) { let tcx = cx.tcx; let infcx = tcx.infer_ctxt().build(); @@ -185,14 +181,11 @@ fn get_all_methods<'tcx>( let param_env = tcx.param_env(into_iter_trait); // Create a new inference variable, ?new - let ty = infcx.next_ty_var(TypeVariableOrigin { - kind: TypeVariableOriginKind::TypeInference, - span: original_expr.span, - }); + let ty = infcx.next_ty_var(original_expr.span); let projection = ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::Projection( ty::ProjectionPredicate { - projection_ty: ty::AliasTy::new(tcx, into_iter_trait, GenericArgs::empty()), + projection_term: ty::AliasTerm::new(tcx, into_iter_trait, GenericArgs::empty()), term: ty.into(), }, ))); diff --git a/lints/par_iter/src/variable_check.rs b/lints/par_iter/src/variable_check.rs index 17c41d0..70d6093 100644 --- a/lints/par_iter/src/variable_check.rs +++ b/lints/par_iter/src/variable_check.rs @@ -1,17 +1,18 @@ -use clippy_utils::{get_trait_def_id, ty::implements_trait, visitors::for_each_expr_with_closures}; +use clippy_utils::{get_trait_def_id, ty::implements_trait, visitors::for_each_expr}; + use rustc_hash::FxHashSet; use rustc_hir as hir; use rustc_hir_typeck::expr_use_visitor as euv; -use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; +use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::{LateContext, LintContext}; use rustc_middle::{ - hir::map::associated_body, mir::FakeReadCause, ty::{self, Ty, TyCtxt, UpvarId, UpvarPath}, }; -use rustc_span::{sym, Symbol}; +use rustc_span::{def_id::LocalDefId, sym, Symbol}; use rustc_trait_selection::infer::InferCtxtExt; -use std::ops::ControlFlow; + +use core::ops::ControlFlow; use crate::constants::TRAIT_PATHS; @@ -33,7 +34,7 @@ pub(crate) struct MutablyUsedVariablesCtxt<'tcx> { pub(crate) fn check_variables<'tcx>( cx: &LateContext<'tcx>, body_owner: hir::def_id::LocalDefId, - body: &hir::Body<'tcx>, + body: &'tcx hir::Body<'_>, params: &hir::HirIdSet, is_mut: bool, ) -> bool { @@ -53,28 +54,23 @@ pub(crate) fn check_variables<'tcx>( async_closures: FxHashSet::default(), tcx: cx.tcx, }; - let infcx = cx.tcx.infer_ctxt().build(); - euv::ExprUseVisitor::new( - &mut ctx, - &infcx, - body_owner, - cx.param_env, - cx.typeck_results(), - ) - .consume_body(body); + + euv::ExprUseVisitor::for_clippy(cx, body_owner, &mut ctx) + .consume_body(body) + .into_ok(); let mut checked_closures = FxHashSet::default(); // We retrieve all the closures declared in the function because they will not be found // by `euv::Delegate`. - let mut closures: FxHashSet = FxHashSet::default(); - for_each_expr_with_closures(cx, cx.tcx.hir().body(body.id()).value, |expr| { + let mut closures: FxHashSet = FxHashSet::default(); + for_each_expr(cx, body, |expr| { if let hir::ExprKind::Closure(closure) = expr.kind { closures.insert(closure.def_id); } ControlFlow::<()>::Continue(()) }); - check_closures(&mut ctx, cx, &infcx, &mut checked_closures, closures); + check_closures(&mut ctx, cx, &mut checked_closures, closures); ctx }; @@ -95,7 +91,6 @@ pub(crate) fn check_variables<'tcx>( pub(crate) fn check_closures<'tcx>( ctx: &mut MutablyUsedVariablesCtxt<'tcx>, cx: &LateContext<'tcx>, - infcx: &InferCtxt<'tcx>, checked_closures: &mut FxHashSet, closures: FxHashSet, ) { @@ -108,12 +103,13 @@ pub(crate) fn check_closures<'tcx>( ctx.prev_move_to_closure.clear(); if let Some(body) = cx .tcx - .opt_hir_node_by_def_id(closure) - .and_then(associated_body) + .hir_node_by_def_id(closure) + .associated_body() .map(|(_, body_id)| hir.body(body_id)) { - euv::ExprUseVisitor::new(ctx, infcx, closure, cx.param_env, cx.typeck_results()) - .consume_body(body); + euv::ExprUseVisitor::for_clippy(cx, closure, &mut *ctx) + .consume_body(body) + .into_ok(); } } } @@ -341,7 +337,7 @@ pub(crate) fn check_implements_par_iter<'tcx>( let mut implemented_traits = Vec::new(); for trait_path in TRAIT_PATHS { - if let Some(trait_def_id) = get_trait_def_id(cx, trait_path) { + if let Some(trait_def_id) = get_trait_def_id(cx.tcx, trait_path) { if cx .tcx .infer_ctxt() diff --git a/lints/par_iter/ui/main.fixed b/lints/par_iter/ui/main.fixed index 38a485d..c40d945 100644 --- a/lints/par_iter/ui/main.fixed +++ b/lints/par_iter/ui/main.fixed @@ -217,7 +217,7 @@ pub fn complex_long_chain() { let multiplier = 2; let threshold = 5; let my_string = "Hello".to_string(); - let my_enum = MyEnum::B; // Construct the enum variant + let my_enum: MyEnum = MyEnum::B; // Construct the enum variant data.par_iter() .map(|&x| { diff --git a/lints/rayon_imports/src/rayon_prelude.rs b/lints/rayon_imports/src/rayon_prelude.rs index 7074b49..98912d8 100644 --- a/lints/rayon_imports/src/rayon_prelude.rs +++ b/lints/rayon_imports/src/rayon_prelude.rs @@ -59,19 +59,15 @@ impl LateLintPass<'_> for RayonPrelude { let import_suggestion = "#[allow(unused_imports)]\nuse rayon::prelude::*;\n".to_string(); let inject_use_span = md.spans.inject_use_span; if !use_statement_visitor.has_import { - cx.span_lint( - RAYON_PRELUDE, - inject_use_span, - "rayon::prelude::* is not imported", - |diag| { - diag.span_suggestion( - inject_use_span, - "consider adding this import", - import_suggestion, - rustc_errors::Applicability::MachineApplicable, - ); - }, - ); + cx.span_lint(RAYON_PRELUDE, inject_use_span, |diag| { + diag.primary_message("rayon::prelude::* is not imported"); + diag.span_suggestion( + inject_use_span, + "consider adding this import", + import_suggestion, + rustc_errors::Applicability::MachineApplicable, + ); + }); } } } diff --git a/lints/to_iter/src/lib.rs b/lints/to_iter/src/lib.rs index 14d225c..e05cfd7 100644 --- a/lints/to_iter/src/lib.rs +++ b/lints/to_iter/src/lib.rs @@ -1,12 +1,12 @@ #![feature(rustc_private)] #![warn(unused_extern_crates)] #![feature(let_chains)] +#![feature(unwrap_infallible)] extern crate rustc_errors; extern crate rustc_hash; extern crate rustc_hir; extern crate rustc_hir_typeck; -extern crate rustc_infer; extern crate rustc_middle; extern crate rustc_span; @@ -19,8 +19,9 @@ use rustc_errors::Applicability; use rustc_hir::{ def::Res, intravisit::{walk_expr, Visitor}, - ByRef, Expr, ExprKind, LangItem, Local, Node, PatKind, QPath, + ByRef, Expr, ExprKind, LangItem, Node, PatKind, QPath, }; + use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::Ty; use rustc_span::symbol::sym; @@ -75,27 +76,24 @@ impl<'tcx> LateLintPass<'tcx> for ToIter { // If the argument is a variable, we need to make sure it is mutable so that it works // with try_for_each. let mut add_mut_sugg = None; + if validator.ret_ty.is_some() && let ExprKind::Path(ref qpath) = arg.kind - && let Some(parent_node) = match cx.qpath_res(qpath, expr.hir_id) { - Res::Local(hir_id) => Some(cx.tcx.parent_hir_node(hir_id)), - _ => None, - } - && let Some(pat) = match parent_node { - Node::Local(Local { pat, .. }) => Some(*pat), - _ => None, - } + && let Res::Local(hir_id) = cx.qpath_res(qpath, expr.hir_id) + && let Node::LetStmt(stmt) = cx.tcx.parent_hir_node(hir_id) + && let PatKind::Binding(m, _, id, op) = stmt.pat.kind + && m.1.is_not() { - if let PatKind::Binding(m, _, id, op) = pat.kind { - if !m.1.is_mut() { - let ref_snip = if m.0 == ByRef::Yes { "ref " } else { "" }; - let ident_snip = span_to_snippet_macro(src_map, id.span); - let osp_snip = - op.map_or(String::new(), |p| span_to_snippet_macro(src_map, p.span)); - add_mut_sugg = - Some((pat.span, format!("{ref_snip}mut {ident_snip}{osp_snip}"))); - } - } + let ref_snip = match m.0 { + ByRef::Yes(_) => "ref ", + ByRef::No => "", + }; + let ident_snip = span_to_snippet_macro(src_map, id.span); + let osp_snip = op.map_or(String::new(), |p| span_to_snippet_macro(src_map, p.span)); + add_mut_sugg = Some(( + stmt.pat.span, + format!("{ref_snip}mut {ident_snip}{osp_snip}"), + )); } let mut used_vars = check_variables(cx, body); @@ -189,7 +187,8 @@ impl<'tcx> LateLintPass<'tcx> for ToIter { suggs.push(add_mut); } - cx.span_lint(TO_ITER, expr.span, "use an iterator", |diag| { + cx.span_lint(TO_ITER, expr.span, |diag| { + diag.primary_message("use an iterator"); diag.multipart_suggestion( "try using an iterator", suggs, diff --git a/lints/to_iter/src/variable_check.rs b/lints/to_iter/src/variable_check.rs index 2dd70dd..c6ce727 100644 --- a/lints/to_iter/src/variable_check.rs +++ b/lints/to_iter/src/variable_check.rs @@ -1,14 +1,13 @@ -use clippy_utils::visitors::for_each_expr_with_closures; +use clippy_utils::visitors::for_each_expr; use rustc_hash::FxHashSet; use rustc_hir as hir; use rustc_hir_typeck::expr_use_visitor as euv; -use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; use rustc_lint::LateContext; use rustc_middle::{ - hir::map::associated_body, mir::FakeReadCause, ty::{self, Ty, UpvarId, UpvarPath}, }; +use rustc_span::def_id::LocalDefId; use std::{collections::HashSet, ops::ControlFlow}; pub struct UsedVariablesCtxt<'tcx> { @@ -39,28 +38,23 @@ pub fn check_variables<'tcx>( prev_bind: None, prev_move_to_closure: hir::HirIdSet::default(), }; - let infcx = cx.tcx.infer_ctxt().build(); - euv::ExprUseVisitor::new( - &mut ctx, - &infcx, - body_owner, - cx.param_env, - cx.typeck_results(), - ) - .walk_expr(ex); + + euv::ExprUseVisitor::for_clippy(cx, body_owner, &mut ctx) + .walk_expr(ex) + .into_ok(); let mut checked_closures = FxHashSet::default(); // We retrieve all the closures declared in the function because they will not be found // by `euv::Delegate`. - let mut closures: FxHashSet = FxHashSet::default(); - for_each_expr_with_closures(cx, ex, |expr| { + let mut closures: FxHashSet = FxHashSet::default(); + for_each_expr(cx, ex, |expr| { if let hir::ExprKind::Closure(closure) = expr.kind { closures.insert(closure.def_id); } ControlFlow::<()>::Continue(()) }); - check_closures(&mut ctx, cx, &infcx, &mut checked_closures, closures); + check_closures(&mut ctx, cx, &mut checked_closures, closures); ctx } @@ -68,7 +62,6 @@ pub fn check_variables<'tcx>( pub fn check_closures<'tcx, S: ::std::hash::BuildHasher>( ctx: &mut UsedVariablesCtxt<'tcx>, cx: &LateContext<'tcx>, - infcx: &InferCtxt<'tcx>, checked_closures: &mut HashSet, closures: HashSet, ) { @@ -81,12 +74,13 @@ pub fn check_closures<'tcx, S: ::std::hash::BuildHasher>( ctx.prev_move_to_closure.clear(); if let Some(body) = cx .tcx - .opt_hir_node_by_def_id(closure) - .and_then(associated_body) + .hir_node_by_def_id(closure) + .associated_body() .map(|(_, body_id)| hir.body(body_id)) { - euv::ExprUseVisitor::new(ctx, infcx, closure, cx.param_env, cx.typeck_results()) - .consume_body(body); + euv::ExprUseVisitor::for_clippy(cx, closure, &mut *ctx) + .consume_body(body) + .into_ok(); } } } diff --git a/rust-toolchain b/rust-toolchain index fd2c89a..4b1a3c8 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2024-02-22" +channel = "nightly-2024-07-25" components = ["llvm-tools-preview", "rustc-dev"] diff --git a/scripts/prepare_repo.sh b/scripts/prepare_repo.sh index a80f6c5..261134f 100755 --- a/scripts/prepare_repo.sh +++ b/scripts/prepare_repo.sh @@ -1,7 +1,7 @@ #!/bin/bash if ! command -v cargo-dylint &> /dev/null || ! command -v dylint-link &> /dev/null; then - cargo +stable install cargo-dylint@3.0.0 dylint-link@3.0.0 + cargo install cargo-dylint dylint-link fi CARGO_TOML="Cargo.toml" diff --git a/src/lib.rs b/src/lib.rs index 3250819..02c7890 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ #![feature(rustc_private)] #![warn(unused_extern_crates)] +#![feature(unwrap_infallible)] dylint_linting::dylint_library!(); diff --git a/utils/src/lib.rs b/utils/src/lib.rs index d275281..438ccc2 100644 --- a/utils/src/lib.rs +++ b/utils/src/lib.rs @@ -17,7 +17,7 @@ use rustc_span::{Span, SyntaxContext}; pub fn is_local_def(stmt: &Stmt) -> bool { match stmt.kind { - StmtKind::Local(_) => true, + StmtKind::Let(_) => true, StmtKind::Expr(e) | StmtKind::Semi(e) => { if let ExprKind::Block(b, _) = e.kind { b.stmts.iter().all(is_local_def) && b.expr.is_none()