diff --git a/Cargo.lock b/Cargo.lock index 78f5e42d..9da89a6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] @@ -48,11 +48,11 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.64.0" +version = "0.66.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" dependencies = [ - "bitflags", + "bitflags 2.3.3", "cexpr", "clang-sys", "lazy_static", @@ -63,7 +63,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 1.0.109", + "syn 2.0.27", ] [[package]] @@ -72,6 +72,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + [[package]] name = "byteorder" version = "1.4.3" @@ -80,27 +86,27 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "camino" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" dependencies = [ "serde", ] [[package]] name = "cargo_metadata" -version = "0.15.4" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" +checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" dependencies = [ "camino", "cargo-platform", @@ -149,7 +155,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_lex", "indexmap", "strsim 0.10.0", @@ -218,9 +224,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.14" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ "autocfg", "cfg-if", @@ -231,9 +237,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", ] @@ -275,9 +281,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "env_logger" @@ -300,7 +306,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -315,12 +321,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.9.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] name = "filetime" @@ -331,7 +334,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall 0.2.16", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -367,9 +370,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -399,18 +402,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "humantime" @@ -443,43 +437,31 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "io-lifetimes" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" -dependencies = [ - "hermit-abi 0.3.1", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", + "hermit-abi 0.3.2", "rustix", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "itertools" -version = "0.10.5" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" dependencies = [ "either", ] [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "lazy_static" @@ -495,9 +477,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.144" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libloading" @@ -511,15 +493,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.3.7" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -527,12 +509,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "log-derive" @@ -554,9 +533,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg", ] @@ -600,7 +579,7 @@ dependencies = [ [[package]] name = "mirai-annotations" -version = "1.12.0" +version = "1.12.1" [[package]] name = "mirai-standard-contracts" @@ -621,19 +600,19 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.2", "libc", ] [[package]] name = "os_str_bytes" -version = "6.5.0" +version = "6.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" +checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" [[package]] name = "parking_lot" @@ -684,18 +663,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.27" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -758,7 +737,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -767,14 +746,26 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.8.1" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" dependencies = [ "aho-corasick", "memchr", @@ -783,9 +774,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "rpds" @@ -811,23 +802,22 @@ checksum = "8ba09476327c4b70ccefb6180f046ef588c26a24cf5d269a9feba316eb4f029f" [[package]] name = "rustix" -version = "0.37.19" +version = "0.38.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" dependencies = [ - "bitflags", + "bitflags 2.3.3", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "same-file" @@ -840,44 +830,44 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.162" +version = "1.0.178" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6" +checksum = "60363bdd39a7be0266a520dab25fdc9241d2f987b08a01e01f0ec6d06a981348" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.162" +version = "1.0.178" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6" +checksum = "f28482318d6641454cb273da158647922d1be6b5a2fcc6165cd89ebdd7ed576b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.27", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" dependencies = [ "itoa", "ryu", @@ -926,9 +916,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "static_assertions" @@ -961,9 +951,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0" dependencies = [ "proc-macro2", "quote", @@ -986,9 +976,9 @@ dependencies = [ [[package]] name = "tar" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" +checksum = "ec96d2ffad078296368d46ff1cb309be1c23c513b4ab0e22a45de0185275ac96" dependencies = [ "filetime", "libc", @@ -997,15 +987,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.5.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "5486094ee78b2e5038a6382ed7645bc084dc2ec433426ca4c3cb61e2007b8998" dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", "rustix", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -1025,22 +1015,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.27", ] [[package]] @@ -1060,9 +1050,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "untrustworthy_inputs" @@ -1125,132 +1115,66 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.0" @@ -1268,8 +1192,9 @@ dependencies = [ [[package]] name = "z3-sys" -version = "0.7.1" -source = "git+https://github.com/prove-rs/z3.rs.git#691ac9782f361969e87ac745a3d9a6816593741a" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7cf70fdbc0de3f42b404f49b0d4686a82562254ea29ff0a155eef2f5430f4b0" dependencies = [ "bindgen", "cmake", diff --git a/Cargo.toml b/Cargo.toml index fcf37e5b..220e2643 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "annotations", diff --git a/binaries/summary_store.tar b/binaries/summary_store.tar index d0a128c4..1f5a3369 100644 Binary files a/binaries/summary_store.tar and b/binaries/summary_store.tar differ diff --git a/checker/Cargo.toml b/checker/Cargo.toml index 02137195..bcb57037 100644 --- a/checker/Cargo.toml +++ b/checker/Cargo.toml @@ -49,7 +49,7 @@ shellwords = "*" sled = "*" tar = "0.4.38" tempfile = "*" -z3-sys = { version = "*", git="https://github.com/prove-rs/z3.rs.git", features = ["static-link-z3"], optional = true } +z3-sys = { version = "*", features = ["static-link-z3"], optional = true } [dev-dependencies] walkdir = "*" diff --git a/checker/src/block_visitor.rs b/checker/src/block_visitor.rs index f41b1bbe..4fd5e735 100644 --- a/checker/src/block_visitor.rs +++ b/checker/src/block_visitor.rs @@ -15,12 +15,12 @@ use rustc_hir::def_id::DefId; use rustc_index::{Idx, IndexVec}; use rustc_middle::mir; use rustc_middle::mir::interpret::{alloc_range, ConstValue, GlobalAlloc, Scalar}; -use rustc_middle::ty::adjustment::PointerCast; +use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::layout::LayoutCx; -use rustc_middle::ty::subst::{GenericArg, SubstsRef}; use rustc_middle::ty::{ Const, FloatTy, IntTy, ParamConst, ScalarInt, Ty, TyKind, UintTy, ValTree, VariantDef, }; +use rustc_middle::ty::{GenericArg, GenericArgsRef}; use rustc_target::abi::{FieldIdx, Primitive, TagEncoding, VariantIdx, Variants}; use crate::abstract_value; @@ -299,14 +299,15 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com place, target, unwind, - } => self.visit_drop(place, *target, *unwind), + replace, + } => self.visit_drop(place, *target, *unwind, *replace), mir::TerminatorKind::Call { func, args, destination, target, unwind, - from_hir_call, + call_source, fn_span, } => self.visit_call( func, @@ -314,7 +315,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com *destination, *target, *unwind, - *from_hir_call, + *call_source, fn_span, ), mir::TerminatorKind::Assert { @@ -369,8 +370,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com span, format!( "unknown tag type for constant-time verification: {tag_name}", - ) - .as_str(), + ), ); self.bv.emit_diagnostic(warning); } @@ -477,7 +477,12 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com place: &mir::Place<'tcx>, target: mir::BasicBlock, unwind: mir::UnwindAction, + // The `replace` flag indicates whether this terminator was created as part of an assignment. + // This should only be used for diagnostic purposes, and does not have any operational + // meaning. + _replace: bool, ) { + let tcx = self.bv.cv.tcx; let place_path = self.get_path_for_place(place); let path = place_path.canonicalize(&self.bv.current_environment); let mut ty = self @@ -492,24 +497,20 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com self.type_visitor_mut() .set_path_rustc_type(path.clone(), ty); - if let TyKind::Adt(def, substs) = ty.kind() { - if let Some(destructor) = self.bv.tcx.adt_destructor(def.did()) { - let actual_argument_types = vec![self - .bv - .cv - .tcx - .mk_mut_ref(self.bv.cv.tcx.lifetimes.re_static, ty)]; + if let TyKind::Adt(def, args) = ty.kind() { + if let Some(destructor) = tcx.adt_destructor(def.did()) { + let actual_argument_types = vec![Ty::new_mut_ref(tcx, tcx.lifetimes.re_static, ty)]; let callee_generic_arguments = self .type_visitor() - .specialize_substs(substs, &self.type_visitor().generic_argument_map); + .specialize_generic_args(args, &self.type_visitor().generic_argument_map); let callee_generic_argument_map = self.type_visitor().get_generic_arguments_map( def.did(), callee_generic_arguments, &actual_argument_types, ); - let fun_ty = self.bv.tcx.type_of(destructor.did).skip_binder(); + let fun_ty = tcx.type_of(destructor.did).skip_binder(); let func_const = self - .visit_function_reference(destructor.did, fun_ty, Some(substs)) + .visit_function_reference(destructor.did, fun_ty, Some(args)) .clone(); let func_to_call = Rc::new(func_const.clone().into()); let ref_to_path_value = AbstractValue::make_reference(path.clone()); @@ -579,7 +580,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com /// reused across function calls without duplicating the contents. /// * `destination` - Destination for the return value. If some, the call returns a value. /// * `unwind` - Work to be done if the call unwinds. - /// * `from_hir_call` - Whether this is from a call in HIR, rather than from an overloaded + /// * `call_source` - Where this call came from in HIR/THIR. /// operator. True for overloaded function call. #[allow(clippy::too_many_arguments)] #[logfn_inputs(TRACE)] @@ -590,7 +591,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com destination: mir::Place<'tcx>, target: Option, unwind: mir::UnwindAction, - from_hir_call: bool, + _call_source: mir::CallSource, fn_span: &rustc_span::Span, ) { // This offset is used to distinguish any local variables that leak out from the called function @@ -631,15 +632,15 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com let callee_def_id = func_ref_to_call .def_id .expect("callee obtained via operand should have def id"); - let substs = self + let generic_args = self .bv .cv - .substs_cache + .generic_args_cache .get(&callee_def_id) .expect("MIR should ensure this"); let mut callee_generic_arguments = self .type_visitor() - .specialize_substs(substs, &self.type_visitor().generic_argument_map); + .specialize_generic_args(generic_args, &self.type_visitor().generic_argument_map); let actual_args: Vec<(Rc, Rc)> = args .iter() .map(|arg| (self.get_operand_path(arg), self.visit_operand(arg))) @@ -676,8 +677,8 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com // might not be specialized enough. if !actual_argument_types.is_empty() && !utils::are_concrete(callee_generic_arguments) { let fty = self.bv.tcx.type_of(callee_def_id).skip_binder(); - if let TyKind::FnDef(_, substs) = fty.kind() { - for (i, generic_ty_arg) in substs.types().enumerate() { + if let TyKind::FnDef(_, args) = fty.kind() { + for (i, generic_ty_arg) in args.types().enumerate() { if let TyKind::Param(t_par) = generic_ty_arg.kind() { if t_par.name.as_str() == "Self" { let mut gen_args: Vec> = @@ -686,7 +687,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com .type_visitor() .get_dereferenced_type(actual_argument_types[0]) .into(); - callee_generic_arguments = self.bv.tcx.mk_substs(&gen_args); + callee_generic_arguments = self.bv.tcx.mk_args(&gen_args); break; } } @@ -1010,29 +1011,29 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com ); if let TyKind::Alias( rustc_middle::ty::Opaque, - rustc_middle::ty::AliasTy { def_id, substs, .. }, + rustc_middle::ty::AliasTy { def_id, args, .. }, ) = specialized_closure_ty.kind() { - let substs = self + let args = self .type_visitor() - .specialize_substs(substs, &self.type_visitor().generic_argument_map); - self.bv.cv.substs_cache.insert(*def_id, substs); + .specialize_generic_args(args, &self.type_visitor().generic_argument_map); + self.bv.cv.generic_args_cache.insert(*def_id, args); let closure_ty = self.bv.tcx.type_of(*def_id).skip_binder(); let map = self .type_visitor() - .get_generic_arguments_map(*def_id, substs, &[]); + .get_generic_arguments_map(*def_id, args, &[]); specialized_closure_ty = self .type_visitor() .specialize_generic_argument_type(closure_ty, &map); } match specialized_closure_ty.kind() { - TyKind::Closure(def_id, substs) - | TyKind::Generator(def_id, substs, _) - | TyKind::FnDef(def_id, substs) => { + TyKind::Closure(def_id, args) + | TyKind::Generator(def_id, args, _) + | TyKind::FnDef(def_id, args) => { return extract_func_ref(self.visit_function_reference( *def_id, specialized_closure_ty, - Some(substs), + Some(args), )); } TyKind::Ref(_, ty, _) => { @@ -1041,13 +1042,13 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com *ty, &self.type_visitor().generic_argument_map, ); - if let TyKind::Closure(def_id, substs) | TyKind::FnDef(def_id, substs) = + if let TyKind::Closure(def_id, args) | TyKind::FnDef(def_id, args) = specialized_closure_ty.kind() { return extract_func_ref(self.visit_function_reference( *def_id, specialized_closure_ty, - Some(substs), + Some(args), )); } if let TyKind::Dynamic(..) = specialized_closure_ty.kind() { @@ -1158,7 +1159,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com .bv .cv .session - .struct_span_warn(span, diagnostic.as_ref()); + .struct_span_warn(span, diagnostic.as_ref().to_string()); for pc_span in precondition.spans.iter() { let snippet = self.bv.tcx.sess.source_map().span_to_snippet(*pc_span); if snippet.is_ok() { @@ -1317,7 +1318,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com ) { let span = self.bv.current_span.source_callsite(); - let warning = self.bv.cv.session.struct_span_warn(span, warning.as_str()); + let warning = self.bv.cv.session.struct_span_warn(span, warning.clone()); self.bv.emit_diagnostic(warning); } } @@ -1405,10 +1406,9 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com value_name, if checking_presence { "may not" } else { "may" }, tag_name - ) - .as_str(), + ), ); - self.bv.emit_diagnostic(warning); + self.bv.emit_diagnostic(warning.clone()); } else if promotable_entry_condition.is_none() || tag_check.extract_promotable_disjuncts(false).is_none() { @@ -1419,10 +1419,9 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com "the {value_name} may have a {tag_name} tag, \ and the tag check cannot be promoted as a precondition, \ because it contains local variables", - ) - .as_str(), + ), ); - self.bv.emit_diagnostic(warning); + self.bv.emit_diagnostic(warning.clone()); } } @@ -1430,10 +1429,11 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com // The existence of the tag on the value is different from the expectation. // In this case, report an error. let span = self.bv.current_span.source_callsite(); - let warning = self.bv.cv.session.struct_span_warn( - span, - format!("the {value_name} has a {tag_name} tag").as_str(), - ); + let warning = self + .bv + .cv + .session + .struct_span_warn(span, format!("the {value_name} has a {tag_name} tag")); self.bv.emit_diagnostic(warning); } @@ -1539,7 +1539,8 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com if entry_cond_as_bool.unwrap_or(false) { let error = get_assert_msg_description(msg); let span = self.bv.current_span; - let warning = self.bv.cv.session.struct_span_warn(span, error); + let warning = + self.bv.cv.session.struct_span_warn(span, error.to_string()); self.bv.emit_diagnostic(warning); // No need to push a precondition, the caller can never satisfy it. return; @@ -1573,7 +1574,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com // Can't make this the caller's problem. let warning = format!("possible {}", get_assert_msg_description(msg)); let span = self.bv.current_span; - let warning = self.bv.cv.session.struct_span_warn(span, warning.as_str()); + let warning = self.bv.cv.session.struct_span_warn(span, warning); self.bv.emit_diagnostic(warning); return; } @@ -1888,10 +1889,13 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com // To look up box.0.0 we need the type of the thin pointer, which we // derive from target_type (which is known to be a slice pointer). let deref_ty = self.type_visitor().get_dereferenced_type(target_type); - let thin_ptr_ty = self.bv.tcx.mk_ptr(rustc_middle::ty::TypeAndMut { - ty: deref_ty, - mutbl: rustc_hir::Mutability::Not, - }); + let thin_ptr_ty = Ty::new_ptr( + self.bv.tcx, + rustc_middle::ty::TypeAndMut { + ty: deref_ty, + mutbl: rustc_hir::Mutability::Not, + }, + ); let ptr_val = self .bv .lookup_path_and_refine_result(qualifier.clone(), thin_ptr_ty); @@ -2063,7 +2067,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com | mir::CastKind::PointerFromExposedAddress // All sorts of pointer-to-pointer casts. Note that reference-to-raw-ptr casts are // translated into `&raw mut/const *r`, i.e., they are not actually casts. - | mir::CastKind::Pointer(..) + | mir::CastKind::PointerCoercion(..) // Cast into a dyn* object. | mir::CastKind::DynStar => { // The value remains unchanged, but pointers may be fat, so use copy_or_move_elements @@ -2082,7 +2086,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com return; } }; - if matches!(cast_kind, mir::CastKind::Pointer(PointerCast::Unsize)){ + if matches!(cast_kind, mir::CastKind::PointerCoercion(PointerCoercion::Unsize)){ // Unsize a pointer/reference value, e.g., `&[T; n]` to // `&[T]`. Note that the source could be a thin or fat pointer. // This will do things like convert thin pointers to fat @@ -2141,7 +2145,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com return; } let mut source_path = self.visit_rh_place(place); - if matches!(cast_kind, mir::CastKind::Pointer(PointerCast::ClosureFnPointer(_))){ + if matches!(cast_kind, mir::CastKind::PointerCoercion(PointerCoercion::ClosureFnPointer(_))){ source_path = Path::new_function(source_path) } self.bv @@ -2248,6 +2252,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com let right = self.visit_operand(right_operand); let mut result = match bin_op { mir::BinOp::Add => left.addition(right), + mir::BinOp::AddUnchecked => left.addition(right), mir::BinOp::BitAnd => left.bit_and(right), mir::BinOp::BitOr => left.bit_or(right), mir::BinOp::BitXor => left.bit_xor(right), @@ -2258,6 +2263,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com mir::BinOp::Le => left.less_or_equal(right), mir::BinOp::Lt => left.less_than(right), mir::BinOp::Mul => left.multiply(right), + mir::BinOp::MulUnchecked => left.multiply(right), mir::BinOp::Ne => left.not_equals(right), mir::BinOp::Offset => { let r = left.offset(right); @@ -2266,8 +2272,11 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com } mir::BinOp::Rem => left.remainder(right), mir::BinOp::Shl => left.shift_left(right), + mir::BinOp::ShlUnchecked => left.shift_left(right), mir::BinOp::Shr => left.shr(right), + mir::BinOp::ShrUnchecked => left.shr(right), mir::BinOp::Sub => left.subtract(right), + mir::BinOp::SubUnchecked => left.subtract(right), }; if let Expression::BitAnd { left, right } = &result.expression { if right.expression.is_memory_reference() { @@ -2528,7 +2537,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com self.visit_use(index_path, operand); } } - mir::AggregateKind::Adt(def, variant_idx, substs, _, case_index) => { + mir::AggregateKind::Adt(def, variant_idx, args, _, case_index) => { let mut path = path; let adt_def = self.bv.tcx.adt_def(def); let variant_def = &adt_def.variants()[*variant_idx]; @@ -2557,7 +2566,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com let case_index = case_index.unwrap_or(0usize.into()); let field_path = Path::new_union_field(path, case_index.into(), num_cases); let field = &variant_def.fields[case_index]; - let field_ty = field.ty(self.bv.tcx, substs); + let field_ty = field.ty(self.bv.tcx, args); self.type_visitor_mut() .set_path_rustc_type(field_path.clone(), field_ty); self.visit_use(field_path, &operands[0usize.into()]); @@ -2569,7 +2578,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com } for (i, field) in variant_def.fields.iter().enumerate() { let field_path = Path::new_field(path.clone(), i); - let field_ty = field.ty(self.bv.tcx, substs); + let field_ty = field.ty(self.bv.tcx, args); self.type_visitor_mut() .set_path_rustc_type(field_path.clone(), field_ty); if let Some(operand) = operands.get(i.into()) { @@ -2582,10 +2591,10 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com } } } - mir::AggregateKind::Closure(def_id, substs) - | mir::AggregateKind::Generator(def_id, substs, _) => { + mir::AggregateKind::Closure(def_id, args) + | mir::AggregateKind::Generator(def_id, args, _) => { let ty = self.bv.tcx.type_of(*def_id).skip_binder(); - let func_const = self.visit_function_reference(*def_id, ty, Some(substs)); + let func_const = self.visit_function_reference(*def_id, ty, Some(args)); let func_val = Rc::new(func_const.clone().into()); self.bv.update_value_at(path.clone(), func_val); for (i, operand) in operands.iter().enumerate() { @@ -2704,23 +2713,22 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com ) -> Rc { let mut def_id = unevaluated.def; let def_ty = self.bv.cv.tcx.type_of(def_id); - let substs = self.type_visitor().specialize_substs( - unevaluated.substs, - &self.type_visitor().generic_argument_map, - ); - self.bv.cv.substs_cache.insert(def_id, substs); + let args = self + .type_visitor() + .specialize_generic_args(unevaluated.args, &self.type_visitor().generic_argument_map); + self.bv.cv.generic_args_cache.insert(def_id, args); let path = match unevaluated.promoted { Some(promoted) => { let index = promoted.index(); Rc::new(PathEnum::PromotedConstant { ordinal: index }.into()) } None => { - if !substs.is_empty() { + if !args.is_empty() { let param_env = rustc_middle::ty::ParamEnv::reveal_all(); trace!("devirtualize resolving def_id {:?}: {:?}", def_id, def_ty); - trace!("substs {:?}", substs); + trace!("args {:?}", args); if let Ok(Some(instance)) = - rustc_middle::ty::Instance::resolve(self.bv.tcx, param_env, def_id, substs) + rustc_middle::ty::Instance::resolve(self.bv.tcx, param_env, def_id, args) { def_id = instance.def.def_id(); trace!("resolved it to {:?}", def_id); @@ -2731,7 +2739,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com } else if self.bv.cv.known_names_cache.get(self.bv.tcx, def_id) == KnownNames::AllocRawVecMinNonZeroCap { - if let Ok(ty_and_layout) = self.type_visitor().layout_of(substs.type_at(0)) { + if let Ok(ty_and_layout) = self.type_visitor().layout_of(args.type_at(0)) { if !ty_and_layout.is_unsized() { let size_of_t = ty_and_layout.layout.size().bytes(); let min_non_zero_cap: u128 = if size_of_t == 1 { @@ -2772,13 +2780,15 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com /// Synthesizes a MIRAI constant value from a RustC constant as used in the type system #[logfn_inputs(TRACE)] pub fn visit_const(&mut self, literal: &Const<'tcx>) -> Rc { - let mut val = literal.kind(); + let mut kind = literal.kind(); let lty = literal.ty(); - if let rustc_middle::ty::ConstKind::Unevaluated(_unevaluated) = &val { - val = val.eval(self.bv.tcx, self.type_visitor().get_param_env()); + if let rustc_middle::ty::ConstKind::Unevaluated(_unevaluated) = &kind { + kind = literal + .eval(self.bv.tcx, self.type_visitor().get_param_env()) + .kind(); } - match &val { + match &kind { // A const generic parameter. rustc_middle::ty::ConstKind::Param(ParamConst { index, .. }) => { if let Some(gen_args) = self.type_visitor().generic_arguments { @@ -2788,7 +2798,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com } assume_unreachable!( "reference to unmatched generic constant argument {:?} {:?} {:?}", - val, + kind, self.type_visitor().generic_arguments, self.bv.current_span ); @@ -2810,7 +2820,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com heap_block } _ => { - debug!("val {:?}", val); + debug!("kind {:?}", kind); Rc::new(ConstantDomain::Unimplemented.into()) } } @@ -2833,14 +2843,14 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com fn deserialize_fields( &mut self, - substs: SubstsRef<'tcx>, + args: GenericArgsRef<'tcx>, mut val_tree_iter: std::slice::Iter>, heap_path: Rc, variant: &VariantDef, ) { for (i, field) in variant.fields.iter().enumerate() { let field_path = Path::new_field(heap_path.clone(), i); - let field_ty = field.ty(self.bv.tcx, substs); + let field_ty = field.ty(self.bv.tcx, args); if let Some(val_tree) = val_tree_iter.next() { self.deserialize_val_tree(val_tree, field_path, field_ty); } else { @@ -2862,7 +2872,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com self.bv.update_value_at(target_path, const_value); } ValTree::Branch(val_trees) => match ty.kind() { - TyKind::Adt(def, substs) if def.is_enum() => { + TyKind::Adt(def, args) if def.is_enum() => { let mut val_tree_iter = val_trees.iter(); let variant_index = if let Some(ValTree::Leaf(scalar_int)) = val_tree_iter.next() { @@ -2874,15 +2884,15 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com ); }; let variant = &def.variants()[variant_index]; - self.deserialize_fields(substs, val_tree_iter, target_path, variant); + self.deserialize_fields(args, val_tree_iter, target_path, variant); } TyKind::Adt(def, _) if def.is_union() => { debug!("Did not expect to a serialized union value {:?}", def); } - TyKind::Adt(def, substs) => { + TyKind::Adt(def, args) => { let val_tree_iter = val_trees.iter(); let variant = &def.variants()[VariantIdx::new(0)]; - self.deserialize_fields(substs, val_tree_iter, target_path, variant); + self.deserialize_fields(args, val_tree_iter, target_path, variant); } TyKind::Tuple(types) => { let mut val_tree_iter = val_trees.iter(); @@ -2997,12 +3007,12 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com } Some(GlobalAlloc::Function(instance)) => { let def_id = instance.def.def_id(); - let substs = self.type_visitor().specialize_substs( - instance.substs, + let args = self.type_visitor().specialize_generic_args( + instance.args, &self.type_visitor().generic_argument_map, ); let fn_ty = self.bv.tcx.type_of(def_id).skip_binder(); - self.bv.cv.substs_cache.insert(def_id, substs); + self.bv.cv.generic_args_cache.insert(def_id, args); let fun_val = Rc::new( self.bv .cv @@ -3010,7 +3020,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com .get_function_constant_for( def_id, fn_ty, - Some(substs), + Some(args), self.bv.tcx, &mut self.bv.cv.known_names_cache, &mut self.bv.cv.summary_cache, @@ -3153,8 +3163,8 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com self.type_visitor_mut() .set_path_rustc_type(target_path.clone(), ty); match ty.kind() { - TyKind::Adt(def, substs) if def.is_enum() => { - trace!("deserializing {:?} {:?}", def, substs); + TyKind::Adt(def, args) if def.is_enum() => { + trace!("deserializing {:?} {:?}", def, args); trace!("def.repr() {:?}", def.repr()); let mut bytes_left_to_deserialize = bytes; if let Ok(enum_ty_layout) = self.type_visitor().layout_of(ty) { @@ -3199,7 +3209,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com trace!("deserializing field({}) {:?}", i, field); trace!("bytes_left_deserialize {:?}", bytes_left_to_deserialize); let field_path = Path::new_field(target_path.clone(), i); - let field_ty = field.ty(self.bv.tcx, substs); + let field_ty = field.ty(self.bv.tcx, args); trace!( "field ty layout {:?}", self.type_visitor().layout_of(field_ty) @@ -3214,8 +3224,8 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com } bytes_left_to_deserialize } - TyKind::Adt(def, substs) => { - trace!("deserializing {:?} {:?}", def, substs); + TyKind::Adt(def, args) => { + trace!("deserializing {:?} {:?}", def, args); let mut bytes_left_to_deserialize = bytes; for variant in def.variants().iter() { trace!("deserializing variant {:?}", variant); @@ -3224,7 +3234,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com trace!("deserializing field({}) {:?}", i, field); trace!("bytes_left_deserialize {:?}", bytes_left_to_deserialize); let field_path = Path::new_field(target_path.clone(), i); - let field_ty = field.ty(self.bv.tcx, substs); + let field_ty = field.ty(self.bv.tcx, args); trace!( "field ty layout {:?}", self.type_visitor().layout_of(field_ty) @@ -3307,7 +3317,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com &bytes[size..] }, TyKind::Uint(UintTy::U8) => unsafe { - let uint_ptr = bytes.as_ptr() as *const u8; + let uint_ptr = bytes.as_ptr(); let u = self.bv.get_u128_const_val((*uint_ptr) as u128); self.bv.update_value_at(target_path, u); &bytes[1..] @@ -3401,22 +3411,22 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com } // todo: bytes is the serialization of the captured state of a closure/generator // deserialize that and return an heap block that represents the closure state + func ptr - TyKind::Closure(def_id, substs) - | TyKind::FnDef(def_id, substs) - | TyKind::Generator(def_id, substs, ..) + TyKind::Closure(def_id, args) + | TyKind::FnDef(def_id, args) + | TyKind::Generator(def_id, args, ..) | TyKind::Alias( rustc_middle::ty::Opaque, - rustc_middle::ty::AliasTy { def_id, substs, .. }, + rustc_middle::ty::AliasTy { def_id, args, .. }, ) => { let specialized_ty = self.type_visitor().specialize_generic_argument_type( ty, &self.type_visitor().generic_argument_map, ); - let substs = self + let specialized_args = self .type_visitor() - .specialize_substs(substs, &self.type_visitor().generic_argument_map); + .specialize_generic_args(args, &self.type_visitor().generic_argument_map); let func_val = Rc::new( - self.visit_function_reference(*def_id, specialized_ty, Some(substs)) + self.visit_function_reference(*def_id, specialized_ty, Some(specialized_args)) .clone() .into(), ); @@ -3604,9 +3614,9 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com TyKind::Adt(adt_def, _) => adt_def .discriminants(self.bv.tcx) .find(|(_, var)| var.val == data), - TyKind::Generator(def_id, substs, _) => { - let substs = substs.as_generator(); - substs + TyKind::Generator(def_id, args, _) => { + let generator = args.as_generator(); + generator .discriminants(*def_id, self.bv.tcx) .find(|(_, var)| var.val == data) } @@ -3705,39 +3715,43 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com } TyKind::Uint(..) => self.bv.cv.constant_value_cache.get_u128_for(data), TyKind::RawPtr(..) => self.bv.cv.constant_value_cache.get_u128_for(data), - TyKind::Closure(def_id, substs) => { + TyKind::Closure(def_id, args) => { let specialized_ty = self.type_visitor().specialize_generic_argument_type( ty, &self.type_visitor().generic_argument_map, ); - let substs = self + let specialized_args = self .type_visitor() - .specialize_substs(substs, &self.type_visitor().generic_argument_map); - if substs.len() >= 3 { - let tuple_ty = substs.last().unwrap().expect_ty(); + .specialize_generic_args(args, &self.type_visitor().generic_argument_map); + if specialized_args.len() >= 3 { + let tuple_ty = specialized_args.last().unwrap().expect_ty(); let cv = self.get_constant_value_from_scalar(tuple_ty, data, size); let cp = Path::get_as_path(cv); let fr = self - .visit_function_reference(*def_id, specialized_ty, Some(substs)) + .visit_function_reference( + *def_id, + specialized_ty, + Some(specialized_args), + ) .clone(); let fv = Rc::::new(fr.into()); let fp = Path::get_as_path(fv.clone()); self.bv.copy_or_move_elements(fp, cp, tuple_ty, true); return fv; } else { - unreachable!("substs for closure not right {:?}", substs); + unreachable!("args for closure not right {:?}", specialized_args); } } - TyKind::FnDef(def_id, substs) => { + TyKind::FnDef(def_id, args) => { debug_assert!(size == 0 && data == 0); let specialized_ty = self.type_visitor().specialize_generic_argument_type( ty, &self.type_visitor().generic_argument_map, ); - let substs = self + let specialized_args = self .type_visitor() - .specialize_substs(substs, &self.type_visitor().generic_argument_map); - self.visit_function_reference(*def_id, specialized_ty, Some(substs)) + .specialize_generic_args(args, &self.type_visitor().generic_argument_map); + self.visit_function_reference(*def_id, specialized_ty, Some(specialized_args)) } _ => { let bytes = &data.to_ne_bytes()[0..size]; @@ -3780,11 +3794,11 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com &mut self, def_id: DefId, ty: Ty<'tcx>, - generic_args: Option>, + generic_args: Option>, ) -> &ConstantDomain { //todo: is def_id unique enough? Perhaps add ty? if let Some(generic_args) = generic_args { - self.bv.cv.substs_cache.insert(def_id, generic_args); + self.bv.cv.generic_args_cache.insert(def_id, generic_args); } self.bv.cv.constant_value_cache.get_function_constant_for( def_id, @@ -3924,7 +3938,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com let func_const = self.visit_function_reference( *def_id, ty, - Some(generic_args.as_closure().substs), + Some(generic_args.as_closure().args), ); let func_val = Rc::new(func_const.clone().into()); self.bv diff --git a/checker/src/body_visitor.rs b/checker/src/body_visitor.rs index db351abd..2febdab9 100644 --- a/checker/src/body_visitor.rs +++ b/checker/src/body_visitor.rs @@ -17,8 +17,7 @@ use mirai_annotations::*; use rustc_errors::DiagnosticBuilder; use rustc_hir::def_id::DefId; use rustc_middle::mir; -use rustc_middle::ty::subst::SubstsRef; -use rustc_middle::ty::{AdtDef, Const, Ty, TyCtxt, TyKind, TypeAndMut, UintTy}; +use rustc_middle::ty::{AdtDef, Const, GenericArgsRef, Ty, TyCtxt, TyKind, TypeAndMut, UintTy}; use crate::abstract_value::{self, AbstractValue, AbstractValueTrait, BOTTOM}; use crate::block_visitor::BlockVisitor; @@ -295,7 +294,7 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> { let dominators = self.mir.basic_blocks.dominators(); for (location1, callee_defid1) in self.block_to_call.iter() { for (location2, callee_defid2) in self.block_to_call.iter() { - if location1 != location2 && location1.dominates(*location2, &dominators) { + if location1 != location2 && location1.dominates(*location2, dominators) { self.cv.call_graph.add_dom(*callee_defid1, *callee_defid2); } } @@ -634,7 +633,7 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> { if self.active_calls_map.contains_key(&def_id) { return; } - let generic_args = self.cv.substs_cache.get(&def_id).cloned(); + let generic_args = self.cv.generic_args_cache.get(&def_id).cloned(); let callee_generic_argument_map = if let Some(generic_args) = generic_args { self.type_visitor() .get_generic_arguments_map(def_id, generic_args, &[]) @@ -1723,13 +1722,13 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> { let union_type = self .type_visitor() .get_path_rustc_type(qualifier, self.current_span); - if let TyKind::Adt(def, substs) = union_type.kind() { - let substs = self + if let TyKind::Adt(def, args) = union_type.kind() { + let args = self .type_visitor - .specialize_substs(substs, &self.type_visitor().generic_argument_map); + .specialize_generic_args(args, &self.type_visitor().generic_argument_map); for (i, field) in def.all_fields().enumerate() { let target_type = self.type_visitor().specialize_generic_argument_type( - field.ty(self.tcx, substs), + field.ty(self.tcx, args), &self.type_visitor().generic_argument_map, ); let target_path = Path::new_union_field(qualifier.clone(), i, *num_cases); @@ -1794,7 +1793,7 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> { fn add_leaf_fields_for<'a>( path: Rc, def: &'a AdtDef, - substs: SubstsRef<'a>, + args: GenericArgsRef<'a>, tcx: TyCtxt<'a>, accumulator: &mut Vec<(Rc, Ty<'a>)>, ) { @@ -1823,9 +1822,9 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> { let variant = def.variants().iter().next().expect("at least one variant"); for (i, field) in variant.fields.iter().enumerate() { let field_path = Path::new_field(path.clone(), i); - let field_ty = field.ty(tcx, substs); - if let TyKind::Adt(def, substs) = field_ty.kind() { - add_leaf_fields_for(field_path, def, substs, tcx, accumulator) + let field_ty = field.ty(tcx, args); + if let TyKind::Adt(def, args) = field_ty.kind() { + add_leaf_fields_for(field_path, def, args, tcx, accumulator) } else { accumulator.push((field_path, field_ty)) } @@ -1860,16 +1859,17 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> { s_path = Path::new_field(s_path, 0); ty = self.type_visitor().remove_transparent_wrapper(ty); } - let source_rustc_type = self - .tcx - .mk_ref(*region, rustc_middle::ty::TypeAndMut { ty, mutbl: *mutbl }); + let source_rustc_type = Ty::new_ref( + self.tcx, + *region, + rustc_middle::ty::TypeAndMut { ty, mutbl: *mutbl }, + ); let s_ref_val = AbstractValue::make_reference(s_path); let source_path = Path::new_computed(s_ref_val); if self.type_visitor.is_slice_pointer(source_rustc_type.kind()) { let pointer_path = Path::new_field(source_path.clone(), 0); - let pointer_type = self - .tcx - .mk_ptr(rustc_middle::ty::TypeAndMut { ty, mutbl: *mutbl }); + let pointer_type = + Ty::new_ptr(self.tcx, rustc_middle::ty::TypeAndMut { ty, mutbl: *mutbl }); source_fields.push((pointer_path, pointer_type)); let len_path = Path::new_length(source_path); source_fields.push((len_path, self.tcx.types.usize)); @@ -1890,10 +1890,13 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> { _ => { if self.type_visitor.is_slice_pointer(source_rustc_type.kind()) { let pointer_path = Path::new_field(source_path.clone(), 0); - let pointer_type = self.tcx.mk_ptr(rustc_middle::ty::TypeAndMut { - ty: self.type_visitor.get_element_type(source_rustc_type), - mutbl: rustc_hir::Mutability::Not, - }); + let pointer_type = Ty::new_ptr( + self.tcx, + rustc_middle::ty::TypeAndMut { + ty: self.type_visitor.get_element_type(source_rustc_type), + mutbl: rustc_hir::Mutability::Not, + }, + ); source_fields.push((pointer_path, pointer_type)); let len_path = Path::new_length(source_path); source_fields.push((len_path, self.tcx.types.usize)); @@ -1932,9 +1935,11 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> { t_path = Path::new_field(t_path, 0); ty = self.type_visitor().remove_transparent_wrapper(ty); } - let target_rustc_type = self - .tcx - .mk_ref(*region, rustc_middle::ty::TypeAndMut { ty, mutbl: *mutbl }); + let target_rustc_type = Ty::new_ref( + self.tcx, + *region, + rustc_middle::ty::TypeAndMut { ty, mutbl: *mutbl }, + ); let t_ref_val = AbstractValue::make_reference(t_path); let target_path = Path::new_computed(t_ref_val); if self @@ -1942,10 +1947,13 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> { .is_slice_pointer(target_rustc_type.kind()) { let pointer_path = Path::new_field(target_path.clone(), 0); - let pointer_type = self.tcx.mk_ptr(rustc_middle::ty::TypeAndMut { - ty: self.type_visitor.get_element_type(target_rustc_type), - mutbl: rustc_hir::Mutability::Not, - }); + let pointer_type = Ty::new_ptr( + self.tcx, + rustc_middle::ty::TypeAndMut { + ty: self.type_visitor.get_element_type(target_rustc_type), + mutbl: rustc_hir::Mutability::Not, + }, + ); target_fields.push((pointer_path, pointer_type)); let len_path = Path::new_length(target_path); target_fields.push((len_path, self.tcx.types.usize)); @@ -1969,10 +1977,13 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> { .is_slice_pointer(target_rustc_type.kind()) { let pointer_path = Path::new_field(target_path.clone(), 0); - let pointer_type = self.tcx.mk_ptr(rustc_middle::ty::TypeAndMut { - ty: self.type_visitor.get_element_type(target_rustc_type), - mutbl: rustc_hir::Mutability::Not, - }); + let pointer_type = Ty::new_ptr( + self.tcx, + rustc_middle::ty::TypeAndMut { + ty: self.type_visitor.get_element_type(target_rustc_type), + mutbl: rustc_hir::Mutability::Not, + }, + ); target_fields.push((pointer_path, pointer_type)); let len_path = Path::new_length(target_path); target_fields.push((len_path, self.tcx.types.usize)); @@ -2662,18 +2673,19 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> { let union_type = self .type_visitor() .get_path_rustc_type(qualifier, self.current_span); - if let TyKind::Adt(def, substs) = union_type.kind() { - let substs = self - .type_visitor - .specialize_substs(substs, &self.type_visitor().generic_argument_map); + if let TyKind::Adt(def, args) = union_type.kind() { + let generic_args = self.type_visitor.specialize_generic_args( + args, + &self.type_visitor().generic_argument_map, + ); let source_field = def.all_fields().nth(*case_index).unwrap(); let source_type = self.type_visitor().specialize_generic_argument_type( - source_field.ty(self.tcx, substs), + source_field.ty(self.tcx, generic_args), &self.type_visitor().generic_argument_map, ); for (i, field) in def.all_fields().enumerate() { let target_type = self.type_visitor().specialize_generic_argument_type( - field.ty(self.tcx, substs), + field.ty(self.tcx, generic_args), &self.type_visitor().generic_argument_map, ); let target_path = diff --git a/checker/src/call_visitor.rs b/checker/src/call_visitor.rs index 4628c8b5..0d500404 100644 --- a/checker/src/call_visitor.rs +++ b/checker/src/call_visitor.rs @@ -12,8 +12,7 @@ use log_derive::*; use mirai_annotations::*; use rustc_hir::def_id::DefId; use rustc_middle::mir; -use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef}; -use rustc_middle::ty::{Ty, TyKind, UintTy}; +use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgsRef, Ty, TyKind, UintTy}; use rustc_target::abi::VariantIdx; use crate::abstract_value::{AbstractValue, AbstractValueTrait}; @@ -38,7 +37,7 @@ pub struct CallVisitor<'call, 'block, 'analysis, 'compilation, 'tcx> { pub callee_def_id: DefId, pub callee_func_ref: Option>, pub callee_fun_val: Rc, - pub callee_generic_arguments: Option>, + pub callee_generic_arguments: Option>, pub callee_known_name: KnownNames, pub callee_generic_argument_map: Option>>, pub unwind: mir::UnwindAction, @@ -63,7 +62,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> pub(crate) fn new( block_visitor: &'call mut BlockVisitor<'block, 'analysis, 'compilation, 'tcx>, callee_def_id: DefId, - callee_generic_arguments: Option>, + callee_generic_arguments: Option>, callee_generic_argument_map: Option>>, environment_before_call: Environment, func_const: ConstantDomain, @@ -244,7 +243,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> let resolved_ty = tcx.type_of(resolved_def_id).skip_binder(); let resolved_map = self.type_visitor().get_generic_arguments_map( resolved_def_id, - instance.substs, + instance.args, &[], ); let specialized_resolved_ty = self @@ -260,7 +259,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> .visit_function_reference( resolved_def_id, specialized_resolved_ty, - Some(instance.substs), + Some(instance.args), ) .clone(); self.callee_func_ref = if let ConstantDomain::Function(fr) = &func_const { @@ -270,10 +269,10 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> None }; self.callee_fun_val = Rc::new(func_const.into()); - self.callee_generic_arguments = Some(instance.substs); + self.callee_generic_arguments = Some(instance.args); self.callee_generic_argument_map = self.type_visitor().get_generic_arguments_map( resolved_def_id, - instance.substs, + instance.args, &self.actual_argument_types, ); if has_mir && specialized_resolved_ty.is_closure() { @@ -285,7 +284,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> .insert(0, (Path::new_parameter(1), self.callee_fun_val.clone())); self.actual_argument_types.insert( 0, - tcx.mk_mut_ref(tcx.lifetimes.re_static, specialized_resolved_ty), + Ty::new_mut_ref(tcx, tcx.lifetimes.re_static, specialized_resolved_ty), ); } } @@ -666,7 +665,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> fn handled_clone(&mut self) -> bool { precondition!(self.actual_argument_types.len() == 1); if let TyKind::Ref(_, t, _) = self.actual_argument_types[0].kind() { - if let TyKind::Adt(def, substs) = t.kind() { + if let TyKind::Adt(def, args) = t.kind() { if def.variants().is_empty() { return false; } @@ -707,9 +706,11 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> { // The caller might be able to avoid the diagnostic because it // knows the actual argument whereas here we only know the type. - let specialized_substs = self - .type_visitor() - .specialize_substs(substs, &self.callee_generic_argument_map); + let specialized_substs = + self.type_visitor().specialize_generic_args( + args, + &self.callee_generic_argument_map, + ); if !utils::are_concrete(specialized_substs) { // The clone method will not resolve, but we don't want visit_caller // to issue a diagnostic because is_zero might refine to true @@ -942,7 +943,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> .bv .cv .session - .struct_span_warn(span, msg.as_ref()); + .struct_span_warn(span, msg.to_string()); self.block_visitor.bv.emit_diagnostic(warning); } else { // If we see an unconditional panic inside a standard contract summary, @@ -967,7 +968,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> .bv .cv .session - .struct_span_warn(span, msg.as_str()); + .struct_span_warn(span, msg.to_string()); self.block_visitor.bv.emit_diagnostic(warning); } return; @@ -1015,7 +1016,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> .bv .cv .session - .struct_span_warn(span, msg.as_ref()); + .struct_span_warn(span, msg.to_string()); self.block_visitor.bv.emit_diagnostic(warning); } else { // Since the assertion occurs in code that is being used rather than @@ -1090,7 +1091,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> _ => { let warning = self.block_visitor.bv.cv.session.struct_span_warn( self.block_visitor.bv.current_span, - warning.as_ref(), + warning.to_string(), ); self.block_visitor.bv.emit_diagnostic(warning); } @@ -1254,7 +1255,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> ); // decl.ty is not type specialized actual_argument_types[0] = - tcx.mk_mut_ref(tcx.lifetimes.re_static, callee_ty); + Ty::new_mut_ref(tcx, tcx.lifetimes.re_static, callee_ty); } } } @@ -1266,31 +1267,35 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> // Get the generic argument map for the indirectly called function let generic_arguments = match callee_ty.kind() { - TyKind::Closure(_, substs) => Some(self.type_visitor().specialize_substs( - substs.as_closure().substs, + TyKind::Closure(_, args) => Some(self.type_visitor().specialize_generic_args( + args.as_closure().args, &self.type_visitor().generic_argument_map, )), - TyKind::Generator(_, substs, _) => Some(self.type_visitor().specialize_substs( - substs.as_generator().substs, + TyKind::Generator(_, args, _) => Some(self.type_visitor().specialize_generic_args( + args.as_generator().args, &self.type_visitor().generic_argument_map, )), - TyKind::FnDef(_, substs) - | TyKind::Alias( - rustc_middle::ty::Opaque, - rustc_middle::ty::AliasTy { substs, .. }, - ) => Some( - self.type_visitor() - .specialize_substs(substs, &self.type_visitor().generic_argument_map), - ), - _ => self.block_visitor.bv.cv.substs_cache.get(&def_id).cloned(), + TyKind::FnDef(_, args) + | TyKind::Alias(rustc_middle::ty::Opaque, rustc_middle::ty::AliasTy { args, .. }) => { + Some( + self.type_visitor().specialize_generic_args( + args, + &self.type_visitor().generic_argument_map, + ), + ) + } + _ => self + .block_visitor + .bv + .cv + .generic_args_cache + .get(&def_id) + .cloned(), }; - let argument_map = if let Some(substs) = generic_arguments { - self.type_visitor().get_generic_arguments_map( - def_id, - substs, - &actual_argument_types, - ) + let argument_map = if let Some(args) = generic_arguments { + self.type_visitor() + .get_generic_arguments_map(def_id, args, &actual_argument_types) } else { None }; @@ -1505,7 +1510,7 @@ impl<'call, 'block, 'analysis, 'compilation, 'tcx> format!( "the macro {} expects its first argument to be a reference to a non-reference value", if checking_presence { "has_tag! " } else { "does_not_have_tag!" }, - ).as_str(), + ), ); self.block_visitor.bv.emit_diagnostic(warning); } diff --git a/checker/src/callbacks.rs b/checker/src/callbacks.rs index 371b0b3c..a95654a5 100644 --- a/checker/src/callbacks.rs +++ b/checker/src/callbacks.rs @@ -18,6 +18,7 @@ use log_derive::*; use rustc_driver::Compilation; use rustc_interface::{interface, Queries}; use rustc_middle::ty::TyCtxt; +use rustc_session::EarlyErrorHandler; use std::cell::RefCell; use std::collections::HashMap; use std::fmt::{Debug, Formatter, Result}; @@ -97,6 +98,7 @@ impl rustc_driver::Callbacks for MiraiCallbacks { #[logfn(TRACE)] fn after_analysis<'tcx>( &mut self, + _early_error_handler: &EarlyErrorHandler, compiler: &interface::Compiler, queries: &'tcx Queries<'tcx>, ) -> Compilation { @@ -160,7 +162,7 @@ impl MiraiCallbacks { known_names_cache: KnownNamesCache::create_cache_from_language_items(), options: &std::mem::take(&mut self.options), session: compiler.session(), - substs_cache: HashMap::new(), + generic_args_cache: HashMap::new(), summary_cache: PersistentSummaryCache::new(tcx, summary_store_path), tcx, test_run: self.test_run, diff --git a/checker/src/constant_domain.rs b/checker/src/constant_domain.rs index 8d660ad4..ac060491 100644 --- a/checker/src/constant_domain.rs +++ b/checker/src/constant_domain.rs @@ -13,8 +13,7 @@ use serde::{Deserialize, Serialize}; use mirai_annotations::*; use rustc_hir::def_id::DefId; -use rustc_middle::ty::subst::SubstsRef; -use rustc_middle::ty::{Ty, TyCtxt}; +use rustc_middle::ty::{GenericArgsRef, Ty, TyCtxt}; use crate::expression::{Expression, ExpressionType}; use crate::known_names::{KnownNames, KnownNamesCache}; @@ -114,7 +113,7 @@ impl ConstantDomain { pub fn for_function<'a, 'tcx>( function_id: usize, def_id: DefId, - generic_args: Option>, + generic_args: Option>, tcx: TyCtxt<'tcx>, known_names_cache: &mut KnownNamesCache, summary_cache: &mut PersistentSummaryCache<'tcx>, @@ -1260,7 +1259,7 @@ impl<'tcx> ConstantValueCache<'tcx> { &mut self, def_id: DefId, ty: Ty<'tcx>, - generic_args: Option>, + generic_args: Option>, tcx: TyCtxt<'tcx>, known_names_cache: &mut KnownNamesCache, summary_cache: &mut PersistentSummaryCache<'tcx>, diff --git a/checker/src/crate_visitor.rs b/checker/src/crate_visitor.rs index 8bd997da..3c383aeb 100644 --- a/checker/src/crate_visitor.rs +++ b/checker/src/crate_visitor.rs @@ -22,8 +22,7 @@ use mirai_annotations::*; use rustc_errors::{Diagnostic, DiagnosticBuilder}; use rustc_hir::def_id::{DefId, DefIndex}; use rustc_middle::mir; -use rustc_middle::ty::subst::SubstsRef; -use rustc_middle::ty::{TyCtxt, UnevaluatedConst}; +use rustc_middle::ty::{GenericArgsRef, TyCtxt, UnevaluatedConst}; use rustc_session::Session; use crate::body_visitor::BodyVisitor; @@ -50,10 +49,10 @@ pub struct CrateVisitor<'compilation, 'tcx> { pub constant_value_cache: ConstantValueCache<'tcx>, pub diagnostics_for: HashMap>>, pub file_name: &'compilation str, + pub generic_args_cache: HashMap>, pub known_names_cache: KnownNamesCache, pub options: &'compilation Options, pub session: &'compilation Session, - pub substs_cache: HashMap>, pub summary_cache: PersistentSummaryCache<'tcx>, pub tcx: TyCtxt<'tcx>, pub type_cache: Rc>>, diff --git a/checker/src/expression.rs b/checker/src/expression.rs index e272df35..2fee3045 100644 --- a/checker/src/expression.rs +++ b/checker/src/expression.rs @@ -1467,7 +1467,7 @@ impl ExpressionType { U128 => tcx.types.u128, Unit => tcx.types.unit, Usize => tcx.types.usize, - ThinPointer => tcx.mk_imm_ptr(tcx.mk_unit()), + ThinPointer => Ty::new_imm_ptr(tcx, tcx.types.unit), NonPrimitive => tcx.types.trait_object_dummy_self, } } diff --git a/checker/src/fixed_point_visitor.rs b/checker/src/fixed_point_visitor.rs index 1480d1b8..101163ae 100644 --- a/checker/src/fixed_point_visitor.rs +++ b/checker/src/fixed_point_visitor.rs @@ -47,7 +47,7 @@ impl<'fixed, 'analysis, 'compilation, 'tcx> body_visitor: &'fixed mut BodyVisitor<'analysis, 'compilation, 'tcx>, ) -> FixedPointVisitor<'fixed, 'analysis, 'compilation, 'tcx> { let dominators = body_visitor.mir.basic_blocks.dominators(); - let (block_indices, loop_anchors) = get_sorted_block_indices(body_visitor.mir, &dominators); + let (block_indices, loop_anchors) = get_sorted_block_indices(body_visitor.mir, dominators); // in_state[bb] is the join (or widening) of the out_state values of each predecessor of bb let mut in_state: HashMap = HashMap::new(); // out_state[bb] is the environment that results from analyzing block bb, given in_state[bb] @@ -64,7 +64,7 @@ impl<'fixed, 'analysis, 'compilation, 'tcx> bv: body_visitor, block_indices, loop_anchors, - dominators, + dominators: dominators.clone(), in_state, out_state, terminator_state, diff --git a/checker/src/main.rs b/checker/src/main.rs index 3ad29e72..dda7dac0 100644 --- a/checker/src/main.rs +++ b/checker/src/main.rs @@ -26,15 +26,16 @@ use mirai::callbacks; use mirai::options::Options; use mirai::utils; use mirai_annotations::*; -use rustc_session::config::ErrorOutputType; -use rustc_session::early_error; use std::env; use std::path::Path; fn main() { + let early_error_handler = + rustc_session::EarlyErrorHandler::new(rustc_session::config::ErrorOutputType::default()); + // Initialize loggers. if env::var("RUSTC_LOG").is_ok() { - rustc_driver::init_rustc_env_logger(); + rustc_driver::init_rustc_env_logger(&early_error_handler); } if env::var("MIRAI_LOG").is_ok() { let e = env_logger::Env::new() @@ -45,7 +46,11 @@ fn main() { // Get any options specified via the MIRAI_FLAGS environment variable let mut options = Options::default(); - let rustc_args = options.parse_from_str(&env::var("MIRAI_FLAGS").unwrap_or_default(), false); + let rustc_args = options.parse_from_str( + &env::var("MIRAI_FLAGS").unwrap_or_default(), + &early_error_handler, + false, + ); info!("MIRAI options from environment: {:?}", options); // Let arguments supplied on the command line override the environment variable. @@ -53,10 +58,8 @@ fn main() { .enumerate() .map(|(i, arg)| { arg.into_string().unwrap_or_else(|arg| { - early_error( - ErrorOutputType::default(), - &format!("Argument {i} is not valid Unicode: {arg:?}"), - ) + early_error_handler + .early_error(format!("Argument {i} is not valid Unicode: {arg:?}")) }) }) .collect::>(); @@ -68,7 +71,7 @@ fn main() { args.remove(1); } - let mut rustc_command_line_arguments = options.parse(&args[1..], false); + let mut rustc_command_line_arguments = options.parse(&args[1..], &early_error_handler, false); info!("MIRAI options modified by command line: {:?}", options); rustc_driver::install_ice_hook(rustc_driver::DEFAULT_BUG_REPORT_URL, |_| ()); diff --git a/checker/src/options.rs b/checker/src/options.rs index d3f7ef80..f9a53751 100644 --- a/checker/src/options.rs +++ b/checker/src/options.rs @@ -7,8 +7,7 @@ use clap::{Arg, Command, ErrorKind}; use itertools::Itertools; use mirai_annotations::*; -use rustc_session::config::ErrorOutputType; -use rustc_session::early_error; +use rustc_session::EarlyErrorHandler; /// Creates the clap::Command metadata for argument parsing. fn make_options_parser<'help>(running_test_harness: bool) -> Command<'help> { @@ -105,21 +104,29 @@ impl Options { /// Parse options from an argument string. The argument string will be split using unix /// shell escaping rules. Any content beyond the leftmost `--` token will be returned /// (excluding this token). - pub fn parse_from_str(&mut self, s: &str, running_test_harness: bool) -> Vec { + pub fn parse_from_str( + &mut self, + s: &str, + handler: &EarlyErrorHandler, + running_test_harness: bool, + ) -> Vec { self.parse( &shellwords::split(s).unwrap_or_else(|e| { - early_error( - ErrorOutputType::default(), - &format!("Cannot parse argument string: {e:?}"), - ) + handler.early_error(format!("Cannot parse argument string: {e:?}")) }), + handler, running_test_harness, ) } /// Parses options from a list of strings. Any content beyond the leftmost `--` token /// will be returned (excluding this token). - pub fn parse(&mut self, args: &[String], running_test_harness: bool) -> Vec { + pub fn parse( + &mut self, + args: &[String], + handler: &EarlyErrorHandler, + running_test_harness: bool, + ) -> Vec { let mut mirai_args_end = args.len(); let mut rustc_args_start = 0; if let Some((p, _)) = args.iter().find_position(|s| s.as_str() == "--") { @@ -187,10 +194,7 @@ impl Options { self.max_analysis_time_for_body = match matches.value_of("body_analysis_timeout") { Some(s) => match s.parse::() { Ok(v) => v, - Err(_) => early_error( - ErrorOutputType::default(), - "--body_analysis_timeout expects an integer", - ), + Err(_) => handler.early_error("--body_analysis_timeout expects an integer"), }, None => assume_unreachable!(), } @@ -199,10 +203,7 @@ impl Options { self.max_analysis_time_for_crate = match matches.value_of("crate_analysis_timeout") { Some(s) => match s.parse::() { Ok(v) => v, - Err(_) => early_error( - ErrorOutputType::default(), - "--crate_analysis_timeout expects an integer", - ), + Err(_) => handler.early_error("--crate_analysis_timeout expects an integer"), }, None => assume_unreachable!(), } diff --git a/checker/src/path.rs b/checker/src/path.rs index ef209e50..cdbc9510 100644 --- a/checker/src/path.rs +++ b/checker/src/path.rs @@ -893,7 +893,9 @@ impl PathRefinement for Rc { } if let PathEnum::Offset { value } = &self.value { - let Expression::Offset { left, right } = &value.expression else {unreachable!()}; + let Expression::Offset { left, right } = &value.expression else { + unreachable!() + }; if let Expression::Variable { path, var_type } = &left.expression { let canonical_left_path = path.canonicalize(environment); let canonical_lef_var = diff --git a/checker/src/summaries.rs b/checker/src/summaries.rs index df3fc508..833e8176 100644 --- a/checker/src/summaries.rs +++ b/checker/src/summaries.rs @@ -346,7 +346,7 @@ fn extract_reachable_heap_allocations( } } } - heap_roots.extend(new_roots.into_iter()); + heap_roots.extend(new_roots); } } diff --git a/checker/src/type_visitor.rs b/checker/src/type_visitor.rs index 28ea002c..9e85d011 100644 --- a/checker/src/type_visitor.rs +++ b/checker/src/type_visitor.rs @@ -15,10 +15,10 @@ use mirai_annotations::*; use rustc_hir::def_id::DefId; use rustc_index::Idx; use rustc_middle::mir; -use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, SubstsRef}; use rustc_middle::ty::{ AdtDef, Const, ConstKind, ExistentialPredicate, ExistentialProjection, ExistentialTraitRef, - FnSig, ParamTy, Ty, TyCtxt, TyKind, TypeAndMut, + FnSig, GenericArg, GenericArgKind, GenericArgs, GenericArgsRef, ParamTy, Ty, TyCtxt, TyKind, + TypeAndMut, }; use rustc_target::abi::VariantIdx; @@ -42,7 +42,7 @@ impl<'tcx> Default for type_visitor::TypeCache<'tcx> { } impl<'tcx> TypeCache<'tcx> { - /// Provides a way to refer to a rustc_middle::ty::Ty via a handle that does not have + /// Provides a way to refer to a rustc_middle::ty::Ty via a handle that does not have /// a life time specifier. pub fn new() -> TypeCache<'tcx> { TypeCache { @@ -78,7 +78,7 @@ pub struct TypeVisitor<'tcx> { pub closures_being_specialized: RefCell>, pub def_id: DefId, pub generic_argument_map: Option>>, - pub generic_arguments: Option>, + pub generic_arguments: Option>, pub mir: &'tcx mir::Body<'tcx>, path_ty_cache: HashMap, Ty<'tcx>>, pub dummy_untagged_value_type: Ty<'tcx>, @@ -140,9 +140,9 @@ impl<'tcx> TypeVisitor<'tcx> { path_ty = t; } match path_ty.kind() { - TyKind::Closure(_, substs) => { - if utils::are_concrete(substs) { - for (i, ty) in substs.as_closure().upvar_tys().enumerate() { + TyKind::Closure(_, args) => { + if utils::are_concrete(args) { + for (i, ty) in args.as_closure().upvar_tys().enumerate() { let var_type = ExpressionType::from(ty.kind()); let mut qualifier = path.clone(); if is_ref { @@ -158,8 +158,8 @@ impl<'tcx> TypeVisitor<'tcx> { } } } - TyKind::Generator(_, substs, _) => { - for (i, ty) in substs.as_generator().prefix_tys().enumerate() { + TyKind::Generator(_, args, _) => { + for (i, ty) in args.as_generator().prefix_tys().enumerate() { let var_type = ExpressionType::from(ty.kind()); let mut qualifier = path.clone(); if is_ref { @@ -176,9 +176,9 @@ impl<'tcx> TypeVisitor<'tcx> { } TyKind::Alias( rustc_middle::ty::Opaque, - rustc_middle::ty::AliasTy { def_id, substs, .. }, + rustc_middle::ty::AliasTy { def_id, args, .. }, ) => { - let map = self.get_generic_arguments_map(*def_id, substs, &[]); + let map = self.get_generic_arguments_map(*def_id, args, &[]); let path_ty = self.specialize_generic_argument_type( self.tcx.type_of(*def_id).skip_binder(), &map, @@ -349,8 +349,7 @@ impl<'tcx> TypeVisitor<'tcx> { if target_type.is_never() { target_type } else { - self.tcx - .mk_imm_ref(self.tcx.lifetimes.re_erased, target_type) + Ty::new_imm_ref(self.tcx, self.tcx.lifetimes.re_erased, target_type) } } Expression::InitialParameterValue { path, .. } @@ -377,10 +376,13 @@ impl<'tcx> TypeVisitor<'tcx> { self.get_type_from_index(*type_index) } } - PathEnum::HeapBlock { .. } => self.tcx.mk_ptr(rustc_middle::ty::TypeAndMut { - ty: self.tcx.types.u8, - mutbl: rustc_hir::Mutability::Not, - }), + PathEnum::HeapBlock { .. } => Ty::new_ptr( + self.tcx, + rustc_middle::ty::TypeAndMut { + ty: self.tcx.types.u8, + mutbl: rustc_hir::Mutability::Not, + }, + ), PathEnum::Offset { value } => { if let Expression::Offset { left, .. } = &value.expression { let base_path = Path::get_as_path(left.clone()); @@ -440,7 +442,7 @@ impl<'tcx> TypeVisitor<'tcx> { } match &**selector { PathSelector::ConstantSlice { .. } => { - return self.tcx.mk_imm_ref(self.tcx.lifetimes.re_erased, t); + return Ty::new_imm_ref(self.tcx, self.tcx.lifetimes.re_erased, t); } PathSelector::Function => { return t; @@ -452,10 +454,10 @@ impl<'tcx> TypeVisitor<'tcx> { | PathSelector::Field(ordinal) => { if let TyKind::Alias( rustc_middle::ty::Opaque, - rustc_middle::ty::AliasTy { def_id, substs, .. }, + rustc_middle::ty::AliasTy { def_id, args, .. }, ) = &t.kind() { - let map = self.get_generic_arguments_map(*def_id, substs, &[]); + let map = self.get_generic_arguments_map(*def_id, args, &[]); t = self.specialize_generic_argument_type( self.tcx.type_of(*def_id).skip_binder(), &map, @@ -464,17 +466,20 @@ impl<'tcx> TypeVisitor<'tcx> { trace!("opaque type_of {:?}", t); } match t.kind() { - TyKind::Adt(def, substs) => { - return self.get_field_type(def, substs, *ordinal); + TyKind::Adt(def, args) => { + return self.get_field_type(def, args, *ordinal); } TyKind::Array(elem_ty, ..) | TyKind::Slice(elem_ty) => { match *ordinal { 0 => { // Field 0 of a sized array is a raw pointer to the array element type - return self.tcx.mk_ptr(rustc_middle::ty::TypeAndMut { - ty: *elem_ty, - mutbl: rustc_hir::Mutability::Not, - }); + return Ty::new_ptr( + self.tcx, + rustc_middle::ty::TypeAndMut { + ty: *elem_ty, + mutbl: rustc_hir::Mutability::Not, + }, + ); } 1 => { return self.tcx.types.usize; @@ -482,8 +487,8 @@ impl<'tcx> TypeVisitor<'tcx> { _ => {} } } - TyKind::Closure(def_id, substs) => { - let closure_substs = substs.as_closure(); + TyKind::Closure(def_id, args) => { + let closure_substs = args.as_closure(); if closure_substs.is_valid() { return closure_substs .upvar_tys() @@ -497,11 +502,11 @@ impl<'tcx> TypeVisitor<'tcx> { }); } } - TyKind::Generator(def_id, substs, _) => { + TyKind::Generator(def_id, args, _) => { let mut tuple_types = - substs.as_generator().state_tys(*def_id, self.tcx); + args.as_generator().state_tys(*def_id, self.tcx); if let Some(field_tys) = tuple_types.nth(*ordinal) { - return self.tcx.mk_tup_from_iter(field_tys); + return Ty::new_tup_from_iter(self.tcx, field_tys); } info!("generator field not found {:?} {:?}", def_id, ordinal); return self.tcx.types.never; @@ -511,9 +516,9 @@ impl<'tcx> TypeVisitor<'tcx> { // why would getting a field from a closure not need a deref // before the field access? I.e. is a reference to a closure // a sort of fat pointer? - if let TyKind::Closure(def_id, substs) = t.kind() { - if utils::are_concrete(substs) { - return substs + if let TyKind::Closure(def_id, args) = t.kind() { + if utils::are_concrete(args) { + return args .as_closure() .upvar_tys() .nth(*ordinal) @@ -533,10 +538,13 @@ impl<'tcx> TypeVisitor<'tcx> { match *ordinal { 0 => { // Field 0 of a str is a raw pointer to char - return self.tcx.mk_ptr(rustc_middle::ty::TypeAndMut { - ty: self.tcx.types.char, - mutbl: rustc_hir::Mutability::Not, - }); + return Ty::new_ptr( + self.tcx, + rustc_middle::ty::TypeAndMut { + ty: self.tcx.types.char, + mutbl: rustc_hir::Mutability::Not, + }, + ); } 1 => { return self.tcx.types.usize; @@ -557,10 +565,13 @@ impl<'tcx> TypeVisitor<'tcx> { match *ordinal { 0 => { // Field 0 of a slice pointer is a raw pointer to the slice element type - return self.tcx.mk_ptr(rustc_middle::ty::TypeAndMut { - ty: self.get_element_type(t), - mutbl: rustc_hir::Mutability::Mut, - }); + return Ty::new_ptr( + self.tcx, + rustc_middle::ty::TypeAndMut { + ty: self.get_element_type(t), + mutbl: rustc_hir::Mutability::Mut, + }, + ); } 1 => { return self.tcx.types.usize; @@ -603,19 +614,19 @@ impl<'tcx> TypeVisitor<'tcx> { while type_visitor::is_transparent_wrapper(t) || matches!(t.kind(), TyKind::Adt(..)) { - if let TyKind::Adt(def, substs) = t.kind() { - let substs = - self.specialize_substs(substs, &self.generic_argument_map); + if let TyKind::Adt(def, args) = t.kind() { + let args = + self.specialize_generic_args(args, &self.generic_argument_map); if !def.is_enum() { // Could be a *&S vs *&S.Field_0 confusion - t = self.get_field_type(def, substs, 0); + t = self.get_field_type(def, args, 0); continue; } if *ordinal < def.variants().len() { let variant = &def.variants()[VariantIdx::new(*ordinal)]; let field_tys = - variant.fields.iter().map(|fd| fd.ty(self.tcx, substs)); - return self.tcx.mk_tup_from_iter(field_tys); + variant.fields.iter().map(|fd| fd.ty(self.tcx, args)); + return Ty::new_tup_from_iter(self.tcx, field_tys); } if !type_visitor::is_transparent_wrapper(t) { break; @@ -637,8 +648,8 @@ impl<'tcx> TypeVisitor<'tcx> { } PathSelector::Slice(_) => { return { - let slice_ty = self.tcx.mk_slice(self.get_element_type(t)); - self.tcx.mk_mut_ref(self.tcx.lifetimes.re_static, slice_ty) + let slice_ty = Ty::new_slice(self.tcx, self.get_element_type(t)); + Ty::new_mut_ref(self.tcx, self.tcx.lifetimes.re_static, slice_ty) }; } PathSelector::TagField => { @@ -708,13 +719,13 @@ impl<'tcx> TypeVisitor<'tcx> { pub fn get_field_type( &self, def: &'tcx AdtDef, - substs: SubstsRef<'tcx>, + args: GenericArgsRef<'tcx>, ordinal: usize, ) -> Ty<'tcx> { for variant in def.variants().iter() { if ordinal < variant.fields.len() { let field = &variant.fields[ordinal.into()]; - let ft = field.ty(self.tcx, substs); + let ft = field.ty(self.tcx, args); trace!("field {:?} type is {:?}", ordinal, ft); return ft; } @@ -746,10 +757,13 @@ impl<'tcx> TypeVisitor<'tcx> { if let Some(ty) = self.path_ty_cache.get(rp) { if ty.is_adt() { let param_path = p.replace_root(arg_path, Path::new_parameter(i + 1)); - let ptr_ty = self.tcx.mk_ptr(rustc_middle::ty::TypeAndMut { - ty: *ty, - mutbl: rustc_hir::Mutability::Not, - }); + let ptr_ty = Ty::new_ptr( + self.tcx, + rustc_middle::ty::TypeAndMut { + ty: *ty, + mutbl: rustc_hir::Mutability::Not, + }, + ); result.insert(param_path, ptr_ty); } } @@ -770,7 +784,7 @@ impl<'tcx> TypeVisitor<'tcx> { pub fn get_generic_arguments_map( &self, def_id: DefId, - generic_args: SubstsRef<'tcx>, + generic_args: GenericArgsRef<'tcx>, actual_argument_types: &[Ty<'tcx>], ) -> Option>> { let mut substitution_map = self.generic_argument_map.clone(); @@ -781,7 +795,7 @@ impl<'tcx> TypeVisitor<'tcx> { // as well. This applies recursively. Note that a child cannot mask the // generic parameters of its parent with one of its own, so each parameter // definition in this iteration will have a unique name. - InternalSubsts::for_item(self.tcx, def_id, |param_def, _| { + GenericArgs::for_item(self.tcx, def_id, |param_def, _| { if let Some(gen_arg) = generic_args.get(param_def.index as usize) { let specialized_gen_arg = self.specialize_generic_argument(*gen_arg, &substitution_map); @@ -868,7 +882,8 @@ impl<'tcx> TypeVisitor<'tcx> { TyKind::Ref(region, ty, mutbl) => { if let TyKind::Param(t_par) = ty.kind() { if t_par.name.as_str() == "Self" && !self.actual_argument_types.is_empty() { - return self.tcx.mk_ref( + return Ty::new_ref( + self.tcx, *region, rustc_middle::ty::TypeAndMut { ty: self.actual_argument_types[0], @@ -927,7 +942,7 @@ impl<'tcx> TypeVisitor<'tcx> { } mir::ProjectionElem::OpaqueCast(ty) => *ty, mir::ProjectionElem::Downcast(_, ordinal) => { - if let TyKind::Adt(def, substs) = base_ty.kind() { + if let TyKind::Adt(def, args) = base_ty.kind() { if ordinal.index() >= def.variants().len() { debug!( "illegally down casting to index {} of {:?} at {:?}", @@ -936,16 +951,16 @@ impl<'tcx> TypeVisitor<'tcx> { current_span ); let variant = &def.variants().iter().last().unwrap(); - let field_tys = variant.fields.iter().map(|fd| fd.ty(self.tcx, substs)); - return self.tcx.mk_tup_from_iter(field_tys); + let field_tys = variant.fields.iter().map(|fd| fd.ty(self.tcx, args)); + return Ty::new_tup_from_iter(self.tcx, field_tys); } let variant = &def.variants()[*ordinal]; - let field_tys = variant.fields.iter().map(|fd| fd.ty(self.tcx, substs)); - return self.tcx.mk_tup_from_iter(field_tys); - } else if let TyKind::Generator(def_id, substs, ..) = base_ty.kind() { - let mut tuple_types = substs.as_generator().state_tys(*def_id, self.tcx); + let field_tys = variant.fields.iter().map(|fd| fd.ty(self.tcx, args)); + return Ty::new_tup_from_iter(self.tcx, field_tys); + } else if let TyKind::Generator(def_id, args, ..) = base_ty.kind() { + let mut tuple_types = args.as_generator().state_tys(*def_id, self.tcx); if let Some(field_tys) = tuple_types.nth(ordinal.index()) { - return self.tcx.mk_tup_from_iter(field_tys); + return Ty::new_tup_from_iter(self.tcx, field_tys); } debug!( "illegally down casting to index {} of {:?} at {:?}", @@ -988,18 +1003,21 @@ impl<'tcx> TypeVisitor<'tcx> { ty: Ty<'tcx>, ) -> std::result::Result< rustc_middle::ty::layout::TyAndLayout<'tcx>, - rustc_middle::ty::layout::LayoutError<'tcx>, + &'tcx rustc_middle::ty::layout::LayoutError<'tcx>, > { let param_env = self.get_param_env(); if utils::is_concrete(ty.kind()) { self.tcx.layout_of(param_env.and(ty)) } else { - Err(rustc_middle::ty::layout::LayoutError::Unknown(ty)) + Err(&*self + .tcx + .arena + .alloc(rustc_middle::ty::layout::LayoutError::Unknown(ty))) } } pub fn remove_transparent_wrapper(&self, ty: Ty<'tcx>) -> Ty<'tcx> { - if let TyKind::Adt(def, substs) = ty.kind() { + if let TyKind::Adt(def, args) = ty.kind() { if def.repr().transparent() { let variant_0 = VariantIdx::from_u32(0); let v = &def.variants()[variant_0]; @@ -1011,7 +1029,7 @@ impl<'tcx> TypeVisitor<'tcx> { !is_zst }); if let Some(f) = non_zst_field { - return f.ty(self.tcx, substs); + return f.ty(self.tcx, args); } } } @@ -1054,7 +1072,7 @@ impl<'tcx> TypeVisitor<'tcx> { // The projection of an associated type. For example, // `>::N`. if let TyKind::Alias(rustc_middle::ty::Projection, projection) = gen_arg_type.kind() { - let specialized_substs = self.specialize_substs(projection.substs, map); + let specialized_substs = self.specialize_generic_args(projection.args, map); let item_def_id = projection.def_id; return if utils::are_concrete(specialized_substs) { let param_env = self @@ -1068,13 +1086,11 @@ impl<'tcx> TypeVisitor<'tcx> { ) { let instance_item_def_id = instance.def.def_id(); if item_def_id == instance_item_def_id { - return self - .tcx - .mk_projection(projection.def_id, specialized_substs); + return Ty::new_projection(self.tcx, projection.def_id, specialized_substs); } let item_type = self.tcx.type_of(instance_item_def_id).skip_binder(); let map = - self.get_generic_arguments_map(instance_item_def_id, instance.substs, &[]); + self.get_generic_arguments_map(instance_item_def_id, instance.args, &[]); if item_type == gen_arg_type && map.is_none() { // Can happen if the projection just adds a life time item_type @@ -1098,15 +1114,16 @@ impl<'tcx> TypeVisitor<'tcx> { gen_arg_type } } else { - self.tcx - .mk_projection(projection.def_id, specialized_substs) + Ty::new_projection(self.tcx, projection.def_id, specialized_substs) }; } if map.is_none() { return gen_arg_type; } match gen_arg_type.kind() { - TyKind::Adt(def, substs) => self.tcx.mk_adt(*def, self.specialize_substs(substs, map)), + TyKind::Adt(def, args) => { + Ty::new_adt(self.tcx, *def, self.specialize_generic_args(args, map)) + } TyKind::Array(elem_ty, len) => { let specialized_elem_ty = self.specialize_generic_argument_type(*elem_ty, map); let specialized_len = self.specialize_const(*len, map); @@ -1115,18 +1132,22 @@ impl<'tcx> TypeVisitor<'tcx> { } TyKind::Slice(elem_ty) => { let specialized_elem_ty = self.specialize_generic_argument_type(*elem_ty, map); - self.tcx.mk_slice(specialized_elem_ty) + Ty::new_slice(self.tcx, specialized_elem_ty) } TyKind::RawPtr(rustc_middle::ty::TypeAndMut { ty, mutbl }) => { let specialized_ty = self.specialize_generic_argument_type(*ty, map); - self.tcx.mk_ptr(rustc_middle::ty::TypeAndMut { - ty: specialized_ty, - mutbl: *mutbl, - }) + Ty::new_ptr( + self.tcx, + rustc_middle::ty::TypeAndMut { + ty: specialized_ty, + mutbl: *mutbl, + }, + ) } TyKind::Ref(region, ty, mutbl) => { let specialized_ty = self.specialize_generic_argument_type(*ty, map); - self.tcx.mk_ref( + Ty::new_ref( + self.tcx, *region, rustc_middle::ty::TypeAndMut { ty: specialized_ty, @@ -1134,9 +1155,9 @@ impl<'tcx> TypeVisitor<'tcx> { }, ) } - TyKind::FnDef(def_id, substs) => self - .tcx - .mk_fn_def(*def_id, self.specialize_substs(substs, map)), + TyKind::FnDef(def_id, args) => { + Ty::new_fn_def(self.tcx, *def_id, self.specialize_generic_args(args, map)) + } TyKind::FnPtr(fn_sig) => { let map_fn_sig = |fn_sig: FnSig<'tcx>| { let specialized_inputs_and_output = self.tcx.mk_type_list_from_iter( @@ -1153,33 +1174,33 @@ impl<'tcx> TypeVisitor<'tcx> { } }; let specialized_fn_sig = fn_sig.map_bound(map_fn_sig); - self.tcx.mk_fn_ptr(specialized_fn_sig) + Ty::new_fn_ptr(self.tcx, specialized_fn_sig) } TyKind::Dynamic(predicates, region, kind) => { let specialized_predicates = predicates.iter().map( |bound_pred: rustc_middle::ty::Binder<'_, ExistentialPredicate<'tcx>>| { bound_pred.map_bound(|pred| match pred { - ExistentialPredicate::Trait(ExistentialTraitRef { def_id, substs }) => { + ExistentialPredicate::Trait(ExistentialTraitRef { def_id, args }) => { ExistentialPredicate::Trait(ExistentialTraitRef { def_id, - substs: self.specialize_substs(substs, map), + args: self.specialize_generic_args(args, map), }) } ExistentialPredicate::Projection(ExistentialProjection { def_id, - substs, + args, term, }) => { if let Some(ty) = term.ty() { ExistentialPredicate::Projection(ExistentialProjection { def_id, - substs: self.specialize_substs(substs, map), + args: self.specialize_generic_args(args, map), term: self.specialize_generic_argument_type(ty, map).into(), }) } else { ExistentialPredicate::Projection(ExistentialProjection { def_id, - substs: self.specialize_substs(substs, map), + args: self.specialize_generic_args(args, map), term, }) } @@ -1188,14 +1209,15 @@ impl<'tcx> TypeVisitor<'tcx> { }) }, ); - self.tcx.mk_dynamic( + Ty::new_dynamic( + self.tcx, self.tcx .mk_poly_existential_predicates_from_iter(specialized_predicates), *region, *kind, ) } - TyKind::Closure(def_id, substs) => { + TyKind::Closure(def_id, args) => { // Closure types can be part of their own type parameters... // so need to guard against endless recursion { @@ -1207,19 +1229,20 @@ impl<'tcx> TypeVisitor<'tcx> { return gen_arg_type; } } - let specialized_closure = self - .tcx - .mk_closure(*def_id, self.specialize_substs(substs, map)); + let specialized_closure = + Ty::new_closure(self.tcx, *def_id, self.specialize_generic_args(args, map)); let mut borrowed_closures_being_specialized = self.closures_being_specialized.borrow_mut(); let closures_being_specialized = borrowed_closures_being_specialized.deref_mut(); closures_being_specialized.remove(def_id); specialized_closure } - TyKind::Generator(def_id, substs, movability) => { - self.tcx - .mk_generator(*def_id, self.specialize_substs(substs, map), *movability) - } + TyKind::Generator(def_id, args, movability) => Ty::new_generator( + self.tcx, + *def_id, + self.specialize_generic_args(args, map), + *movability, + ), TyKind::GeneratorWitness(bound_types) => { let map_types = |types: &rustc_middle::ty::List>| { self.tcx.mk_type_list_from_iter( @@ -1229,19 +1252,18 @@ impl<'tcx> TypeVisitor<'tcx> { ) }; let specialized_types = bound_types.map_bound(map_types); - self.tcx.mk_generator_witness(specialized_types) + Ty::new_generator_witness(self.tcx, specialized_types) } - TyKind::Tuple(types) => self.tcx.mk_tup_from_iter( + TyKind::Tuple(types) => Ty::new_tup_from_iter( + self.tcx, types .iter() .map(|ty| self.specialize_generic_argument_type(ty, map)), ), TyKind::Alias( rustc_middle::ty::Opaque, - rustc_middle::ty::AliasTy { def_id, substs, .. }, - ) => self - .tcx - .mk_opaque(*def_id, self.specialize_substs(substs, map)), + rustc_middle::ty::AliasTy { def_id, args, .. }, + ) => Ty::new_opaque(self.tcx, *def_id, self.specialize_generic_args(args, map)), TyKind::Param(ParamTy { name, .. }) => { if let Some(map) = map { if let Some(gen_arg) = map.get(name) { @@ -1255,16 +1277,16 @@ impl<'tcx> TypeVisitor<'tcx> { } #[logfn_inputs(TRACE)] - pub fn specialize_substs( + pub fn specialize_generic_args( &self, - substs: SubstsRef<'tcx>, + args: GenericArgsRef<'tcx>, map: &Option>>, - ) -> SubstsRef<'tcx> { - let specialized_generic_args: Vec> = substs + ) -> GenericArgsRef<'tcx> { + let specialized_generic_args: Vec> = args .iter() .map(|gen_arg| self.specialize_generic_argument(gen_arg, map)) .collect(); - self.tcx.mk_substs(&specialized_generic_args) + self.tcx.mk_args(&specialized_generic_args) } } diff --git a/checker/src/utils.rs b/checker/src/utils.rs index e13ff209..40abc3a2 100644 --- a/checker/src/utils.rs +++ b/checker/src/utils.rs @@ -16,8 +16,9 @@ use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; use rustc_hir::Node; use rustc_middle::ty; use rustc_middle::ty::print::{FmtPrinter, Printer}; -use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; -use rustc_middle::ty::{FloatTy, IntTy, Ty, TyCtxt, TyKind, UintTy}; +use rustc_middle::ty::{ + FloatTy, GenericArgKind, GenericArgsRef, IntTy, Ty, TyCtxt, TyKind, UintTy, +}; /// Returns the location of the rust system binaries that are associated with this build of Mirai. /// The location is obtained by looking at the contents of the environmental variables that were @@ -70,10 +71,10 @@ pub fn contains_function<'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> bool { if ty.is_fn() || ty.is_closure() || ty.is_generator() { return true; } - if let TyKind::Adt(def, substs) = ty.kind() { + if let TyKind::Adt(def, args) = ty.kind() { for variant in def.variants().iter() { for (_, field) in variant.fields.iter().enumerate() { - let field_ty = field.ty(tcx, substs); + let field_ty = field.ty(tcx, args); if contains_function(field_ty, tcx) { return true; } @@ -152,7 +153,7 @@ pub fn is_trait_method(def_id: DefId, tcx: TyCtxt<'_>) -> bool { #[logfn(TRACE)] pub fn argument_types_key_str<'tcx>( tcx: TyCtxt<'tcx>, - generic_args: Option>, + generic_args: Option>, ) -> Rc { let mut result = "_".to_string(); if let Some(generic_args) = generic_args { @@ -211,7 +212,7 @@ fn append_mangled_type<'tcx>(str: &mut String, ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) TyKind::Closure(def_id, subs) => { str.push_str("closure_"); str.push_str(qualified_type_name(tcx, *def_id).as_str()); - for sub in subs.as_closure().substs { + for sub in subs.as_closure().args { if let GenericArgKind::Type(ty) = sub.unpack() { str.push('_'); append_mangled_type(str, ty, tcx); @@ -224,7 +225,7 @@ fn append_mangled_type<'tcx>(str: &mut String, ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) let principal = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), principal); str.push_str(qualified_type_name(tcx, principal.def_id).as_str()); - for sub in principal.substs { + for sub in principal.args { if let GenericArgKind::Type(ty) = sub.unpack() { str.push('_'); append_mangled_type(str, ty, tcx); @@ -249,7 +250,7 @@ fn append_mangled_type<'tcx>(str: &mut String, ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) TyKind::Generator(def_id, subs, ..) => { str.push_str("generator_"); str.push_str(qualified_type_name(tcx, *def_id).as_str()); - for sub in subs.as_generator().substs { + for sub in subs.as_generator().args { if let GenericArgKind::Type(ty) = sub.unpack() { str.push('_'); append_mangled_type(str, ty, tcx); @@ -262,13 +263,10 @@ fn append_mangled_type<'tcx>(str: &mut String, ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) append_mangled_type(str, ty, tcx) } } - TyKind::Alias( - rustc_middle::ty::Opaque, - rustc_middle::ty::AliasTy { def_id, substs, .. }, - ) => { + TyKind::Alias(rustc_middle::ty::Opaque, rustc_middle::ty::AliasTy { def_id, args, .. }) => { str.push_str("impl_"); str.push_str(qualified_type_name(tcx, *def_id).as_str()); - for sub in *substs { + for sub in *args { if let GenericArgKind::Type(ty) = sub.unpack() { str.push('_'); append_mangled_type(str, ty, tcx); @@ -446,8 +444,8 @@ pub fn def_id_as_qualified_name_str(tcx: TyCtxt<'_>, def_id: DefId) -> Rc { name.push('('); let fn_sig = if fn_ty.is_fn() { fn_ty.fn_sig(tcx).skip_binder() - } else if let ty::Closure(_, substs) = fn_ty.kind() { - substs.as_closure().sig().skip_binder() + } else if let ty::Closure(_, args) = fn_ty.kind() { + args.as_closure().sig().skip_binder() } else { unreachable!() }; @@ -480,7 +478,7 @@ pub fn def_id_display_name(tcx: TyCtxt<'_>, def_id: DefId) -> String { } /// Returns false if any of the generic arguments are themselves generic -pub fn are_concrete(gen_args: SubstsRef<'_>) -> bool { +pub fn are_concrete(gen_args: GenericArgsRef<'_>) -> bool { for gen_arg in gen_args.iter() { if let GenericArgKind::Type(ty) = gen_arg.unpack() { if !is_concrete(ty.kind()) { @@ -498,12 +496,9 @@ pub fn is_concrete(ty: &TyKind<'_>) -> bool { | TyKind::Closure(_, gen_args) | TyKind::FnDef(_, gen_args) | TyKind::Generator(_, gen_args, _) - | TyKind::Alias( - _, - rustc_middle::ty::AliasTy { - substs: gen_args, .. - }, - ) => are_concrete(gen_args), + | TyKind::Alias(_, rustc_middle::ty::AliasTy { args: gen_args, .. }) => { + are_concrete(gen_args) + } TyKind::Tuple(types) => types.iter().all(|t| is_concrete(t.kind())), TyKind::Bound(..) | TyKind::Dynamic(..) diff --git a/checker/tests/call_graph/fnptr_fold.rs b/checker/tests/call_graph/fnptr_fold.rs index 67304dae..64146c4f 100644 --- a/checker/tests/call_graph/fnptr_fold.rs +++ b/checker/tests/call_graph/fnptr_fold.rs @@ -68,10 +68,10 @@ commit; /* EXPECTED:CALL_SITES{ "files": [ "tests/call_graph/fnptr_fold.rs", - "/rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/io/stdio.rs", - "/rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/mod.rs", - "/rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/slice/mod.rs", - "/rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/ptr/metadata.rs" + "/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/std/src/io/stdio.rs", + "/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/fmt/mod.rs", + "/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/slice/mod.rs", + "/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/ptr/metadata.rs" ], "callables": [ { @@ -113,7 +113,7 @@ commit; { "name": "/core/core::slice::::len(&[T])->usize", "file_index": 3, - "first_line": 140, + "first_line": 141, "local": true }, { @@ -175,7 +175,7 @@ commit; ], [ 3, - 141, + 142, 9, 6, 7 diff --git a/checker/tests/call_graph/static_fold.rs b/checker/tests/call_graph/static_fold.rs index 544535b1..f24f7367 100644 --- a/checker/tests/call_graph/static_fold.rs +++ b/checker/tests/call_graph/static_fold.rs @@ -64,10 +64,10 @@ commit; /* EXPECTED:CALL_SITES{ "files": [ "tests/call_graph/static_fold.rs", - "/rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/std/src/io/stdio.rs", - "/rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/fmt/mod.rs", - "/rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/slice/mod.rs", - "/rustc/2f2c438dce75d8cc532c3baa849eeddc0901802c/library/core/src/ptr/metadata.rs" + "/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/std/src/io/stdio.rs", + "/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/fmt/mod.rs", + "/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/slice/mod.rs", + "/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/ptr/metadata.rs" ], "callables": [ { @@ -109,7 +109,7 @@ commit; { "name": "/core/core::slice::::len(&[T])->usize", "file_index": 3, - "first_line": 140, + "first_line": 141, "local": true }, { @@ -157,7 +157,7 @@ commit; ], [ 3, - 141, + 142, 9, 6, 7 diff --git a/checker/tests/integration_tests.rs b/checker/tests/integration_tests.rs index a0571375..244c65ac 100644 --- a/checker/tests/integration_tests.rs +++ b/checker/tests/integration_tests.rs @@ -19,6 +19,7 @@ extern crate rayon; extern crate rustc_ast; extern crate rustc_data_structures; extern crate rustc_driver; +extern crate rustc_session; extern crate tempfile; use std::collections::HashMap; @@ -31,6 +32,7 @@ use std::str::FromStr; use rayon::iter::IntoParallelIterator; use rayon::iter::ParallelIterator; use regex::Regex; +use rustc_session::*; use serde::Deserialize; use tempfile::TempDir; use walkdir::WalkDir; @@ -148,9 +150,9 @@ fn run_directory(directory_path: PathBuf) -> Vec<(String, String)> { files_and_temp_dirs } -fn build_options() -> Options { +fn build_options(early_error_handler: &EarlyErrorHandler) -> Options { let mut options = Options::default(); - options.parse_from_str("", true); // get defaults + options.parse_from_str("", early_error_handler, true); // get defaults options.diag_level = DiagLevel::Paranoid; // override default options.max_analysis_time_for_body = 20; options.max_analysis_time_for_crate = 60; @@ -254,6 +256,7 @@ fn invoke_driver_on_files( // Runs the single test case found in file_name, using temp_dir_path as the place // to put compiler output, which for Mirai includes the persistent summary store. fn invoke_driver( + early_error_handler: &EarlyErrorHandler, file_name: String, temp_dir_path: String, sys_root: String, @@ -265,7 +268,8 @@ fn invoke_driver( let file_content = read_to_string(Path::new(&file_name)).unwrap(); let options_re = Regex::new(r"(?m)^\s*//\s*MIRAI_FLAGS\s(?P.*)$").unwrap(); if let Some(captures) = options_re.captures(&file_content) { - rustc_args = options.parse_from_str(&captures["flags"], true); // override based on test source + rustc_args = options.parse_from_str(&captures["flags"], early_error_handler, true); + // override based on test source } } @@ -424,9 +428,11 @@ fn check_call_graph_output( // Default test driver fn start_driver(config: DriverConfig) -> usize { + let early_error_handler = EarlyErrorHandler::new(config::ErrorOutputType::default()); let sys_root = utils::find_sysroot(); - let options = build_options(); + let options = build_options(&early_error_handler); self::invoke_driver( + &early_error_handler, config.file_name, config.temp_dir_path, sys_root, @@ -438,12 +444,14 @@ fn start_driver(config: DriverConfig) -> usize { // Test driver for call graph generation; // sets up call graph configuration. fn start_driver_call_graph(config: DriverConfig) -> usize { + let early_error_handler = EarlyErrorHandler::new(config::ErrorOutputType::default()); let sys_root = utils::find_sysroot(); - let mut options = build_options(); + let mut options = build_options(&early_error_handler); let (call_graph_config, call_graph_config_path) = generate_call_graph_config(&config.file_name, &config.temp_dir_path); options.call_graph_config = Some(call_graph_config_path); let result = self::invoke_driver( + &early_error_handler, config.file_name.clone(), config.temp_dir_path.clone(), sys_root, diff --git a/checker/tests/run-pass/crate_traversal.rs b/checker/tests/run-pass/crate_traversal.rs index c975741e..0f7a199c 100644 --- a/checker/tests/run-pass/crate_traversal.rs +++ b/checker/tests/run-pass/crate_traversal.rs @@ -92,6 +92,7 @@ fn bar() -> bool { f(&1, &-1) } +#[allow(dropping_references)] fn test7() { loop { let beacon = { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 16570262..008bdd83 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-05-09" +channel = "nightly-2023-07-28" components = [ "clippy", "rustfmt", "rustc-dev", "rust-src", "rust-std", "llvm-tools-preview" ] diff --git a/standard_contracts/src/foreign_contracts.rs b/standard_contracts/src/foreign_contracts.rs index 28e16064..63147554 100644 --- a/standard_contracts/src/foreign_contracts.rs +++ b/standard_contracts/src/foreign_contracts.rs @@ -2867,22 +2867,37 @@ pub mod core { ) { std::intrinsics::copy_nonoverlapping(src, dst, count); } - // pub fn volatile_copy_memory(dst: *mut T, src: *const T, count: usize) {} - // pub fn volatile_set_memory(dst: *mut T, val: T, count: usize) { - // *dst = val; - // } - // pub fn volatile_load(src: *const T) -> T { - // *src - // } - // pub fn volatile_store(dst: *mut T, val: T) { - // *dst = val; - // } - // pub fn unaligned_volatile_load(src: *const T) -> T { - // *src - // } - // pub fn unaligned_volatile_store(dst: *mut T, val: T) { - // *dst = val - // } + pub unsafe fn volatile_copy_memory(dst: *mut T, src: *const T, count: usize) { + std::intrinsics::copy_nonoverlapping(src, dst, count); + } + pub unsafe fn volatile_set_memory(dst: *mut T, val: T, count: usize) { + // todo: add a intrinsic function for this to MIRAI + *dst = val; + } + pub unsafe fn volatile_load(src: *const T) -> T + where + T: Copy, + { + *src + } + pub unsafe fn volatile_store(dst: *mut T, val: T) + where + T: Copy, + { + *dst = val; + } + pub unsafe fn unaligned_volatile_load(src: *const T) -> T + where + T: Copy, + { + *src + } + pub unsafe fn unaligned_volatile_store(dst: *mut T, val: T) + where + T: Copy, + { + *dst = val + } default_contract!(float_to_int_unchecked); pub fn fmaf32(a: f32, b: f32, c: f32) -> f32 {