diff --git a/CHANGELOG.md b/CHANGELOG.md index 48c68995b86..3e92832629f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,7 +46,7 @@ - ❗️ cargo-package: Disallow `package.license-file` and `package.readme` pointing to non-existent files during packaging. -- ❗️ cargo-package: generated `.cargo_vcs_info.json` is always incluced, +- ❗️ cargo-package: generated `.cargo_vcs_info.json` is always included, even when `--allow-dirty` is passed. [#13960](https://github.com/rust-lang/cargo/pull/13960) - ❗️ Disallow passing `--release`/`--debug` flag along with the `--profile` flag. diff --git a/Cargo.lock b/Cargo.lock index 5a9aced4931..a5b3703ba09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -339,7 +339,7 @@ dependencies = [ "unicode-width", "url", "walkdir", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -353,7 +353,7 @@ dependencies = [ "snapbox", "thiserror", "time", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -387,7 +387,7 @@ name = "cargo-credential-wincred" version = "0.4.8" dependencies = [ "cargo-credential", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -435,7 +435,7 @@ dependencies = [ "toml", "url", "walkdir", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -456,12 +456,12 @@ dependencies = [ "tempfile", "tracing", "walkdir", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "cargo-util-schemas" -version = "0.5.1" +version = "0.6.0" dependencies = [ "semver", "serde", @@ -539,18 +539,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.11" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" +checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.11" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" +checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" dependencies = [ "anstream", "anstyle", @@ -780,9 +780,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.73+curl-8.8.0" +version = "0.4.74+curl-8.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "450ab250ecf17227c39afb9a2dd9261dc0035cb80f2612472fc0c4aac2dcb84d" +checksum = "8af10b986114528fcdc4b63b6f5f021b7057618411046a4de2ba0f0149a097bf" dependencies = [ "cc", "libc", @@ -1087,9 +1087,9 @@ dependencies = [ [[package]] name = "gix" -version = "0.63.0" +version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "984c5018adfa7a4536ade67990b3ebc6e11ab57b3d6cd9968de0947ca99b4b06" +checksum = "d78414d29fcc82329080166077e0f7689f4016551fdb334d787c3d040fe2634f" dependencies = [ "gix-actor", "gix-attributes", @@ -1134,7 +1134,6 @@ dependencies = [ "gix-validate", "gix-worktree", "once_cell", - "parking_lot", "prodash", "smallvec", "thiserror", @@ -1142,9 +1141,9 @@ dependencies = [ [[package]] name = "gix-actor" -version = "0.31.2" +version = "0.31.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d69c59d392c7e6c94385b6fd6089d6df0fe945f32b4357687989f3aee253cd7f" +checksum = "a0e454357e34b833cc3a00b6efbbd3dd4d18b24b9fb0c023876ec2645e8aa3f2" dependencies = [ "bstr", "gix-date", @@ -1156,9 +1155,9 @@ dependencies = [ [[package]] name = "gix-attributes" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eefb48f42eac136a4a0023f49a54ec31be1c7a9589ed762c45dcb9b953f7ecc8" +checksum = "e37ce99c7e81288c28b703641b6d5d119aacc45c1a6b247156e6249afa486257" dependencies = [ "bstr", "gix-glob", @@ -1191,9 +1190,9 @@ dependencies = [ [[package]] name = "gix-command" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c22e086314095c43ffe5cdc5c0922d5439da4fd726f3b0438c56147c34dc225" +checksum = "0d76867867da891cbe32021ad454e8cae90242f6afb06762e4dd0d357afd1d7b" dependencies = [ "bstr", "gix-path", @@ -1203,9 +1202,9 @@ dependencies = [ [[package]] name = "gix-commitgraph" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b102311085da4af18823413b5176d7c500fb2272eaf391cfa8635d8bcb12c4" +checksum = "133b06f67f565836ec0c473e2116a60fb74f80b6435e21d88013ac0e3c60fc78" dependencies = [ "bstr", "gix-chunk", @@ -1217,9 +1216,9 @@ dependencies = [ [[package]] name = "gix-config" -version = "0.37.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fafe42957e11d98e354a66b6bd70aeea00faf2f62dd11164188224a507c840" +checksum = "28f53fd03d1bf09ebcc2c8654f08969439c4556e644ca925f27cf033bc43e658" dependencies = [ "bstr", "gix-config-value", @@ -1238,9 +1237,9 @@ dependencies = [ [[package]] name = "gix-config-value" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbd06203b1a9b33a78c88252a625031b094d9e1b647260070c25b09910c0a804" +checksum = "b328997d74dd15dc71b2773b162cb4af9a25c424105e4876e6d0686ab41c383e" dependencies = [ "bitflags 2.6.0", "bstr", @@ -1251,9 +1250,9 @@ dependencies = [ [[package]] name = "gix-credentials" -version = "0.24.2" +version = "0.24.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c70146183bd3c7119329a3c7392d1aa0e0adbe48d727f4df31828fe6d8fdaa1" +checksum = "198588f532e4d1202e04e6c3f50e4d7c060dffc66801c6f53cc246f1d234739e" dependencies = [ "bstr", "gix-command", @@ -1268,9 +1267,9 @@ dependencies = [ [[package]] name = "gix-date" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "367ee9093b0c2b04fd04c5c7c8b6a1082713534eab537597ae343663a518fa99" +checksum = "9eed6931f21491ee0aeb922751bd7ec97b4b2fe8fbfedcb678e2a2dce5f3b8c0" dependencies = [ "bstr", "itoa 1.0.11", @@ -1280,9 +1279,9 @@ dependencies = [ [[package]] name = "gix-diff" -version = "0.44.0" +version = "0.44.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b9bd8b2d07b6675a840b56a6c177d322d45fa082672b0dad8f063b25baf0a4" +checksum = "1996d5c8a305b59709467d80617c9fde48d9d75fd1f4179ea970912630886c9d" dependencies = [ "bstr", "gix-hash", @@ -1292,9 +1291,9 @@ dependencies = [ [[package]] name = "gix-dir" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60c99f8c545abd63abe541d20ab6cda347de406c0a3f1c80aadc12d9b0e94974" +checksum = "0c975679aa00dd2d757bfd3ddb232e8a188c0094c3306400575a0813858b1365" dependencies = [ "bstr", "gix-discover", @@ -1312,9 +1311,9 @@ dependencies = [ [[package]] name = "gix-discover" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc27c699b63da66b50d50c00668bc0b7e90c3a382ef302865e891559935f3dbf" +checksum = "67662731cec3cb31ba3ed2463809493f76d8e5d6c6d245de8b0560438c13450e" dependencies = [ "bstr", "dunce", @@ -1350,9 +1349,9 @@ dependencies = [ [[package]] name = "gix-filter" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00ce6ea5ac8fca7adbc63c48a1b9e0492c222c386aa15f513405f1003f2f4ab2" +checksum = "e6547738da28275f4dff4e9f3a0f28509f53f94dd6bd822733c91cb306bca61a" dependencies = [ "bstr", "encoding_rs", @@ -1371,9 +1370,9 @@ dependencies = [ [[package]] name = "gix-fs" -version = "0.11.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f78f7d6dcda7a5809efd73a33b145e3dce7421c460df21f32126f9732736b0c" +checksum = "6adf99c27cdf17b1c4d77680c917e0d94d8783d4e1c73d3be0d1d63107163d7a" dependencies = [ "fastrand", "gix-features", @@ -1382,9 +1381,9 @@ dependencies = [ [[package]] name = "gix-glob" -version = "0.16.2" +version = "0.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "682bdc43cb3c00dbedfcc366de2a849b582efd8d886215dbad2ea662ec156bb5" +checksum = "fa7df15afa265cc8abe92813cd354d522f1ac06b29ec6dfa163ad320575cb447" dependencies = [ "bitflags 2.6.0", "bstr", @@ -1415,9 +1414,9 @@ dependencies = [ [[package]] name = "gix-ignore" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "640dbeb4f5829f9fc14d31f654a34a0350e43a24e32d551ad130d99bf01f63f1" +checksum = "5e6afb8f98e314d4e1adc822449389ada863c174b5707cedd327d67b84dba527" dependencies = [ "bstr", "gix-glob", @@ -1428,9 +1427,9 @@ dependencies = [ [[package]] name = "gix-index" -version = "0.33.0" +version = "0.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d8c5a5f1c58edcbc5692b174cda2703aba82ed17d7176ff4c1752eb48b1b167" +checksum = "9a9a44eb55bd84bb48f8a44980e951968ced21e171b22d115d1cdcef82a7d73f" dependencies = [ "bitflags 2.6.0", "bstr", @@ -1478,9 +1477,9 @@ dependencies = [ [[package]] name = "gix-negotiate" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d57dec54544d155a495e01de947da024471e1825d7d3f2724301c07a310d6184" +checksum = "9ec879fb6307bb63519ba89be0024c6f61b4b9d61f1a91fd2ce572d89fe9c224" dependencies = [ "bitflags 2.6.0", "gix-commitgraph", @@ -1494,9 +1493,9 @@ dependencies = [ [[package]] name = "gix-object" -version = "0.42.2" +version = "0.42.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe2dc4a41191c680c942e6ebd630c8107005983c4679214fdb1007dcf5ae1df" +checksum = "25da2f46b4e7c2fa7b413ce4dffb87f69eaf89c2057e386491f4c55cadbfe386" dependencies = [ "bstr", "gix-actor", @@ -1513,9 +1512,9 @@ dependencies = [ [[package]] name = "gix-odb" -version = "0.61.0" +version = "0.61.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e92b9790e2c919166865d0825b26cc440a387c175bed1b43a2fa99c0e9d45e98" +checksum = "20d384fe541d93d8a3bb7d5d5ef210780d6df4f50c4e684ccba32665a5e3bc9b" dependencies = [ "arc-swap", "gix-date", @@ -1533,9 +1532,9 @@ dependencies = [ [[package]] name = "gix-pack" -version = "0.51.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a8da51212dbff944713edb2141ed7e002eea326b8992070374ce13a6cb610b3" +checksum = "3e0594491fffe55df94ba1c111a6566b7f56b3f8d2e1efc750e77d572f5f5229" dependencies = [ "clru", "gix-chunk", @@ -1577,9 +1576,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.10.7" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23623cf0f475691a6d943f898c4d0b89f5c1a2a64d0f92bce0e0322ee6528783" +checksum = "8d23d5bbda31344d8abc8de7c075b3cf26e5873feba7c4a15d916bce67382bd9" dependencies = [ "bstr", "gix-trace", @@ -1590,9 +1589,9 @@ dependencies = [ [[package]] name = "gix-pathspec" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76cab098dc10ba2d89f634f66bf196dea4d7db4bf10b75c7a9c201c55a2ee19" +checksum = "d307d1b8f84dc8386c4aa20ce0cf09242033840e15469a3ecba92f10cfb5c046" dependencies = [ "bitflags 2.6.0", "bstr", @@ -1605,9 +1604,9 @@ dependencies = [ [[package]] name = "gix-prompt" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fddabbc7c51c241600ab3c4623b19fa53bde7c1a2f637f61043ed5fcadf000cc" +checksum = "7e0595d2be4b6d6a71a099e989bdd610882b882da35fb8503d91d6f81aa0936f" dependencies = [ "gix-command", "gix-config-value", @@ -1618,9 +1617,9 @@ dependencies = [ [[package]] name = "gix-protocol" -version = "0.45.1" +version = "0.45.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c140d4c6d209048826bad78f021a01b612830f89da356efeb31afe8957f8bee" +checksum = "bad8da8e89f24177bd77947092199bb13dcc318bbd73530ba8a05e6d6adaaa9d" dependencies = [ "bstr", "gix-credentials", @@ -1647,12 +1646,11 @@ dependencies = [ [[package]] name = "gix-ref" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b36752b448647acd59c9668fdd830b16d07db1e6d9c3b3af105c1605a6e23d9" +checksum = "636e96a0a5562715153fee098c217110c33a6f8218f08f4687ff99afde159bb5" dependencies = [ "gix-actor", - "gix-date", "gix-features", "gix-fs", "gix-hash", @@ -1669,9 +1667,9 @@ dependencies = [ [[package]] name = "gix-refspec" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dde848865834a54fe4d9b4573f15d0e9a68eaf3d061b42d3ed52b4b8acf880b2" +checksum = "6868f8cd2e62555d1f7c78b784bece43ace40dd2a462daf3b588d5416e603f37" dependencies = [ "bstr", "gix-hash", @@ -1683,9 +1681,9 @@ dependencies = [ [[package]] name = "gix-revision" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63e08f8107ed1f93a83bcfbb4c38084c7cb3f6cd849793f1d5eec235f9b13b2b" +checksum = "01b13e43c2118c4b0537ddac7d0821ae0dfa90b7b8dbf20c711e153fb749adce" dependencies = [ "bstr", "gix-date", @@ -1699,9 +1697,9 @@ dependencies = [ [[package]] name = "gix-revwalk" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4181db9cfcd6d1d0fd258e91569dbb61f94cb788b441b5294dd7f1167a3e788f" +checksum = "1b030ccaab71af141f537e0225f19b9e74f25fefdba0372246b844491cab43e0" dependencies = [ "gix-commitgraph", "gix-date", @@ -1714,9 +1712,9 @@ dependencies = [ [[package]] name = "gix-sec" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fddc27984a643b20dd03e97790555804f98cf07404e0e552c0ad8133266a79a1" +checksum = "1547d26fa5693a7f34f05b4a3b59a90890972922172653bcb891ab3f09f436df" dependencies = [ "bitflags 2.6.0", "gix-path", @@ -1726,9 +1724,9 @@ dependencies = [ [[package]] name = "gix-submodule" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "921cd49924ac14b6611b22e5fb7bbba74d8780dc7ad26153304b64d1272460ac" +checksum = "0f2e0f69aa00805e39d39ec80472a7e9da20ed5d73318b27925a2cc198e854fd" dependencies = [ "bstr", "gix-config", @@ -1760,9 +1758,9 @@ checksum = "f924267408915fddcd558e3f37295cc7d6a3e50f8bd8b606cee0808c3915157e" [[package]] name = "gix-transport" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb0ffa5f869977f5b9566399154055902f05d7e85c787d5eacf551acdd0c4adf" +checksum = "27c02b83763ffe95bcc27ce5821b2b7f843315a009c06f1cd59c9b66c508c058" dependencies = [ "base64", "bstr", @@ -1779,9 +1777,9 @@ dependencies = [ [[package]] name = "gix-traverse" -version = "0.39.1" +version = "0.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f20cb69b63eb3e4827939f42c05b7756e3488ef49c25c412a876691d568ee2a0" +checksum = "e499a18c511e71cf4a20413b743b9f5bcf64b3d9e81e9c3c6cd399eae55a8840" dependencies = [ "bitflags 2.6.0", "gix-commitgraph", @@ -1796,9 +1794,9 @@ dependencies = [ [[package]] name = "gix-url" -version = "0.27.3" +version = "0.27.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0db829ebdca6180fbe32be7aed393591df6db4a72dbbc0b8369162390954d1cf" +checksum = "e2eb9b35bba92ea8f0b5ab406fad3cf6b87f7929aa677ff10aa042c6da621156" dependencies = [ "bstr", "gix-features", @@ -1831,9 +1829,9 @@ dependencies = [ [[package]] name = "gix-worktree" -version = "0.34.0" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53f6b7de83839274022aff92157d7505f23debf739d257984a300a35972ca94e" +checksum = "26f7326ebe0b9172220694ea69d344c536009a9b98fb0f9de092c440f3efe7a6" dependencies = [ "bstr", "gix-attributes", @@ -1965,7 +1963,7 @@ dependencies = [ name = "home" version = "0.5.11" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2034,9 +2032,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown", @@ -2171,7 +2169,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -2192,9 +2190,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.28.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c10584274047cb335c23d3e61bcef8e323adae7c5c8c760540f73610177fc3f" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" dependencies = [ "cc", "pkg-config", @@ -2923,9 +2921,9 @@ dependencies = [ [[package]] name = "rusqlite" -version = "0.31.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b838eba278d213a8beaf485bd313fd580ca4505a00d5871caeb1457c55322cae" +checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e" dependencies = [ "bitflags 2.6.0", "fallible-iterator", @@ -3116,11 +3114,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "itoa 1.0.11", + "memchr", "ryu", "serde", ] @@ -3895,6 +3894,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" diff --git a/Cargo.toml b/Cargo.toml index 951c62e3802..9dc40f90a8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ cargo-platform = { path = "crates/cargo-platform", version = "0.1.5" } cargo-test-macro = { version = "0.3.0", path = "crates/cargo-test-macro" } cargo-test-support = { version = "0.4.0", path = "crates/cargo-test-support" } cargo-util = { version = "0.2.14", path = "crates/cargo-util" } -cargo-util-schemas = { version = "0.5.0", path = "crates/cargo-util-schemas" } +cargo-util-schemas = { version = "0.6.0", path = "crates/cargo-util-schemas" } cargo_metadata = "0.18.1" clap = "4.5.11" color-print = "0.3.6" @@ -46,7 +46,7 @@ filetime = "0.2.23" flate2 = { version = "1.0.30", default-features = false, features = ["zlib"] } git2 = "0.19.0" git2-curl = "0.20.0" -gix = { version = "0.63.0", default-features = false, features = ["blocking-http-transport-curl", "progress-tree", "parallel", "dirwalk"] } +gix = { version = "0.64.0", default-features = false, features = ["blocking-http-transport-curl", "progress-tree", "parallel", "dirwalk"] } glob = "0.3.1" handlebars = { version = "5.1.2", features = ["dir_source"] } hex = "0.4.3" @@ -77,7 +77,7 @@ proptest = "1.5.0" pulldown-cmark = { version = "0.11.0", default-features = false, features = ["html"] } rand = "0.8.5" regex = "1.10.5" -rusqlite = { version = "0.31.0", features = ["bundled"] } +rusqlite = { version = "0.32.0", features = ["bundled"] } rustfix = { version = "0.8.2", path = "crates/rustfix" } same-file = "1.0.6" security-framework = "2.11.1" @@ -108,7 +108,7 @@ unicode-xid = "0.2.4" url = "2.5.2" varisat = "0.2.2" walkdir = "2.5.0" -windows-sys = "0.52" +windows-sys = "0.59" [workspace.lints.rust] rust_2018_idioms = "warn" # TODO: could this be removed? diff --git a/crates/cargo-util-schemas/Cargo.toml b/crates/cargo-util-schemas/Cargo.toml index f960213f7de..b95026ac3be 100644 --- a/crates/cargo-util-schemas/Cargo.toml +++ b/crates/cargo-util-schemas/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-util-schemas" -version = "0.5.1" +version = "0.6.0" rust-version = "1.80" # MSRV:1 edition.workspace = true license.workspace = true diff --git a/crates/cargo-util-schemas/src/manifest/mod.rs b/crates/cargo-util-schemas/src/manifest/mod.rs index fe954f0f4ca..df0bb51dcfd 100644 --- a/crates/cargo-util-schemas/src/manifest/mod.rs +++ b/crates/cargo-util-schemas/src/manifest/mod.rs @@ -106,8 +106,8 @@ impl TomlManifest { self.features.as_ref() } - pub fn resolved_lints(&self) -> Result, UnresolvedError> { - self.lints.as_ref().map(|l| l.resolved()).transpose() + pub fn normalized_lints(&self) -> Result, UnresolvedError> { + self.lints.as_ref().map(|l| l.normalized()).transpose() } } @@ -237,23 +237,26 @@ impl TomlPackage { } } - pub fn resolved_edition(&self) -> Result, UnresolvedError> { - self.edition.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_edition(&self) -> Result, UnresolvedError> { + self.edition.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_rust_version(&self) -> Result, UnresolvedError> { - self.rust_version.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_rust_version(&self) -> Result, UnresolvedError> { + self.rust_version + .as_ref() + .map(|v| v.normalized()) + .transpose() } - pub fn resolved_version(&self) -> Result, UnresolvedError> { - self.version.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_version(&self) -> Result, UnresolvedError> { + self.version.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_authors(&self) -> Result>, UnresolvedError> { - self.authors.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_authors(&self) -> Result>, UnresolvedError> { + self.authors.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_build(&self) -> Result, UnresolvedError> { + pub fn normalized_build(&self) -> Result, UnresolvedError> { let readme = self.build.as_ref().ok_or(UnresolvedError)?; match readme { StringOrBool::Bool(false) => Ok(None), @@ -262,60 +265,66 @@ impl TomlPackage { } } - pub fn resolved_exclude(&self) -> Result>, UnresolvedError> { - self.exclude.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_exclude(&self) -> Result>, UnresolvedError> { + self.exclude.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_include(&self) -> Result>, UnresolvedError> { - self.include.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_include(&self) -> Result>, UnresolvedError> { + self.include.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_publish(&self) -> Result, UnresolvedError> { - self.publish.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_publish(&self) -> Result, UnresolvedError> { + self.publish.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_description(&self) -> Result, UnresolvedError> { - self.description.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_description(&self) -> Result, UnresolvedError> { + self.description + .as_ref() + .map(|v| v.normalized()) + .transpose() } - pub fn resolved_homepage(&self) -> Result, UnresolvedError> { - self.homepage.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_homepage(&self) -> Result, UnresolvedError> { + self.homepage.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_documentation(&self) -> Result, UnresolvedError> { + pub fn normalized_documentation(&self) -> Result, UnresolvedError> { self.documentation .as_ref() - .map(|v| v.resolved()) + .map(|v| v.normalized()) .transpose() } - pub fn resolved_readme(&self) -> Result, UnresolvedError> { + pub fn normalized_readme(&self) -> Result, UnresolvedError> { let readme = self.readme.as_ref().ok_or(UnresolvedError)?; - readme.resolved().and_then(|sb| match sb { + readme.normalized().and_then(|sb| match sb { StringOrBool::Bool(false) => Ok(None), StringOrBool::Bool(true) => Err(UnresolvedError), StringOrBool::String(value) => Ok(Some(value)), }) } - pub fn resolved_keywords(&self) -> Result>, UnresolvedError> { - self.keywords.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_keywords(&self) -> Result>, UnresolvedError> { + self.keywords.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_categories(&self) -> Result>, UnresolvedError> { - self.categories.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_categories(&self) -> Result>, UnresolvedError> { + self.categories.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_license(&self) -> Result, UnresolvedError> { - self.license.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_license(&self) -> Result, UnresolvedError> { + self.license.as_ref().map(|v| v.normalized()).transpose() } - pub fn resolved_license_file(&self) -> Result, UnresolvedError> { - self.license_file.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_license_file(&self) -> Result, UnresolvedError> { + self.license_file + .as_ref() + .map(|v| v.normalized()) + .transpose() } - pub fn resolved_repository(&self) -> Result, UnresolvedError> { - self.repository.as_ref().map(|v| v.resolved()).transpose() + pub fn normalized_repository(&self) -> Result, UnresolvedError> { + self.repository.as_ref().map(|v| v.normalized()).transpose() } } @@ -330,7 +339,7 @@ pub enum InheritableField { } impl InheritableField { - pub fn resolved(&self) -> Result<&T, UnresolvedError> { + pub fn normalized(&self) -> Result<&T, UnresolvedError> { self.as_value().ok_or(UnresolvedError) } @@ -634,7 +643,7 @@ impl InheritableDependency { } } - pub fn resolved(&self) -> Result<&TomlDependency, UnresolvedError> { + pub fn normalized(&self) -> Result<&TomlDependency, UnresolvedError> { match self { InheritableDependency::Value(d) => Ok(d), InheritableDependency::Inherit(_) => Err(UnresolvedError), @@ -1440,7 +1449,7 @@ pub struct InheritableLints { } impl InheritableLints { - pub fn resolved(&self) -> Result<&TomlLints, UnresolvedError> { + pub fn normalized(&self) -> Result<&TomlLints, UnresolvedError> { if self.workspace { Err(UnresolvedError) } else { diff --git a/crates/home/src/windows.rs b/crates/home/src/windows.rs index c9a63d97b99..bd21ad085c7 100644 --- a/crates/home/src/windows.rs +++ b/crates/home/src/windows.rs @@ -20,7 +20,12 @@ pub fn home_dir_inner() -> Option { fn home_dir_crt() -> Option { unsafe { let mut path = ptr::null_mut(); - match SHGetKnownFolderPath(&FOLDERID_Profile, KF_FLAG_DONT_VERIFY as u32, 0, &mut path) { + match SHGetKnownFolderPath( + &FOLDERID_Profile, + KF_FLAG_DONT_VERIFY as u32, + std::ptr::null_mut(), + &mut path, + ) { S_OK => { let path_slice = slice::from_raw_parts(path, wcslen(path)); let s = OsString::from_wide(&path_slice); diff --git a/crates/xtask-build-man/src/main.rs b/crates/xtask-build-man/src/main.rs index 2ab3f098aaa..646610d5fa5 100644 --- a/crates/xtask-build-man/src/main.rs +++ b/crates/xtask-build-man/src/main.rs @@ -45,14 +45,14 @@ fn build_mdman() -> io::Result<()> { /// saved in the src/doc/src/commands/ directory. These are included in the /// Cargo book, which is converted to HTML by mdbook. fn build_cargo() -> io::Result<()> { - // Find all `src/doc/man/cargo-*.md` + // Find all `src/doc/man/cargo*.md` let src_paths = { let mut src_paths = Vec::new(); for entry in fs::read_dir("src/doc/man")? { let entry = entry?; let file_name = entry.file_name(); let file_name = file_name.to_str().unwrap(); - if file_name.starts_with("cargo-") && file_name.ends_with(".md") { + if file_name.starts_with("cargo") && file_name.ends_with(".md") { src_paths.push(entry.path()); } } diff --git a/src/cargo/core/compiler/fingerprint/mod.rs b/src/cargo/core/compiler/fingerprint/mod.rs index 6ffebd753cd..22ac87ba85e 100644 --- a/src/cargo/core/compiler/fingerprint/mod.rs +++ b/src/cargo/core/compiler/fingerprint/mod.rs @@ -1426,7 +1426,7 @@ fn calculate_normal( // HACK(#13975): duplicating the lookup logic here until `--check-cfg` is supported // on Cargo's MSRV and we can centralize the logic in `lints_to_rustflags` let mut lint_check_cfg = Vec::new(); - if let Ok(Some(lints)) = unit.pkg.manifest().resolved_toml().resolved_lints() { + if let Ok(Some(lints)) = unit.pkg.manifest().normalized_toml().normalized_lints() { if let Some(rust_lints) = lints.get("rust") { if let Some(unexpected_cfgs) = rust_lints.get("unexpected_cfgs") { if let Some(config) = unexpected_cfgs.config() { diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index a7b7e7b83d9..fe07c59945d 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -1355,7 +1355,7 @@ fn check_cfg_args(unit: &Unit) -> CargoResult> { ]; // Also include the custom arguments specified in `[lints.rust.unexpected_cfgs.check_cfg]` - if let Ok(Some(lints)) = unit.pkg.manifest().resolved_toml().resolved_lints() { + if let Ok(Some(lints)) = unit.pkg.manifest().normalized_toml().normalized_lints() { if let Some(rust_lints) = lints.get("rust") { if let Some(unexpected_cfgs) = rust_lints.get("unexpected_cfgs") { if let Some(config) = unexpected_cfgs.config() { diff --git a/src/cargo/core/compiler/standard_lib.rs b/src/cargo/core/compiler/standard_lib.rs index 8b24cf7cdcb..92b3474d3f0 100644 --- a/src/cargo/core/compiler/standard_lib.rs +++ b/src/cargo/core/compiler/standard_lib.rs @@ -6,13 +6,12 @@ use crate::core::compiler::{CompileKind, CompileMode, RustcTargetData, Unit}; use crate::core::profiles::{Profiles, UnitFor}; use crate::core::resolver::features::{CliFeatures, FeaturesFor, ResolvedFeatures}; use crate::core::resolver::HasDevUnits; -use crate::core::{Dependency, PackageId, PackageSet, Resolve, SourceId, Workspace}; +use crate::core::{PackageId, PackageSet, Resolve, Workspace}; use crate::ops::{self, Packages}; use crate::util::errors::CargoResult; use crate::GlobalContext; use std::collections::{HashMap, HashSet}; use std::path::PathBuf; -use std::rc::Rc; use super::BuildConfig; @@ -74,60 +73,11 @@ pub fn resolve_std<'gctx>( } let src_path = detect_sysroot_src_path(target_data)?; - let to_patch = [ - "rustc-std-workspace-core", - "rustc-std-workspace-alloc", - "rustc-std-workspace-std", - ]; - let patches = to_patch - .iter() - .map(|&name| { - let source_path = SourceId::for_path(&src_path.join("library").join(name))?; - let dep = Dependency::parse(name, None, source_path)?; - Ok(dep) - }) - .collect::>>()?; - let crates_io_url = crate::sources::CRATES_IO_INDEX.parse().unwrap(); - let patch = HashMap::from([(crates_io_url, patches)]); - let members = vec![ - String::from("library/std"), - String::from("library/core"), - String::from("library/alloc"), - String::from("library/sysroot"), - ]; - let ws_config = crate::core::WorkspaceConfig::Root(crate::core::WorkspaceRootConfig::new( - &src_path, - &Some(members), - /*default_members*/ &None, - /*exclude*/ &None, - /*inheritable*/ &None, - /*custom_metadata*/ &None, - )); - let virtual_manifest = crate::core::VirtualManifest::new( - Rc::default(), - Rc::new(toml_edit::ImDocument::parse("".to_owned()).expect("empty is valid TOML")), - Rc::default(), - Rc::default(), - /*replace*/ Vec::new(), - patch, - ws_config, - crate::core::Features::default(), - None, - ); - + let std_ws_manifest_path = src_path.join("library").join("Cargo.toml"); let gctx = ws.gctx(); - // This is a delicate hack. In order for features to resolve correctly, - // the resolver needs to run a specific "current" member of the workspace. - // Thus, in order to set the features for `std`, we need to set `sysroot` - // to be the "current" member. `sysroot` is the root, and all other - // standard library crates are dependencies from there. Since none of the - // other crates need to alter their features, this should be fine, for - // now. Perhaps in the future features will be decoupled from the resolver - // and it will be easier to control feature selection. - let current_manifest = src_path.join("library/sysroot/Cargo.toml"); // TODO: Consider doing something to enforce --locked? Or to prevent the // lock file from being written, such as setting ephemeral. - let mut std_ws = Workspace::new_virtual(src_path, current_manifest, virtual_manifest, gctx)?; + let mut std_ws = Workspace::new(&std_ws_manifest_path, gctx)?; // Don't require optional dependencies in this workspace, aka std's own // `[dev-dependencies]`. No need for us to generate a `Resolve` which has // those included because we'll never use them anyway. diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index a45a26a765f..d63dbd61de3 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -64,7 +64,7 @@ pub struct Manifest { contents: Rc, document: Rc>, original_toml: Rc, - resolved_toml: Rc, + normalized_toml: Rc, summary: Summary, // this form of manifest: @@ -110,7 +110,7 @@ pub struct VirtualManifest { contents: Rc, document: Rc>, original_toml: Rc, - resolved_toml: Rc, + normalized_toml: Rc, // this form of manifest: replace: Vec<(PackageIdSpec, Dependency)>, @@ -422,7 +422,7 @@ impl Manifest { contents: Rc, document: Rc>, original_toml: Rc, - resolved_toml: Rc, + normalized_toml: Rc, summary: Summary, default_kind: Option, @@ -451,7 +451,7 @@ impl Manifest { contents, document, original_toml, - resolved_toml, + normalized_toml, summary, default_kind, @@ -483,9 +483,9 @@ impl Manifest { pub fn contents(&self) -> &str { self.contents.as_str() } - /// See [`Manifest::resolved_toml`] for what "resolved" means - pub fn to_resolved_contents(&self) -> CargoResult { - let toml = toml::to_string_pretty(self.resolved_toml())?; + /// See [`Manifest::normalized_toml`] for what "normalized" means + pub fn to_normalized_contents(&self) -> CargoResult { + let toml = toml::to_string_pretty(self.normalized_toml())?; Ok(format!("{}\n{}", MANIFEST_PREAMBLE, toml)) } /// Collection of spans for the original TOML @@ -502,8 +502,8 @@ impl Manifest { /// useful for the operation of cargo, including /// - workspace inheritance /// - target discovery - pub fn resolved_toml(&self) -> &TomlManifest { - &self.resolved_toml + pub fn normalized_toml(&self) -> &TomlManifest { + &self.normalized_toml } pub fn summary(&self) -> &Summary { &self.summary @@ -553,7 +553,7 @@ impl Manifest { &self.warnings } pub fn profiles(&self) -> Option<&TomlProfiles> { - self.resolved_toml.profile.as_ref() + self.normalized_toml.profile.as_ref() } pub fn publish(&self) -> &Option> { &self.publish @@ -664,7 +664,7 @@ impl VirtualManifest { contents: Rc, document: Rc>, original_toml: Rc, - resolved_toml: Rc, + normalized_toml: Rc, replace: Vec<(PackageIdSpec, Dependency)>, patch: HashMap>, workspace: WorkspaceConfig, @@ -675,7 +675,7 @@ impl VirtualManifest { contents, document, original_toml, - resolved_toml, + normalized_toml, replace, patch, workspace, @@ -698,8 +698,8 @@ impl VirtualManifest { &self.original_toml } /// The [`TomlManifest`] with all fields expanded - pub fn resolved_toml(&self) -> &TomlManifest { - &self.resolved_toml + pub fn normalized_toml(&self) -> &TomlManifest { + &self.normalized_toml } pub fn replace(&self) -> &[(PackageIdSpec, Dependency)] { @@ -715,7 +715,7 @@ impl VirtualManifest { } pub fn profiles(&self) -> Option<&TomlProfiles> { - self.resolved_toml.profile.as_ref() + self.normalized_toml.profile.as_ref() } pub fn warnings_mut(&mut self) -> &mut Warnings { diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index bb866a873c9..174986ee446 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -662,7 +662,7 @@ mod imp { ptr::null_mut(), OPEN_EXISTING, 0, - 0, + std::ptr::null_mut(), ); if h == INVALID_HANDLE_VALUE { return TtyWidth::NoTty; diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 65b14233315..3a2588e412c 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -244,25 +244,6 @@ impl<'gctx> Workspace<'gctx> { } } - pub fn new_virtual( - root_path: PathBuf, - current_manifest: PathBuf, - manifest: VirtualManifest, - gctx: &'gctx GlobalContext, - ) -> CargoResult> { - let mut ws = Workspace::new_default(current_manifest, gctx); - ws.root_manifest = Some(root_path.join("Cargo.toml")); - ws.target_dir = gctx.target_dir()?; - ws.packages - .packages - .insert(root_path, MaybePackage::Virtual(manifest)); - ws.find_members()?; - ws.set_resolve_behavior()?; - // TODO: validation does not work because it walks up the directory - // tree looking for the root which is a fake file that doesn't exist. - Ok(ws) - } - /// Creates a "temporary workspace" from one package which only contains /// that package. /// @@ -1066,7 +1047,7 @@ impl<'gctx> Workspace<'gctx> { ); self.gctx.shell().warn(&msg) }; - if manifest.resolved_toml().has_profiles() { + if manifest.normalized_toml().has_profiles() { emit_warning("profiles")?; } if !manifest.replace().is_empty() { @@ -1191,7 +1172,7 @@ impl<'gctx> Workspace<'gctx> { let mut error_count = 0; let toml_lints = pkg .manifest() - .resolved_toml() + .normalized_toml() .lints .clone() .map(|lints| lints.lints) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 459e780f32f..ab4ceeb4199 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -924,7 +924,7 @@ fn tar( } FileContents::Generated(generated_kind) => { let contents = match generated_kind { - GeneratedFile::Manifest => publish_pkg.manifest().to_resolved_contents()?, + GeneratedFile::Manifest => publish_pkg.manifest().to_normalized_contents()?, GeneratedFile::Lockfile => build_lock(ws, &publish_pkg, local_reg)?, GeneratedFile::VcsInfo(ref s) => serde_json::to_string_pretty(s)?, }; diff --git a/src/cargo/ops/fix.rs b/src/cargo/ops/fix.rs index df354b36e4b..26c49088f81 100644 --- a/src/cargo/ops/fix.rs +++ b/src/cargo/ops/fix.rs @@ -443,7 +443,7 @@ fn add_feature_for_unused_deps( let manifest = pkg.manifest(); let activated_opt_deps = manifest - .resolved_toml() + .normalized_toml() .features() .map(|map| { map.values() @@ -479,7 +479,7 @@ fn add_feature_for_unused_deps( // only way to guarantee an optional dependency is available for use. // // The way we avoid implicitly creating features in Edition2024 is we remove the - // dependency from `resolved_toml` if there is no `dep:` syntax as that is the only + // dependency from `normalized_toml` if there is no `dep:` syntax as that is the only // syntax that suppresses the creation of the implicit feature. for (feature_name, activations) in features.iter_mut() { let Some(activations) = activations.as_array_mut() else { diff --git a/src/cargo/ops/registry/login.rs b/src/cargo/ops/registry/login.rs index 4087317bb28..34e78e1edc3 100644 --- a/src/cargo/ops/registry/login.rs +++ b/src/cargo/ops/registry/login.rs @@ -34,7 +34,7 @@ pub fn registry_login( false, None, ) { - Ok(registry) => Some(format!("{}/me", registry.host())), + Ok((registry, _)) => Some(format!("{}/me", registry.host())), Err(e) if e.is::() => e .downcast::() .unwrap() diff --git a/src/cargo/ops/registry/mod.rs b/src/cargo/ops/registry/mod.rs index f45947566b7..3aeecaeb8ee 100644 --- a/src/cargo/ops/registry/mod.rs +++ b/src/cargo/ops/registry/mod.rs @@ -118,14 +118,14 @@ impl RegistryCredentialConfig { /// `registry`, or `index` are set, then uses `crates-io`. /// * `force_update`: If `true`, forces the index to be updated. /// * `token_required`: If `true`, the token will be set. -fn registry( - gctx: &GlobalContext, +fn registry<'gctx>( + gctx: &'gctx GlobalContext, source_ids: &RegistrySourceIds, token_from_cmdline: Option>, reg_or_index: Option<&RegistryOrIndex>, force_update: bool, token_required: Option>, -) -> CargoResult { +) -> CargoResult<(Registry, RegistrySource<'gctx>)> { let is_index = reg_or_index.map(|v| v.is_index()).unwrap_or_default(); if is_index && token_required.is_some() && token_from_cmdline.is_none() { bail!("command-line argument --index requires --token to be specified"); @@ -134,9 +134,9 @@ fn registry( auth::cache_token_from_commandline(gctx, &source_ids.original, token); } + let mut src = RegistrySource::remote(source_ids.replacement, &HashSet::new(), gctx)?; let cfg = { let _lock = gctx.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?; - let mut src = RegistrySource::remote(source_ids.replacement, &HashSet::new(), gctx)?; // Only update the index if `force_update` is set. if force_update { src.invalidate_cache() @@ -168,11 +168,9 @@ fn registry( None }; let handle = http_handle(gctx)?; - Ok(Registry::new_handle( - api_host, - token, - handle, - cfg.auth_required, + Ok(( + Registry::new_handle(api_host, token, handle, cfg.auth_required), + src, )) } diff --git a/src/cargo/ops/registry/owner.rs b/src/cargo/ops/registry/owner.rs index a5ff86594c3..7c8246fdfbf 100644 --- a/src/cargo/ops/registry/owner.rs +++ b/src/cargo/ops/registry/owner.rs @@ -36,7 +36,7 @@ pub fn modify_owners(gctx: &GlobalContext, opts: &OwnersOptions) -> CargoResult< let operation = Operation::Owners { name: &name }; let source_ids = super::get_source_id(gctx, opts.reg_or_index.as_ref())?; - let mut registry = super::registry( + let (mut registry, _) = super::registry( gctx, &source_ids, opts.token.as_ref().map(Secret::as_deref), diff --git a/src/cargo/ops/registry/publish.rs b/src/cargo/ops/registry/publish.rs index 592a1cb0765..1124c4e14f5 100644 --- a/src/cargo/ops/registry/publish.rs +++ b/src/cargo/ops/registry/publish.rs @@ -28,6 +28,7 @@ use crate::ops; use crate::ops::PackageOpts; use crate::ops::Packages; use crate::sources::source::QueryKind; +use crate::sources::source::Source; use crate::sources::SourceConfigMap; use crate::sources::CRATES_IO_REGISTRY; use crate::util::auth; @@ -129,7 +130,7 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> { val => val, }; let source_ids = super::get_source_id(opts.gctx, reg_or_index.as_ref())?; - let mut registry = super::registry( + let (mut registry, mut source) = super::registry( opts.gctx, &source_ids, opts.token.as_ref().map(Secret::as_deref), @@ -139,6 +140,34 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> { )?; verify_dependencies(pkg, ®istry, source_ids.original)?; + // Bail before packaging and uploading if same version already exists in the registry + + let query = Dependency::parse(pkg.name(), Some(&ver), source_ids.replacement)?; + + let _lock = opts + .gctx + .acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?; + + let duplicate_query = loop { + match source.query_vec(&query, QueryKind::Exact) { + std::task::Poll::Ready(res) => { + break res?; + } + std::task::Poll::Pending => source.block_until_ready()?, + } + }; + + drop(_lock); + + if !duplicate_query.is_empty() { + bail!( + "{}@{} already exists on {}", + pkg.name(), + pkg.version(), + source.describe() + ); + } + // Prepare a tarball, with a non-suppressible warning if metadata // is missing since this is being put online. let tarball = ops::package_one( @@ -411,7 +440,7 @@ pub(crate) fn prepare_transmit( } } - let string_features = match manifest.resolved_toml().features() { + let string_features = match manifest.normalized_toml().features() { Some(features) => features .iter() .map(|(feat, values)| { diff --git a/src/cargo/ops/registry/search.rs b/src/cargo/ops/registry/search.rs index 41e12e36e46..652730f1fad 100644 --- a/src/cargo/ops/registry/search.rs +++ b/src/cargo/ops/registry/search.rs @@ -21,7 +21,7 @@ pub fn search( limit: u32, ) -> CargoResult<()> { let source_ids = super::get_source_id(gctx, reg_or_index.as_ref())?; - let mut registry = + let (mut registry, _) = super::registry(gctx, &source_ids, None, reg_or_index.as_ref(), false, None)?; let (crates, total_crates) = registry.search(query, limit).with_context(|| { format!( diff --git a/src/cargo/ops/registry/yank.rs b/src/cargo/ops/registry/yank.rs index 523c21bf84f..f46b9332f6b 100644 --- a/src/cargo/ops/registry/yank.rs +++ b/src/cargo/ops/registry/yank.rs @@ -47,7 +47,7 @@ pub fn yank( } }; let source_ids = super::get_source_id(gctx, reg_or_index.as_ref())?; - let mut registry = super::registry( + let (mut registry, _) = super::registry( gctx, &source_ids, token.as_ref().map(Secret::as_deref), diff --git a/src/cargo/ops/vendor.rs b/src/cargo/ops/vendor.rs index f319dedce38..a060b3cd6db 100644 --- a/src/cargo/ops/vendor.rs +++ b/src/cargo/ops/vendor.rs @@ -360,7 +360,7 @@ fn cp_sources( let cksum = if dst.file_name() == Some(OsStr::new("Cargo.toml")) && pkg.package_id().source_id().is_git() { - let contents = pkg.manifest().to_resolved_contents()?; + let contents = pkg.manifest().to_normalized_contents()?; copy_and_checksum( &dst, &mut dst_opts, diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 85036c8101f..4159da35275 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -880,14 +880,14 @@ fn read_packages( fn nested_paths(manifest: &Manifest) -> Vec { let mut nested_paths = Vec::new(); - let resolved = manifest.resolved_toml(); - let dependencies = resolved + let normalized = manifest.normalized_toml(); + let dependencies = normalized .dependencies .iter() - .chain(resolved.build_dependencies()) - .chain(resolved.dev_dependencies()) + .chain(normalized.build_dependencies()) + .chain(normalized.dev_dependencies()) .chain( - resolved + normalized .target .as_ref() .into_iter() diff --git a/src/cargo/util/lints.rs b/src/cargo/util/lints.rs index f443fdd6ec2..4d1b5b6de88 100644 --- a/src/cargo/util/lints.rs +++ b/src/cargo/util/lints.rs @@ -456,7 +456,7 @@ pub fn check_im_a_teapot( } if manifest - .resolved_toml() + .normalized_toml() .package() .is_some_and(|p| p.im_a_teapot.is_some()) { @@ -560,7 +560,7 @@ pub fn check_implicit_features( } let activated_opt_deps = manifest - .resolved_toml() + .normalized_toml() .features() .map(|map| { map.values() diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 76892b9d773..35318991789 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -81,7 +81,7 @@ pub fn read_manifest( .borrow_mut() .insert(package_root.to_owned(), ws_root_config.clone()); } - let resolved_toml = resolve_toml( + let normalized_toml = normalize_toml( &original_toml, &features, &workspace_config, @@ -91,12 +91,12 @@ pub fn read_manifest( &mut errors, )?; - if resolved_toml.package().is_some() { + if normalized_toml.package().is_some() { to_real_manifest( contents, document, original_toml, - resolved_toml, + normalized_toml, features, workspace_config, source_id, @@ -106,12 +106,12 @@ pub fn read_manifest( &mut errors, ) .map(EitherManifest::Real) - } else if resolved_toml.workspace.is_some() { + } else if normalized_toml.workspace.is_some() { to_virtual_manifest( contents, document, original_toml, - resolved_toml, + normalized_toml, features, workspace_config, source_id, @@ -240,30 +240,30 @@ fn to_workspace_config( } fn to_workspace_root_config( - resolved_toml: &manifest::TomlWorkspace, + normalized_toml: &manifest::TomlWorkspace, manifest_file: &Path, ) -> WorkspaceRootConfig { let package_root = manifest_file.parent().unwrap(); let inheritable = InheritableFields { - package: resolved_toml.package.clone(), - dependencies: resolved_toml.dependencies.clone(), - lints: resolved_toml.lints.clone(), + package: normalized_toml.package.clone(), + dependencies: normalized_toml.dependencies.clone(), + lints: normalized_toml.lints.clone(), _ws_root: package_root.to_owned(), }; let ws_root_config = WorkspaceRootConfig::new( package_root, - &resolved_toml.members, - &resolved_toml.default_members, - &resolved_toml.exclude, + &normalized_toml.members, + &normalized_toml.default_members, + &normalized_toml.exclude, &Some(inheritable), - &resolved_toml.metadata, + &normalized_toml.metadata, ); ws_root_config } -/// See [`Manifest::resolved_toml`] for more details +/// See [`Manifest::normalized_toml`] for more details #[tracing::instrument(skip_all)] -fn resolve_toml( +fn normalize_toml( original_toml: &manifest::TomlManifest, features: &Features, workspace_config: &WorkspaceConfig, @@ -278,7 +278,7 @@ fn resolve_toml( } } - let mut resolved_toml = manifest::TomlManifest { + let mut normalized_toml = manifest::TomlManifest { cargo_features: original_toml.cargo_features.clone(), package: None, project: None, @@ -314,26 +314,26 @@ fn resolve_toml( if let Some(original_package) = original_toml.package() { let package_name = &original_package.name; - let resolved_package = - resolve_package_toml(original_package, features, package_root, &inherit)?; - let edition = resolved_package - .resolved_edition() - .expect("previously resolved") + let normalized_package = + normalize_package_toml(original_package, features, package_root, &inherit)?; + let edition = normalized_package + .normalized_edition() + .expect("previously normalized") .map_or(Edition::default(), |e| { Edition::from_str(&e).unwrap_or_default() }); - resolved_toml.package = Some(resolved_package); + normalized_toml.package = Some(normalized_package); - resolved_toml.features = resolve_features(original_toml.features.as_ref())?; + normalized_toml.features = normalize_features(original_toml.features.as_ref())?; - resolved_toml.lib = targets::resolve_lib( + normalized_toml.lib = targets::normalize_lib( original_toml.lib.as_ref(), package_root, &original_package.name, edition, warnings, )?; - resolved_toml.bin = Some(targets::resolve_bins( + normalized_toml.bin = Some(targets::normalize_bins( original_toml.bin.as_ref(), package_root, &original_package.name, @@ -341,9 +341,9 @@ fn resolve_toml( original_package.autobins, warnings, errors, - resolved_toml.lib.is_some(), + normalized_toml.lib.is_some(), )?); - resolved_toml.example = Some(targets::resolve_examples( + normalized_toml.example = Some(targets::normalize_examples( original_toml.example.as_ref(), package_root, edition, @@ -351,7 +351,7 @@ fn resolve_toml( warnings, errors, )?); - resolved_toml.test = Some(targets::resolve_tests( + normalized_toml.test = Some(targets::normalize_tests( original_toml.test.as_ref(), package_root, edition, @@ -359,7 +359,7 @@ fn resolve_toml( warnings, errors, )?); - resolved_toml.bench = Some(targets::resolve_benches( + normalized_toml.bench = Some(targets::normalize_benches( original_toml.bench.as_ref(), package_root, edition, @@ -368,7 +368,7 @@ fn resolve_toml( errors, )?); - let activated_opt_deps = resolved_toml + let activated_opt_deps = normalized_toml .features .as_ref() .map(|map| { @@ -382,7 +382,7 @@ fn resolve_toml( }) .unwrap_or_default(); - resolved_toml.dependencies = resolve_dependencies( + normalized_toml.dependencies = normalize_dependencies( gctx, edition, &features, @@ -402,7 +402,7 @@ fn resolve_toml( edition, warnings, )?; - resolved_toml.dev_dependencies = resolve_dependencies( + normalized_toml.dev_dependencies = normalize_dependencies( gctx, edition, &features, @@ -422,7 +422,7 @@ fn resolve_toml( edition, warnings, )?; - resolved_toml.build_dependencies = resolve_dependencies( + normalized_toml.build_dependencies = normalize_dependencies( gctx, edition, &features, @@ -433,9 +433,9 @@ fn resolve_toml( package_root, warnings, )?; - let mut resolved_target = BTreeMap::new(); + let mut normalized_target = BTreeMap::new(); for (name, platform) in original_toml.target.iter().flatten() { - let resolved_dependencies = resolve_dependencies( + let normalized_dependencies = normalize_dependencies( gctx, edition, &features, @@ -455,7 +455,7 @@ fn resolve_toml( edition, warnings, )?; - let resolved_dev_dependencies = resolve_dependencies( + let normalized_dev_dependencies = normalize_dependencies( gctx, edition, &features, @@ -475,7 +475,7 @@ fn resolve_toml( edition, warnings, )?; - let resolved_build_dependencies = resolve_dependencies( + let normalized_build_dependencies = normalize_dependencies( gctx, edition, &features, @@ -486,47 +486,47 @@ fn resolve_toml( package_root, warnings, )?; - resolved_target.insert( + normalized_target.insert( name.clone(), manifest::TomlPlatform { - dependencies: resolved_dependencies, - build_dependencies: resolved_build_dependencies, + dependencies: normalized_dependencies, + build_dependencies: normalized_build_dependencies, build_dependencies2: None, - dev_dependencies: resolved_dev_dependencies, + dev_dependencies: normalized_dev_dependencies, dev_dependencies2: None, }, ); } - resolved_toml.target = (!resolved_target.is_empty()).then_some(resolved_target); + normalized_toml.target = (!normalized_target.is_empty()).then_some(normalized_target); - let resolved_lints = original_toml + let normalized_lints = original_toml .lints .clone() .map(|value| lints_inherit_with(value, || inherit()?.lints())) .transpose()?; - resolved_toml.lints = resolved_lints.map(|lints| manifest::InheritableLints { + normalized_toml.lints = normalized_lints.map(|lints| manifest::InheritableLints { workspace: false, lints, }); - resolved_toml.badges = original_toml.badges.clone(); + normalized_toml.badges = original_toml.badges.clone(); } else { for field in original_toml.requires_package() { bail!("this virtual manifest specifies a `{field}` section, which is not allowed"); } } - Ok(resolved_toml) + Ok(normalized_toml) } #[tracing::instrument(skip_all)] -fn resolve_package_toml<'a>( +fn normalize_package_toml<'a>( original_package: &manifest::TomlPackage, features: &Features, package_root: &Path, inherit: &dyn Fn() -> CargoResult<&'a InheritableFields>, ) -> CargoResult> { - let resolved_package = manifest::TomlPackage { + let normalized_package = manifest::TomlPackage { edition: original_package .edition .clone() @@ -552,7 +552,7 @@ fn resolve_package_toml<'a>( .map(|value| field_inherit_with(value, "authors", || inherit()?.authors())) .transpose()? .map(manifest::InheritableField::Value), - build: targets::resolve_build(original_package.build.as_ref(), package_root), + build: targets::normalize_build(original_package.build.as_ref(), package_root), metabuild: original_package.metabuild.clone(), default_target: original_package.default_target.clone(), forced_target: original_package.forced_target.clone(), @@ -600,7 +600,7 @@ fn resolve_package_toml<'a>( .map(|value| field_inherit_with(value, "documentation", || inherit()?.documentation())) .transpose()? .map(manifest::InheritableField::Value), - readme: resolve_package_readme( + readme: normalize_package_readme( package_root, original_package .readme @@ -654,15 +654,15 @@ fn resolve_package_toml<'a>( _invalid_cargo_features: Default::default(), }; - if resolved_package.resolver.as_deref() == Some("3") { + if normalized_package.resolver.as_deref() == Some("3") { features.require(Feature::edition2024())?; } - Ok(Box::new(resolved_package)) + Ok(Box::new(normalized_package)) } /// Returns the name of the README file for a [`manifest::TomlPackage`]. -fn resolve_package_readme( +fn normalize_package_readme( package_root: &Path, readme: Option<&manifest::StringOrBool>, ) -> Option { @@ -691,18 +691,18 @@ fn default_readme_from_package_root(package_root: &Path) -> Option { } #[tracing::instrument(skip_all)] -fn resolve_features( +fn normalize_features( original_features: Option<&BTreeMap>>, ) -> CargoResult>>> { - let Some(resolved_features) = original_features.cloned() else { + let Some(normalized_features) = original_features.cloned() else { return Ok(None); }; - Ok(Some(resolved_features)) + Ok(Some(normalized_features)) } #[tracing::instrument(skip_all)] -fn resolve_dependencies<'a>( +fn normalize_dependencies<'a>( gctx: &GlobalContext, edition: Edition, features: &Features, @@ -788,7 +788,7 @@ fn resolve_dependencies<'a>( fn load_inheritable_fields( gctx: &GlobalContext, - resolved_path: &Path, + normalized_path: &Path, workspace_config: &WorkspaceConfig, ) -> CargoResult { match workspace_config { @@ -796,7 +796,7 @@ fn load_inheritable_fields( WorkspaceConfig::Member { root: Some(ref path_to_root), } => { - let path = resolved_path + let path = normalized_path .parent() .unwrap() .join(path_to_root) @@ -805,7 +805,7 @@ fn load_inheritable_fields( inheritable_from_path(gctx, root_path) } WorkspaceConfig::Member { root: None } => { - match find_workspace_root(&resolved_path, gctx)? { + match find_workspace_root(&normalized_path, gctx)? { Some(path_to_root) => inheritable_from_path(gctx, path_to_root), None => Err(anyhow!("failed to find a workspace root")), } @@ -931,7 +931,7 @@ impl InheritableFields { /// Gets the field `workspace.package.readme`. fn readme(&self, package_root: &Path) -> CargoResult { - let Some(readme) = resolve_package_readme( + let Some(readme) = normalize_package_readme( self._ws_root.as_path(), self.package.as_ref().and_then(|p| p.readme.as_ref()), ) else { @@ -1090,7 +1090,7 @@ fn to_real_manifest( contents: String, document: toml_edit::ImDocument, original_toml: manifest::TomlManifest, - resolved_toml: manifest::TomlManifest, + normalized_toml: manifest::TomlManifest, features: Features, workspace_config: WorkspaceConfig, source_id: SourceId, @@ -1117,17 +1117,17 @@ fn to_real_manifest( features.require(Feature::open_namespaces())?; } - let resolved_package = resolved_toml + let normalized_package = normalized_toml .package() .expect("previously verified to have a `[package]`"); - let rust_version = resolved_package - .resolved_rust_version() - .expect("previously resolved") + let rust_version = normalized_package + .normalized_rust_version() + .expect("previously normalized") .cloned(); - let edition = if let Some(edition) = resolved_package - .resolved_edition() - .expect("previously resolved") + let edition = if let Some(edition) = normalized_package + .normalized_edition() + .expect("previously normalized") { let edition: Edition = edition .parse() @@ -1210,13 +1210,13 @@ fn to_real_manifest( } } - if resolved_package.metabuild.is_some() { + if normalized_package.metabuild.is_some() { features.require(Feature::metabuild())?; } let resolve_behavior = match ( - resolved_package.resolver.as_ref(), - resolved_toml + normalized_package.resolver.as_ref(), + normalized_toml .workspace .as_ref() .and_then(|ws| ws.resolver.as_ref()), @@ -1234,10 +1234,10 @@ fn to_real_manifest( let targets = to_targets( &features, &original_toml, - &resolved_toml, + &normalized_toml, package_root, edition, - &resolved_package.metabuild, + &normalized_package.metabuild, warnings, )?; @@ -1265,7 +1265,7 @@ fn to_real_manifest( }) } - if let Some(links) = &resolved_package.links { + if let Some(links) = &normalized_package.links { if !targets.iter().any(|t| t.is_custom_build()) { bail!("package specifies that it links to `{links}` but does not have a custom build script") } @@ -1318,18 +1318,22 @@ fn to_real_manifest( platform: None, root: package_root, }; - gather_dependencies(&mut manifest_ctx, resolved_toml.dependencies.as_ref(), None)?; gather_dependencies( &mut manifest_ctx, - resolved_toml.dev_dependencies(), + normalized_toml.dependencies.as_ref(), + None, + )?; + gather_dependencies( + &mut manifest_ctx, + normalized_toml.dev_dependencies(), Some(DepKind::Development), )?; gather_dependencies( &mut manifest_ctx, - resolved_toml.build_dependencies(), + normalized_toml.build_dependencies(), Some(DepKind::Build), )?; - for (name, platform) in resolved_toml.target.iter().flatten() { + for (name, platform) in normalized_toml.target.iter().flatten() { manifest_ctx.platform = Some(name.parse()?); gather_dependencies(&mut manifest_ctx, platform.dependencies.as_ref(), None)?; gather_dependencies( @@ -1343,8 +1347,8 @@ fn to_real_manifest( Some(DepKind::Development), )?; } - let replace = replace(&resolved_toml, &mut manifest_ctx)?; - let patch = patch(&resolved_toml, &mut manifest_ctx)?; + let replace = replace(&normalized_toml, &mut manifest_ctx)?; + let patch = patch(&normalized_toml, &mut manifest_ctx)?; { let mut names_sources = BTreeMap::new(); @@ -1363,78 +1367,80 @@ fn to_real_manifest( } verify_lints( - resolved_toml.resolved_lints().expect("previously resolved"), + normalized_toml + .normalized_lints() + .expect("previously normalized"), gctx, warnings, )?; let default = manifest::TomlLints::default(); let rustflags = lints_to_rustflags( - resolved_toml - .resolved_lints() - .expect("previously resolved") + normalized_toml + .normalized_lints() + .expect("previously normalized") .unwrap_or(&default), ); let metadata = ManifestMetadata { - description: resolved_package - .resolved_description() - .expect("previously resolved") + description: normalized_package + .normalized_description() + .expect("previously normalized") .cloned(), - homepage: resolved_package - .resolved_homepage() - .expect("previously resolved") + homepage: normalized_package + .normalized_homepage() + .expect("previously normalized") .cloned(), - documentation: resolved_package - .resolved_documentation() - .expect("previously resolved") + documentation: normalized_package + .normalized_documentation() + .expect("previously normalized") .cloned(), - readme: resolved_package - .resolved_readme() - .expect("previously resolved") + readme: normalized_package + .normalized_readme() + .expect("previously normalized") .cloned(), - authors: resolved_package - .resolved_authors() - .expect("previously resolved") + authors: normalized_package + .normalized_authors() + .expect("previously normalized") .cloned() .unwrap_or_default(), - license: resolved_package - .resolved_license() - .expect("previously resolved") + license: normalized_package + .normalized_license() + .expect("previously normalized") .cloned(), - license_file: resolved_package - .resolved_license_file() - .expect("previously resolved") + license_file: normalized_package + .normalized_license_file() + .expect("previously normalized") .cloned(), - repository: resolved_package - .resolved_repository() - .expect("previously resolved") + repository: normalized_package + .normalized_repository() + .expect("previously normalized") .cloned(), - keywords: resolved_package - .resolved_keywords() - .expect("previously resolved") + keywords: normalized_package + .normalized_keywords() + .expect("previously normalized") .cloned() .unwrap_or_default(), - categories: resolved_package - .resolved_categories() - .expect("previously resolved") + categories: normalized_package + .normalized_categories() + .expect("previously normalized") .cloned() .unwrap_or_default(), - badges: resolved_toml.badges.clone().unwrap_or_default(), - links: resolved_package.links.clone(), + badges: normalized_toml.badges.clone().unwrap_or_default(), + links: normalized_package.links.clone(), rust_version: rust_version.clone(), }; - if let Some(profiles) = &resolved_toml.profile { + if let Some(profiles) = &normalized_toml.profile { let cli_unstable = gctx.cli_unstable(); validate_profiles(profiles, cli_unstable, &features, warnings)?; } - let version = resolved_package - .resolved_version() - .expect("previously resolved"); - let publish = match resolved_package - .resolved_publish() - .expect("previously resolved") + let version = normalized_package + .normalized_version() + .expect("previously normalized"); + let publish = match normalized_package + .normalized_publish() + .expect("previously normalized") { Some(manifest::VecStringOrBool::VecString(ref vecstring)) => Some(vecstring.clone()), Some(manifest::VecStringOrBool::Bool(false)) => Some(vec![]), @@ -1447,7 +1453,7 @@ fn to_real_manifest( } let pkgid = PackageId::new( - resolved_package.name.as_str().into(), + normalized_package.name.as_str().into(), version .cloned() .unwrap_or_else(|| semver::Version::new(0, 0, 0)), @@ -1457,7 +1463,7 @@ fn to_real_manifest( let summary = Summary::new( pkgid, deps, - &resolved_toml + &normalized_toml .features .as_ref() .unwrap_or(&Default::default()) @@ -1469,7 +1475,7 @@ fn to_real_manifest( ) }) .collect(), - resolved_package.links.as_deref(), + normalized_package.links.as_deref(), rust_version.clone(), ); // editon2024 stops exposing implicit features, which will strip weak optional dependencies from `dependencies`, @@ -1497,7 +1503,7 @@ fn to_real_manifest( ) } - if let Some(run) = &resolved_package.default_run { + if let Some(run) = &normalized_package.default_run { if !targets .iter() .filter(|t| t.is_bin()) @@ -1509,38 +1515,38 @@ fn to_real_manifest( } } - let default_kind = resolved_package + let default_kind = normalized_package .default_target .as_ref() .map(|t| CompileTarget::new(&*t)) .transpose()? .map(CompileKind::Target); - let forced_kind = resolved_package + let forced_kind = normalized_package .forced_target .as_ref() .map(|t| CompileTarget::new(&*t)) .transpose()? .map(CompileKind::Target); - let include = resolved_package - .resolved_include() - .expect("previously resolved") + let include = normalized_package + .normalized_include() + .expect("previously normalized") .cloned() .unwrap_or_default(); - let exclude = resolved_package - .resolved_exclude() - .expect("previously resolved") + let exclude = normalized_package + .normalized_exclude() + .expect("previously normalized") .cloned() .unwrap_or_default(); - let links = resolved_package.links.clone(); - let custom_metadata = resolved_package.metadata.clone(); - let im_a_teapot = resolved_package.im_a_teapot; - let default_run = resolved_package.default_run.clone(); - let metabuild = resolved_package.metabuild.clone().map(|sov| sov.0); + let links = normalized_package.links.clone(); + let custom_metadata = normalized_package.metadata.clone(); + let im_a_teapot = normalized_package.im_a_teapot; + let default_run = normalized_package.default_run.clone(); + let metabuild = normalized_package.metabuild.clone().map(|sov| sov.0); let manifest = Manifest::new( Rc::new(contents), Rc::new(document), Rc::new(original_toml), - Rc::new(resolved_toml), + Rc::new(normalized_toml), summary, default_kind, forced_kind, @@ -1565,13 +1571,13 @@ fn to_real_manifest( embedded, ); if manifest - .resolved_toml() + .normalized_toml() .package() .unwrap() .license_file .is_some() && manifest - .resolved_toml() + .normalized_toml() .package() .unwrap() .license @@ -1677,7 +1683,7 @@ fn to_virtual_manifest( contents: String, document: toml_edit::ImDocument, original_toml: manifest::TomlManifest, - resolved_toml: manifest::TomlManifest, + normalized_toml: manifest::TomlManifest, features: Features, workspace_config: WorkspaceConfig, source_id: SourceId, @@ -1719,7 +1725,7 @@ fn to_virtual_manifest( Rc::new(contents), Rc::new(document), Rc::new(original_toml), - Rc::new(resolved_toml), + Rc::new(normalized_toml), replace, patch, workspace_config, @@ -1770,15 +1776,15 @@ struct ManifestContext<'a, 'b> { #[tracing::instrument(skip_all)] fn gather_dependencies( manifest_ctx: &mut ManifestContext<'_, '_>, - resolved_deps: Option<&BTreeMap>, + normalized_deps: Option<&BTreeMap>, kind: Option, ) -> CargoResult<()> { - let Some(dependencies) = resolved_deps else { + let Some(dependencies) = normalized_deps else { return Ok(()); }; for (n, v) in dependencies.iter() { - let resolved = v.resolved().expect("previously resolved"); + let resolved = v.normalized().expect("previously normalized"); let dep = dep_to_dependency(&resolved, n, manifest_ctx, kind)?; manifest_ctx.deps.push(dep); } @@ -2559,9 +2565,13 @@ pub fn prepare_for_publish( ) -> CargoResult { let contents = me.manifest().contents(); let document = me.manifest().document(); - let original_toml = - prepare_toml_for_publish(me.manifest().resolved_toml(), ws, me.root(), packaged_files)?; - let resolved_toml = original_toml.clone(); + let original_toml = prepare_toml_for_publish( + me.manifest().normalized_toml(), + ws, + me.root(), + packaged_files, + )?; + let normalized_toml = original_toml.clone(); let features = me.manifest().unstable_features().clone(); let workspace_config = me.manifest().workspace_config().clone(); let source_id = me.package_id().source_id(); @@ -2572,7 +2582,7 @@ pub fn prepare_for_publish( contents.to_owned(), document.clone(), original_toml, - resolved_toml, + normalized_toml, features, workspace_config, source_id, @@ -2911,11 +2921,11 @@ fn prepare_target_for_publish( context: &str, gctx: &GlobalContext, ) -> CargoResult> { - let path = target.path.as_ref().expect("previously resolved"); + let path = target.path.as_ref().expect("previously normalized"); let path = normalize_path(&path.0); if let Some(packaged_files) = packaged_files { if !packaged_files.contains(&path) { - let name = target.name.as_ref().expect("previously resolved"); + let name = target.name.as_ref().expect("previously normalized"); gctx.shell().warn(format!( "ignoring {context} `{name}` as `{}` is not included in the published package", path.display() diff --git a/src/cargo/util/toml/targets.rs b/src/cargo/util/toml/targets.rs index 5827727b9c4..5de630501da 100644 --- a/src/cargo/util/toml/targets.rs +++ b/src/cargo/util/toml/targets.rs @@ -35,7 +35,7 @@ const DEFAULT_EXAMPLE_DIR_NAME: &'static str = "examples"; pub(super) fn to_targets( features: &Features, original_toml: &TomlManifest, - resolved_toml: &TomlManifest, + normalized_toml: &TomlManifest, package_root: &Path, edition: Edition, metabuild: &Option, @@ -45,7 +45,7 @@ pub(super) fn to_targets( if let Some(target) = to_lib_target( original_toml.lib.as_ref(), - resolved_toml.lib.as_ref(), + normalized_toml.lib.as_ref(), package_root, edition, warnings, @@ -53,38 +53,38 @@ pub(super) fn to_targets( targets.push(target); } - let package = resolved_toml + let package = normalized_toml .package .as_ref() .ok_or_else(|| anyhow::format_err!("manifest has no `package` (or `project`)"))?; targets.extend(to_bin_targets( features, - resolved_toml.bin.as_deref().unwrap_or_default(), + normalized_toml.bin.as_deref().unwrap_or_default(), package_root, edition, )?); targets.extend(to_example_targets( - resolved_toml.example.as_deref().unwrap_or_default(), + normalized_toml.example.as_deref().unwrap_or_default(), package_root, edition, )?); targets.extend(to_test_targets( - resolved_toml.test.as_deref().unwrap_or_default(), + normalized_toml.test.as_deref().unwrap_or_default(), package_root, edition, )?); targets.extend(to_bench_targets( - resolved_toml.bench.as_deref().unwrap_or_default(), + normalized_toml.bench.as_deref().unwrap_or_default(), package_root, edition, )?); // processing the custom build script - if let Some(custom_build) = package.resolved_build().expect("should be resolved") { + if let Some(custom_build) = package.normalized_build().expect("previously normalized") { if metabuild.is_some() { anyhow::bail!("cannot specify both `metabuild` and `build`"); } @@ -104,7 +104,7 @@ pub(super) fn to_targets( } if let Some(metabuild) = metabuild { // Verify names match available build deps. - let bdeps = resolved_toml.build_dependencies.as_ref(); + let bdeps = normalized_toml.build_dependencies.as_ref(); for name in &metabuild.0 { if !bdeps.map_or(false, |bd| bd.contains_key(name.as_str())) { anyhow::bail!( @@ -124,7 +124,7 @@ pub(super) fn to_targets( } #[tracing::instrument(skip_all)] -pub fn resolve_lib( +pub fn normalize_lib( original_lib: Option<&TomlLibTarget>, package_root: &Path, package_name: &str, @@ -176,16 +176,16 @@ pub fn resolve_lib( #[tracing::instrument(skip_all)] fn to_lib_target( original_lib: Option<&TomlLibTarget>, - resolved_lib: Option<&TomlLibTarget>, + normalized_lib: Option<&TomlLibTarget>, package_root: &Path, edition: Edition, warnings: &mut Vec, ) -> CargoResult> { - let Some(lib) = resolved_lib else { + let Some(lib) = normalized_lib else { return Ok(None); }; - let path = lib.path.as_ref().expect("previously resolved"); + let path = lib.path.as_ref().expect("previously normalized"); let path = package_root.join(&path.0); // Per the Macros 1.1 RFC: @@ -229,7 +229,7 @@ fn to_lib_target( } #[tracing::instrument(skip_all)] -pub fn resolve_bins( +pub fn normalize_bins( toml_bins: Option<&Vec>, package_root: &Path, package_name: &str, @@ -239,7 +239,7 @@ pub fn resolve_bins( errors: &mut Vec, has_lib: bool, ) -> CargoResult> { - if is_resolved(toml_bins, autodiscover) { + if is_normalized(toml_bins, autodiscover) { let toml_bins = toml_bins.cloned().unwrap_or_default(); for bin in &toml_bins { validate_bin_name(bin, warnings)?; @@ -315,7 +315,7 @@ fn to_bin_targets( let mut result = Vec::new(); for bin in bins { - let path = package_root.join(&bin.path.as_ref().expect("previously resolved").0); + let path = package_root.join(&bin.path.as_ref().expect("previously normalized").0); let mut target = Target::bin_target( name_or_panic(bin), bin.filename.clone(), @@ -352,7 +352,7 @@ fn legacy_bin_path(package_root: &Path, name: &str, has_lib: bool) -> Option>, package_root: &Path, edition: Edition, @@ -362,7 +362,7 @@ pub fn resolve_examples( ) -> CargoResult> { let mut inferred = || infer_from_directory(&package_root, Path::new(DEFAULT_EXAMPLE_DIR_NAME)); - let targets = resolve_targets( + let targets = normalize_targets( "example", "example", toml_examples, @@ -388,7 +388,7 @@ fn to_example_targets( let mut result = Vec::new(); for toml in targets { - let path = package_root.join(&toml.path.as_ref().expect("previously resolved").0); + let path = package_root.join(&toml.path.as_ref().expect("previously normalized").0); let crate_types = match toml.crate_types() { Some(kinds) => kinds.iter().map(|s| s.into()).collect(), None => Vec::new(), @@ -409,7 +409,7 @@ fn to_example_targets( } #[tracing::instrument(skip_all)] -pub fn resolve_tests( +pub fn normalize_tests( toml_tests: Option<&Vec>, package_root: &Path, edition: Edition, @@ -419,7 +419,7 @@ pub fn resolve_tests( ) -> CargoResult> { let mut inferred = || infer_from_directory(&package_root, Path::new(DEFAULT_TEST_DIR_NAME)); - let targets = resolve_targets( + let targets = normalize_targets( "test", "test", toml_tests, @@ -445,7 +445,7 @@ fn to_test_targets( let mut result = Vec::new(); for toml in targets { - let path = package_root.join(&toml.path.as_ref().expect("previously resolved").0); + let path = package_root.join(&toml.path.as_ref().expect("previously normalized").0); let mut target = Target::test_target( name_or_panic(&toml), path, @@ -459,7 +459,7 @@ fn to_test_targets( } #[tracing::instrument(skip_all)] -pub fn resolve_benches( +pub fn normalize_benches( toml_benches: Option<&Vec>, package_root: &Path, edition: Edition, @@ -484,7 +484,7 @@ pub fn resolve_benches( let mut inferred = || infer_from_directory(&package_root, Path::new(DEFAULT_BENCH_DIR_NAME)); - let targets = resolve_targets_with_legacy_path( + let targets = normalize_targets_with_legacy_path( "benchmark", "bench", toml_benches, @@ -512,7 +512,7 @@ fn to_bench_targets( let mut result = Vec::new(); for toml in targets { - let path = package_root.join(&toml.path.as_ref().expect("previously resolved").0); + let path = package_root.join(&toml.path.as_ref().expect("previously normalized").0); let mut target = Target::bench_target( name_or_panic(&toml), path, @@ -526,7 +526,7 @@ fn to_bench_targets( Ok(result) } -fn is_resolved(toml_targets: Option<&Vec>, autodiscover: Option) -> bool { +fn is_normalized(toml_targets: Option<&Vec>, autodiscover: Option) -> bool { if autodiscover != Some(false) { return false; } @@ -539,7 +539,7 @@ fn is_resolved(toml_targets: Option<&Vec>, autodiscover: Option>, @@ -551,7 +551,7 @@ fn resolve_targets( errors: &mut Vec, autodiscover_flag_name: &str, ) -> CargoResult> { - resolve_targets_with_legacy_path( + normalize_targets_with_legacy_path( target_kind_human, target_kind, toml_targets, @@ -566,7 +566,7 @@ fn resolve_targets( ) } -fn resolve_targets_with_legacy_path( +fn normalize_targets_with_legacy_path( target_kind_human: &str, target_kind: &str, toml_targets: Option<&Vec>, @@ -579,7 +579,7 @@ fn resolve_targets_with_legacy_path( legacy_path: &mut dyn FnMut(&TomlTarget) -> Option, autodiscover_flag_name: &str, ) -> CargoResult> { - if is_resolved(toml_targets, autodiscover) { + if is_normalized(toml_targets, autodiscover) { let toml_targets = toml_targets.cloned().unwrap_or_default(); for target in &toml_targets { // Check early to improve error messages @@ -1000,7 +1000,7 @@ Cargo doesn't know which to use because multiple target files found at `{}` and /// Returns the path to the build script if one exists for this crate. #[tracing::instrument(skip_all)] -pub fn resolve_build(build: Option<&StringOrBool>, package_root: &Path) -> Option { +pub fn normalize_build(build: Option<&StringOrBool>, package_root: &Path) -> Option { const BUILD_RS: &str = "build.rs"; match build { None => { diff --git a/src/doc/man/cargo.md b/src/doc/man/cargo.md index 3b1c62e3253..fa3d8bd3bc7 100644 --- a/src/doc/man/cargo.md +++ b/src/doc/man/cargo.md @@ -56,6 +56,9 @@ available at . ### Manifest Commands +{{man "cargo-add" 1}}\ +    Add dependencies to a `Cargo.toml` manifest file. + {{man "cargo-generate-lockfile" 1}}\     Generate `Cargo.lock` for a project. @@ -68,6 +71,9 @@ available at . {{man "cargo-pkgid" 1}}\     Print a fully qualified package specification. +{{man "cargo-remove" 1}}\ +    Remove dependencies from a `Cargo.toml` manifest file. + {{man "cargo-tree" 1}}\     Display a tree visualization of a dependency graph. diff --git a/src/doc/man/generated_txt/cargo.txt b/src/doc/man/generated_txt/cargo.txt index 5c0762e6038..d9a1d1fd7af 100644 --- a/src/doc/man/generated_txt/cargo.txt +++ b/src/doc/man/generated_txt/cargo.txt @@ -50,6 +50,9 @@ COMMANDS     Execute unit and integration tests of a package. Manifest Commands + cargo-add(1) +     Add dependencies to a Cargo.toml manifest file. + cargo-generate-lockfile(1)     Generate Cargo.lock for a project. @@ -63,6 +66,9 @@ COMMANDS cargo-pkgid(1)     Print a fully qualified package specification. + cargo-remove(1) +     Remove dependencies from a Cargo.toml manifest file. + cargo-tree(1)     Display a tree visualization of a dependency graph. @@ -158,16 +164,19 @@ OPTIONS . Manifest Options - --frozen, --locked - Either of these flags requires that the Cargo.lock file is - up-to-date. If the lock file is missing, or it needs to be updated, - Cargo will exit with an error. The --frozen flag also prevents Cargo - from attempting to access the network to determine if it is - out-of-date. + --locked + Asserts that the exact same dependencies and versions are used as + when the existing Cargo.lock file was originally generated. Cargo + will exit with an error when either of the following scenarios + arises: + + o The lock file is missing. - These may be used in environments where you want to assert that the - Cargo.lock file is up-to-date (such as a CI build) or want to avoid - network access. + o Cargo attempted to change the lock file due to a different + dependency resolution. + + It may be used in environments where deterministic builds are + desired, such as in CI pipelines. --offline Prevents Cargo from accessing the network for any reason. Without @@ -184,6 +193,9 @@ OPTIONS May also be specified with the net.offline config value . + --frozen + Equivalent to specifying both --locked and --offline. + Common Options +toolchain If Cargo has been installed with rustup, and the first argument to diff --git a/src/doc/src/commands/cargo.md b/src/doc/src/commands/cargo.md index b1b07bc7021..ccba5dc446b 100644 --- a/src/doc/src/commands/cargo.md +++ b/src/doc/src/commands/cargo.md @@ -56,6 +56,9 @@ available at . ### Manifest Commands +[cargo-add(1)](cargo-add.html)\ +    Add dependencies to a `Cargo.toml` manifest file. + [cargo-generate-lockfile(1)](cargo-generate-lockfile.html)\     Generate `Cargo.lock` for a project. @@ -68,6 +71,9 @@ available at . [cargo-pkgid(1)](cargo-pkgid.html)\     Print a fully qualified package specification. +[cargo-remove(1)](cargo-remove.html)\ +    Remove dependencies from a `Cargo.toml` manifest file. + [cargo-tree(1)](cargo-tree.html)\     Display a tree visualization of a dependency graph. @@ -180,21 +186,21 @@ terminal. config value. - ### Manifest Options
-
--frozen
--locked
-
Either of these flags requires that the Cargo.lock file is -up-to-date. If the lock file is missing, or it needs to be updated, Cargo will -exit with an error. The --frozen flag also prevents Cargo from -attempting to access the network to determine if it is out-of-date.

-

These may be used in environments where you want to assert that the -Cargo.lock file is up-to-date (such as a CI build) or want to avoid network -access.

+
Asserts that the exact same dependencies and versions are used as when the +existing Cargo.lock file was originally generated. Cargo will exit with an +error when either of the following scenarios arises:

+
    +
  • The lock file is missing.
  • +
  • Cargo attempted to change the lock file due to a different dependency resolution.
  • +
+

It may be used in environments where deterministic builds are desired, +such as in CI pipelines.

--offline
@@ -210,6 +216,9 @@ offline.

May also be specified with the net.offline config value. +

--frozen
+
Equivalent to specifying both --locked and --offline.
+
### Common Options @@ -252,19 +261,16 @@ requires the -Z unstable-options flag to enable (see - ## ENVIRONMENT See [the reference](../reference/environment-variables.html) for details on environment variables that Cargo reads. - ## EXIT STATUS * `0`: Cargo succeeded. * `101`: Cargo failed to complete. - ## FILES `~/.cargo/`\ diff --git a/src/doc/src/faq.md b/src/doc/src/faq.md index e4206481cd0..8c907fbce58 100644 --- a/src/doc/src/faq.md +++ b/src/doc/src/faq.md @@ -131,8 +131,8 @@ verified against consistent versions of dependencies, like when However, this determinism can give a false sense of security because `Cargo.lock` does not affect the consumers of your package, only `Cargo.toml` does that. For example: -- [`cargo install`] will select the latest dependencies unless `--locked` is - passed in. +- [`cargo install`] will select the latest dependencies unless + `[--locked`](commands/cargo.html#option-cargo---locked) is passed in. - New dependencies, like those added with [`cargo add`], will be locked to the latest version The lockfile can also be a source of merge conflicts. @@ -174,42 +174,17 @@ but others were accidentally forgotten. ## How can Cargo work offline? -Cargo is often used in situations with limited or no network access such as -airplanes, CI environments, or embedded in large production deployments. Users -are often surprised when Cargo attempts to fetch resources from the network, and -hence the request for Cargo to work offline comes up frequently. - -Cargo, at its heart, will not attempt to access the network unless told to do -so. That is, if no crates come from crates.io, a git repository, or some other -network location, Cargo will never attempt to make a network connection. As a -result, if Cargo attempts to touch the network, then it's because it needs to -fetch a required resource. - -Cargo is also quite aggressive about caching information to minimize the amount -of network activity. It will guarantee, for example, that if `cargo build` (or -an equivalent) is run to completion then the next `cargo build` is guaranteed to -not touch the network so long as `Cargo.toml` has not been modified in the -meantime. This avoidance of the network boils down to a `Cargo.lock` existing -and a populated cache of the crates reflected in the lock file. If either of -these components are missing, then they're required for the build to succeed and -must be fetched remotely. - -As of Rust 1.11.0, Cargo understands a new flag, `--frozen`, which is an -assertion that it shouldn't touch the network. When passed, Cargo will -immediately return an error if it would otherwise attempt a network request. -The error should include contextual information about why the network request is -being made in the first place to help debug as well. Note that this flag *does -not change the behavior of Cargo*, it simply asserts that Cargo shouldn't touch -the network as a previous command has been run to ensure that network activity -shouldn't be necessary. - -The `--offline` flag was added in Rust 1.36.0. This flag tells Cargo to not -access the network, and try to proceed with available cached data if possible. -You can use [`cargo fetch`] in one project to download dependencies before -going offline, and then use those same dependencies in another project with -the `--offline` flag (or [configuration value][offline config]). - -For more information about vendoring, see documentation on [source +The [`--offline`](commands/cargo.html#option-cargo---offline) or + [`--frozen`](commands/cargo.html#option-cargo---frozen) flags tell Cargo to not + touch the network. It returns an error in case it would access the network. +You can use [`cargo fetch`] in one project to download +dependencies before going offline, and then use those same dependencies in +another project. Refer to [configuration value][offline config]) to set via +Cargo configuration. + + + +Vendoring is also related, for more information see documentation on [source replacement][replace]. [replace]: reference/source-replacement.md diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index a560f8a7f34..18be45fc2b0 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -52,12 +52,13 @@ how the feature works: ``` Each new feature described below should explain how to use it. -For the latest nightly, see the [nightly version] of this page. + +*For the latest nightly, see the [nightly version] of this page.* [config file]: config.md [nightly channel]: ../../book/appendix-07-nightly-rust.html [stabilized]: https://doc.crates.io/contrib/process/unstable.html#stabilization -[nightly version]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#script +[nightly version]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html ## List of unstable features diff --git a/src/etc/man/cargo.1 b/src/etc/man/cargo.1 index 8f61e0699f2..eebcf89e43d 100644 --- a/src/etc/man/cargo.1 +++ b/src/etc/man/cargo.1 @@ -64,6 +64,10 @@ available at \&. .br \ \ \ \ Execute unit and integration tests of a package. .SS "Manifest Commands" +\fBcargo\-add\fR(1) +.br +\ \ \ \ Add dependencies to a \fBCargo.toml\fR manifest file. +.sp \fBcargo\-generate\-lockfile\fR(1) .br \ \ \ \ Generate \fBCargo.lock\fR for a project. @@ -80,6 +84,10 @@ available at \&. .br \ \ \ \ Print a fully qualified package specification. .sp +\fBcargo\-remove\fR(1) +.br +\ \ \ \ Remove dependencies from a \fBCargo.toml\fR manifest file. +.sp \fBcargo\-tree\fR(1) .br \ \ \ \ Display a tree visualization of a dependency graph. @@ -209,17 +217,22 @@ May also be specified with the \fBterm.color\fR .RE .SS "Manifest Options" .sp -\fB\-\-frozen\fR, \fB\-\-locked\fR .RS 4 -Either of these flags requires that the \fBCargo.lock\fR file is -up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will -exit with an error. The \fB\-\-frozen\fR flag also prevents Cargo from -attempting to access the network to determine if it is out\-of\-date. +Asserts that the exact same dependencies and versions are used as when the +existing \fBCargo.lock\fR file was originally generated. Cargo will exit with an +error when either of the following scenarios arises: .sp -These may be used in environments where you want to assert that the -\fBCargo.lock\fR file is up\-to\-date (such as a CI build) or want to avoid network -access. +.RS 4 +\h'-04'\(bu\h'+02'The lock file is missing. +.RE +.sp +.RS 4 +\h'-04'\(bu\h'+02'Cargo attempted to change the lock file due to a different dependency resolution. +.RE +.sp +It may be used in environments where deterministic builds are desired, +such as in CI pipelines. .RE .sp \fB\-\-offline\fR @@ -237,6 +250,11 @@ offline. .sp May also be specified with the \fBnet.offline\fR \fIconfig value\fR \&. .RE +.sp +\fB\-\-frozen\fR +.RS 4 +Equivalent to specifying both \fB\-\-locked\fR and \fB\-\-offline\fR\&. +.RE .SS "Common Options" .sp \fB+\fR\fItoolchain\fR diff --git a/tests/build-std/main.rs b/tests/build-std/main.rs index 1075643219c..aec951a9578 100644 --- a/tests/build-std/main.rs +++ b/tests/build-std/main.rs @@ -119,8 +119,31 @@ fn basic() { "#]]) .run(); - p.cargo("run").build_std().target_host().run(); - p.cargo("test").build_std().target_host().run(); + p.cargo("run") + .build_std() + .target_host() + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] `target/[HOST_TARGET]/debug/foo` + +"#]]) + .run(); + p.cargo("test") + .build_std() + .target_host() + .with_stderr_data(str![[r#" +[COMPILING] rustc-std-workspace-std [..] +... +[COMPILING] test v0.0.0 ([..]) +[COMPILING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] unittests src/lib.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH]) +[RUNNING] unittests src/main.rs (target/[HOST_TARGET]/debug/deps/foo-[HASH]) +[RUNNING] tests/smoke.rs (target/[HOST_TARGET]/debug/deps/smoke-[HASH]) +[DOCTEST] foo + +"#]]) + .run(); // Check for hack that removes dylibs. let deps_dir = Path::new("target") diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index ebbfd81443a..93254deadb1 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -6575,7 +6575,7 @@ fn user_specific_cfgs_are_filtered_out() { ) .build(); - p.cargo("rustc -- --cfg debug_assertions --cfg proc_macro -Aunknown_lints -Aunexpected_builtin_cfgs") + p.cargo("rustc -- --cfg debug_assertions --cfg proc_macro -Aunknown_lints -Aexplicit_builtin_cfgs_in_flags") .run(); p.process(&p.bin("foo")).run(); } diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index d9911ee7400..53a618a8cfa 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -819,7 +819,7 @@ fn short_message_format() { .with_status(101) .with_stderr_data(str![[r#" [CHECKING] foo v0.0.1 ([ROOT]/foo) -src/lib.rs:1:27: error[E0308]: mismatched types +src/lib.rs:1:27: error[E0308]: mismatched types[..] [ERROR] could not compile `foo` (lib) due to 1 previous error "#]]) diff --git a/tests/testsuite/credential_process.rs b/tests/testsuite/credential_process.rs index a07006d549b..9844024125e 100644 --- a/tests/testsuite/credential_process.rs +++ b/tests/testsuite/credential_process.rs @@ -535,6 +535,17 @@ fn token_caching() { [NOTE] waiting [..] You may press ctrl-c [..] [PUBLISHED] foo v0.1.0 at registry `alternative` +"#; + let output_non_independent = r#"[UPDATING] `alternative` index +{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"read"} +[PACKAGING] foo v0.1.1 ([ROOT]/foo) +[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) +{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"publish","name":"foo","vers":"0.1.1","cksum":"[..]"} +[UPLOADING] foo v0.1.1 ([ROOT]/foo) +[UPLOADED] foo v0.1.1 to registry `alternative` +[NOTE] waiting [..] +You may press ctrl-c [..] +[PUBLISHED] foo v0.1.1 at registry `alternative` "#; // The output should contain two JSON messages from the provider in both cases: @@ -556,8 +567,21 @@ You may press ctrl-c [..] ), ); + p.change_file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.1" + edition = "2015" + description = "foo" + license = "MIT" + homepage = "https://example.com/" + "#, + ); + p.cargo("publish --registry alternative --no-verify") - .with_stderr_data(output) + .with_stderr_data(output_non_independent) .run(); } diff --git a/tests/testsuite/mock-std/Cargo.toml b/tests/testsuite/mock-std/Cargo.toml deleted file mode 100644 index a69aa4b88fa..00000000000 --- a/tests/testsuite/mock-std/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[workspace] -members = [ - "library/alloc", - "library/core", - "library/proc_macro", - "library/std", - "library/test", -] diff --git a/tests/testsuite/mock-std/library/Cargo.toml b/tests/testsuite/mock-std/library/Cargo.toml new file mode 100644 index 00000000000..f44d7bef23a --- /dev/null +++ b/tests/testsuite/mock-std/library/Cargo.toml @@ -0,0 +1,11 @@ +[workspace] +resolver = "1" +members = [ + "std", + "sysroot", +] + +[patch.crates-io] +rustc-std-workspace-core = { path = 'rustc-std-workspace-core' } +rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' } +rustc-std-workspace-std = { path = 'rustc-std-workspace-std' } diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index b6a29741a4b..bfa64261ea8 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -130,6 +130,54 @@ You may press ctrl-c to skip waiting; the crate should be available shortly. validate_upload_foo(); } +#[cargo_test] +fn duplicate_version() { + let arc: Arc> = Arc::new(Mutex::new(0)); + let registry_dupl = RegistryBuilder::new() + .http_api() + .http_index() + //.add_responder("/index/3/f/foo", move |req, server| { + // let mut lock = arc.lock().unwrap(); + //*lock += 1; + //if *lock <= 1 { + // server.not_found(req) + //} else { + // server.index(req) + //} + //}) + .build(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + license = "MIT" + description = "foo" + "#, + ) + .file("src/main.rs", "fn main() {}") + .build(); + + p.cargo("publish") + .replace_crates_io(registry_dupl.index_url()) + .without_status() + .run(); + + p.cargo("publish") + .replace_crates_io(registry_dupl.index_url()) + .with_stderr_data(str![[r#" +[UPDATING] crates.io index +[ERROR] foo@0.0.1 already exists on [..] + +"#]]) + .with_status(101) + .run(); +} + // Check that the `token` key works at the root instead of under a // `[registry]` table. #[cargo_test] diff --git a/tests/testsuite/registry_auth.rs b/tests/testsuite/registry_auth.rs index 49ff7efa2c9..2f09f78ef80 100644 --- a/tests/testsuite/registry_auth.rs +++ b/tests/testsuite/registry_auth.rs @@ -565,9 +565,10 @@ fn token_not_logged() { // 2. config.json again for verification // 3. /index/3/b/bar // 4. /dl/bar/1.0.0/download - // 5. /api/v1/crates/new - // 6. config.json for the "wait for publish" - // 7. /index/3/f/foo for the "wait for publish" - assert_eq!(authorizations.len(), 7); + // 5. /index/3/b/bar for checking existence of a duplicate version + // 6. /api/v1/crates/new + // 7. config.json for the "wait for publish" + // 8. /index/3/f/foo for the "wait for publish" + assert_eq!(authorizations.len(), 8); assert!(!log.contains("a-unique_token")); }