diff --git a/Cargo.lock b/Cargo.lock index 220494c9490e..05719666ba21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,7 +80,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -90,7 +90,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -274,7 +274,6 @@ dependencies = [ "crates-io", "curl", "curl-sys", - "env_logger", "filetime", "flate2", "fwdansi", @@ -296,14 +295,12 @@ dependencies = [ "lazycell", "libc", "libgit2-sys", - "log", "memchr", "opener", "openssl", "os_info", "pasetors", "pathdiff", - "pretty_env_logger", "pulldown-cmark", "rand", "rustfix", @@ -324,12 +321,14 @@ dependencies = [ "time", "toml", "toml_edit", + "tracing", + "tracing-subscriber", "unicase", "unicode-width", "unicode-xid", "url", "walkdir", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -339,6 +338,7 @@ dependencies = [ "anyhow", "serde", "serde_json", + "snapbox", "thiserror", "time", ] @@ -373,7 +373,7 @@ name = "cargo-credential-wincred" version = "0.3.0" dependencies = [ "cargo-credential", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -419,7 +419,7 @@ dependencies = [ "time", "toml", "url", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -432,14 +432,14 @@ dependencies = [ "hex", "jobserver", "libc", - "log", "miow", "same-file", "sha2", "shell-escape", "tempfile", + "tracing", "walkdir", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -827,19 +827,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "env_logger" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -854,7 +841,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -867,6 +854,18 @@ dependencies = [ "libc", ] +[[package]] +name = "escargot" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "768064bd3a0e2bedcba91dc87ace90beea91acc41b6a01a3ca8e9aa8827461bf" +dependencies = [ + "log", + "once_cell", + "serde", + "serde_json", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -907,7 +906,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall 0.2.16", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1763,14 +1762,14 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "home" version = "0.5.7" dependencies = [ - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1876,7 +1875,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi 0.3.1", "libc", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -1888,7 +1887,7 @@ dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", "rustix 0.37.20", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -2047,6 +2046,15 @@ version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + [[package]] name = "maybe-async" version = "0.2.7" @@ -2112,11 +2120,11 @@ dependencies = [ [[package]] name = "miow" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ffbca2f655e33c08be35d87278e5b18b89550a37dbd598c20db92f6a471123" +checksum = "359f76430b20a79f9e20e115b3428614e654f04fab314482fc0fda0ebd3c6044" dependencies = [ - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -2141,7 +2149,17 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec60c60a693226186f5d6edf073232bfb6464ed97eb22cf3b01c1e8198fd97f5" dependencies = [ - "windows-sys 0.48.0", + "windows-sys", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", ] [[package]] @@ -2281,6 +2299,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "p384" version = "0.13.0" @@ -2422,6 +2446,12 @@ dependencies = [ "sha2", ] +[[package]] +name = "pin-project-lite" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" + [[package]] name = "pkcs8" version = "0.10.2" @@ -2482,16 +2512,6 @@ dependencies = [ "yansi", ] -[[package]] -name = "pretty_env_logger" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c" -dependencies = [ - "env_logger", - "log", -] - [[package]] name = "primeorder" version = "0.13.2" @@ -2675,6 +2695,9 @@ name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] [[package]] name = "regex-syntax" @@ -2738,7 +2761,7 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -2751,7 +2774,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.5", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -2783,11 +2806,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -2936,6 +2959,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + [[package]] name = "shell-escape" version = "0.1.5" @@ -3003,6 +3035,7 @@ dependencies = [ "anstyle", "content_inspector", "dunce", + "escargot", "filetime", "normalize-line-endings", "similar", @@ -3121,7 +3154,7 @@ dependencies = [ "fastrand 2.0.0", "redox_syscall 0.3.5", "rustix 0.38.6", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -3140,7 +3173,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" dependencies = [ "rustix 0.37.20", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -3261,6 +3294,68 @@ dependencies = [ "winnow", ] +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "tracing-core" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + [[package]] name = "typenum" version = "1.16.0" @@ -3344,6 +3439,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "varisat" version = "0.2.2" @@ -3593,21 +3694,6 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -3623,93 +3709,51 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.0" @@ -3737,9 +3781,9 @@ dependencies = [ "cargo", "cargo-util", "clap", - "env_logger", "git2", - "log", + "tracing", + "tracing-subscriber", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 34f1258bf2b2..96fbaea309e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,6 @@ crates-io = { version = "0.38.0", path = "crates/crates-io" } criterion = { version = "0.5.1", features = ["html_reports"] } curl = "0.4.44" curl-sys = "0.4.65" -env_logger = "0.10.0" filetime = "0.2.21" flate2 = { version = "1.0.26", default-features = false, features = ["zlib"] } fwdansi = "1.1.0" @@ -58,9 +57,8 @@ lazy_static = "1.4.0" lazycell = "1.3.0" libc = "0.2.147" libgit2-sys = "0.15.2" -log = "0.4.19" memchr = "2.5.0" -miow = "0.5.0" +miow = "0.6.0" opener = "0.6.1" openssl ="0.10.55" os_info = "3.7.0" @@ -69,7 +67,6 @@ pathdiff = "0.2" percent-encoding = "2.3" pkg-config = "0.3.27" pretty_assertions = "1.4.0" -pretty_env_logger = "0.5.0" proptest = "1.2.0" pulldown-cmark = { version = "0.9.3", default-features = false } rand = "0.8.5" @@ -94,6 +91,8 @@ thiserror = "1.0.44" time = { version = "0.3", features = ["parsing", "formatting", "serde"] } toml = "0.7.6" toml_edit = "0.19.14" +tracing = "0.1.37" +tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } unicase = "2.6.0" unicode-width = "0.1.10" unicode-xid = "0.2.4" @@ -132,7 +131,6 @@ clap = { workspace = true, features = ["wrap_help"] } crates-io.workspace = true curl = { workspace = true, features = ["http2"] } curl-sys.workspace = true -env_logger.workspace = true filetime.workspace = true flate2.workspace = true git2.workspace = true @@ -153,13 +151,11 @@ jobserver.workspace = true lazycell.workspace = true libc.workspace = true libgit2-sys.workspace = true -log.workspace = true memchr.workspace = true opener.workspace = true os_info.workspace = true pasetors.workspace = true pathdiff.workspace = true -pretty_env_logger = { workspace = true, optional = true } pulldown-cmark.workspace = true rand.workspace = true rustfix.workspace = true @@ -178,6 +174,8 @@ termcolor.workspace = true time.workspace = true toml.workspace = true toml_edit.workspace = true +tracing.workspace = true +tracing-subscriber.workspace = true unicase.workspace = true unicode-width.workspace = true unicode-xid.workspace = true @@ -218,6 +216,5 @@ doc = false [features] vendored-openssl = ["openssl/vendored"] vendored-libgit2 = ["libgit2-sys/vendored"] -pretty-env-logger = ["pretty_env_logger"] # This is primarily used by rust-lang/rust distributing cargo the executable. all-static = ['vendored-openssl', 'curl/static-curl', 'curl/force-system-lib-on-osx'] diff --git a/crates/cargo-util/Cargo.toml b/crates/cargo-util/Cargo.toml index 6c5efba83778..36ca7bc1771f 100644 --- a/crates/cargo-util/Cargo.toml +++ b/crates/cargo-util/Cargo.toml @@ -14,10 +14,10 @@ filetime.workspace = true hex.workspace = true jobserver.workspace = true libc.workspace = true -log.workspace = true same-file.workspace = true shell-escape.workspace = true tempfile.workspace = true +tracing.workspace = true walkdir.workspace = true [target.'cfg(target_os = "macos")'.dependencies] diff --git a/crates/cargo-util/src/paths.rs b/crates/cargo-util/src/paths.rs index 4a917821b7e8..ce675585979f 100644 --- a/crates/cargo-util/src/paths.rs +++ b/crates/cargo-util/src/paths.rs @@ -237,7 +237,7 @@ pub fn mtime_recursive(path: &Path) -> Result { Err(e) => { // Ignore errors while walking. If Cargo can't access it, the // build script probably can't access it, either. - log::debug!("failed to determine mtime while walking directory: {}", e); + tracing::debug!("failed to determine mtime while walking directory: {}", e); None } }) @@ -252,7 +252,7 @@ pub fn mtime_recursive(path: &Path) -> Result { // I'm not sure when this is really possible (maybe a // race with unlinking?). Regardless, if Cargo can't // read it, the build script probably can't either. - log::debug!( + tracing::debug!( "failed to determine mtime while fetching symlink metadata of {}: {}", e.path().display(), err @@ -271,7 +271,7 @@ pub fn mtime_recursive(path: &Path) -> Result { // Can't access the symlink target. If Cargo can't // access it, the build script probably can't access // it either. - log::debug!( + tracing::debug!( "failed to determine mtime of symlink target for {}: {}", e.path().display(), err @@ -286,7 +286,7 @@ pub fn mtime_recursive(path: &Path) -> Result { // I'm not sure when this is really possible (maybe a // race with unlinking?). Regardless, if Cargo can't // read it, the build script probably can't either. - log::debug!( + tracing::debug!( "failed to determine mtime while fetching metadata of {}: {}", e.path().display(), err @@ -314,7 +314,7 @@ pub fn set_invocation_time(path: &Path) -> Result { "This file has an mtime of when this was started.", )?; let ft = mtime(×tamp)?; - log::debug!("invocation time for {:?} is {}", path, ft); + tracing::debug!("invocation time for {:?} is {}", path, ft); Ok(ft) } @@ -508,7 +508,7 @@ pub fn link_or_copy(src: impl AsRef, dst: impl AsRef) -> Result<()> } fn _link_or_copy(src: &Path, dst: &Path) -> Result<()> { - log::debug!("linking {} to {}", src.display(), dst.display()); + tracing::debug!("linking {} to {}", src.display(), dst.display()); if same_file::is_same_file(src, dst).unwrap_or(false) { return Ok(()); } @@ -567,7 +567,7 @@ fn _link_or_copy(src: &Path, dst: &Path) -> Result<()> { }; link_result .or_else(|err| { - log::debug!("link failed {}. falling back to fs::copy", err); + tracing::debug!("link failed {}. falling back to fs::copy", err); fs::copy(src, dst).map(|_| ()) }) .with_context(|| { @@ -598,8 +598,8 @@ pub fn copy, Q: AsRef>(from: P, to: Q) -> Result { pub fn set_file_time_no_err>(path: P, time: FileTime) { let path = path.as_ref(); match filetime::set_file_times(path, time, time) { - Ok(()) => log::debug!("set file mtime {} to {}", path.display(), time), - Err(e) => log::warn!( + Ok(()) => tracing::debug!("set file mtime {} to {}", path.display(), time), + Err(e) => tracing::warn!( "could not set mtime of {} to {}: {:?}", path.display(), time, @@ -621,7 +621,7 @@ pub fn strip_prefix_canonical>( let safe_canonicalize = |path: &Path| match path.canonicalize() { Ok(p) => p, Err(e) => { - log::warn!("cannot canonicalize {:?}: {:?}", path, e); + tracing::warn!("cannot canonicalize {:?}: {:?}", path, e); path.to_path_buf() } }; diff --git a/crates/cargo-util/src/process_builder.rs b/crates/cargo-util/src/process_builder.rs index 76392f2564b0..b197b95b1306 100644 --- a/crates/cargo-util/src/process_builder.rs +++ b/crates/cargo-util/src/process_builder.rs @@ -449,7 +449,7 @@ impl ProcessBuilder { arg.push(tmp.path()); let mut cmd = self.build_command_without_args(); cmd.arg(arg); - log::debug!("created argfile at {} for {self}", tmp.path().display()); + tracing::debug!("created argfile at {} for {self}", tmp.path().display()); let cap = self.get_args().map(|arg| arg.len() + 1).sum::(); let mut buf = Vec::with_capacity(cap); @@ -558,7 +558,7 @@ fn piped(cmd: &mut Command, pipe_stdin: bool) -> &mut Command { fn close_tempfile_and_log_error(file: NamedTempFile) { file.close().unwrap_or_else(|e| { - log::warn!("failed to close temporary file: {e}"); + tracing::warn!("failed to close temporary file: {e}"); }); } diff --git a/crates/xtask-bump-check/Cargo.toml b/crates/xtask-bump-check/Cargo.toml index b29e5595fcbe..e965ad09e654 100644 --- a/crates/xtask-bump-check/Cargo.toml +++ b/crates/xtask-bump-check/Cargo.toml @@ -9,6 +9,6 @@ anyhow.workspace = true cargo.workspace = true cargo-util.workspace = true clap.workspace = true -env_logger.workspace = true git2.workspace = true -log.workspace = true +tracing.workspace = true +tracing-subscriber.workspace = true diff --git a/crates/xtask-bump-check/src/main.rs b/crates/xtask-bump-check/src/main.rs index 1942a3621cfb..6f9e2e94cb2c 100644 --- a/crates/xtask-bump-check/src/main.rs +++ b/crates/xtask-bump-check/src/main.rs @@ -1,7 +1,8 @@ mod xtask; fn main() { - env_logger::init_from_env("CARGO_LOG"); + setup_logger(); + let cli = xtask::cli(); let matches = cli.get_matches(); @@ -13,3 +14,13 @@ fn main() { cargo::exit_with_error(e, &mut config.shell()) } } + +// In sync with `src/bin/cargo/main.rs@setup_logger`. +fn setup_logger() { + let env = tracing_subscriber::EnvFilter::from_env("CARGO_LOG"); + + tracing_subscriber::fmt() + .with_writer(std::io::stderr) + .with_env_filter(env) + .init(); +} diff --git a/crates/xtask-bump-check/src/xtask.rs b/crates/xtask-bump-check/src/xtask.rs index 042615f4ed0e..b020e62da80d 100644 --- a/crates/xtask-bump-check/src/xtask.rs +++ b/crates/xtask-bump-check/src/xtask.rs @@ -126,7 +126,7 @@ fn bump_check(args: &clap::ArgMatches, config: &mut cargo::util::Config) -> Carg for referenced_member in checkout_ws(&ws, &repo, referenced_commit)?.members() { let Some(changed_member) = changed_members.get(referenced_member) else { let name = referenced_member.name().as_str(); - log::trace!("skipping {name}, may be removed or not published"); + tracing::trace!("skipping {name}, may be removed or not published"); continue; }; @@ -264,10 +264,10 @@ fn get_referenced_commit<'a>( let referenced_commit = if rev_id == stable_commit.id() { None } else if rev_id == beta_commit.id() { - log::trace!("stable branch from `{}`", stable.name().unwrap().unwrap()); + tracing::trace!("stable branch from `{}`", stable.name().unwrap().unwrap()); Some(stable_commit) } else { - log::trace!("beta branch from `{}`", beta.name().unwrap().unwrap()); + tracing::trace!("beta branch from `{}`", beta.name().unwrap().unwrap()); Some(beta_commit) }; @@ -287,11 +287,11 @@ fn beta_and_stable_branch(repo: &git2::Repository) -> CargoResult<[git2::Branch< let (branch, _) = branch?; let name = branch.name()?.unwrap(); let Some((_, version)) = name.split_once("/rust-") else { - log::trace!("branch `{name}` is not in the format of `/rust-`"); + tracing::trace!("branch `{name}` is not in the format of `/rust-`"); continue; }; let Ok(version) = version.to_semver() else { - log::trace!("branch `{name}` is not a valid semver: `{version}`"); + tracing::trace!("branch `{name}` is not a valid semver: `{version}`"); continue; }; release_branches.push((version, branch)); @@ -380,7 +380,7 @@ fn check_crates_io<'a>( } }; if possibilities.is_empty() { - log::trace!("dep `{name}` has no version greater than or equal to `{current}`"); + tracing::trace!("dep `{name}` has no version greater than or equal to `{current}`"); } else { needs_bump.push(member); } diff --git a/credential/cargo-credential/Cargo.toml b/credential/cargo-credential/Cargo.toml index 9ac9168ffe6e..b765d529e53c 100644 --- a/credential/cargo-credential/Cargo.toml +++ b/credential/cargo-credential/Cargo.toml @@ -12,3 +12,6 @@ serde = { workspace = true, features = ["derive"] } serde_json.workspace = true thiserror.workspace = true time.workspace = true + +[dev-dependencies] +snapbox = { workspace = true, features = ["examples"] } diff --git a/credential/cargo-credential/src/lib.rs b/credential/cargo-credential/src/lib.rs index bbd437617aa0..02564dd2a29f 100644 --- a/credential/cargo-credential/src/lib.rs +++ b/credential/cargo-credential/src/lib.rs @@ -1,4 +1,4 @@ -//! Helper library for writing Cargo credential processes. +//! Helper library for writing Cargo credential providers. //! //! A credential process should have a `struct` that implements the `Credential` trait. //! The `main` function should be called with an instance of that struct, such as: @@ -8,6 +8,34 @@ //! cargo_credential::main(MyCredential); //! } //! ``` +//! +//! While in the `perform` function, stdin and stdout will be re-attached to the +//! active console. This allows credential providers to be interactive if necessary. +//! +//! ## Error handling +//! ### [`Error::UrlNotSupported`] +//! A credential provider may only support some registry URLs. If this is the case +//! and an unsupported index URL is passed to the provider, it should respond with +//! [`Error::UrlNotSupported`]. Other credential providers may be attempted by Cargo. +//! +//! ### [`Error::NotFound`] +//! When attempting an [`Action::Get`] or [`Action::Logout`], if a credential can not +//! be found, the provider should respond with [`Error::NotFound`]. Other credential +//! providers may be attempted by Cargo. +//! +//! ### [`Error::OperationNotSupported`] +//! A credential provider might not support all operations. For example if the provider +//! only supports [`Action::Get`], [`Error::OperationNotSupported`] should be returned +//! for all other requests. +//! +//! ### [`Error::Other`] +//! All other errors go here. The error will be shown to the user in Cargo, including +//! the full error chain using [`std::error::Error::source`]. +//! +//! ## Example +//! ```rust,ignore +#![doc = include_str!("../examples/file-provider.rs")] +//! ``` use serde::{Deserialize, Serialize}; use std::{ diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 8cca5c1f9867..eb337d681ce0 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -523,7 +523,9 @@ pub fn cli() -> Command { Command::new("cargo") // Subcommands all count their args' display order independently (from 0), // which makes their args interspersed with global args. This puts global args last. - .next_display_order(1000) + // + // We also want these to come before auto-generated `--help` + .next_display_order(800) .allow_external_subcommands(true) // Doesn't mix well with our list of common cargo commands. See clap-rs/clap#3108 for // opening clap up to allow us to style our help template @@ -586,9 +588,21 @@ See 'cargo help ' for more information on a specific command.\n", .value_hint(clap::ValueHint::DirPath) .value_parser(clap::builder::ValueParser::path_buf()), ) - .arg(flag("frozen", "Require Cargo.lock and cache are up to date").global(true)) - .arg(flag("locked", "Require Cargo.lock is up to date").global(true)) - .arg(flag("offline", "Run without accessing the network").global(true)) + .arg( + flag("frozen", "Require Cargo.lock and cache are up to date") + .help_heading(heading::MANIFEST_OPTIONS) + .global(true), + ) + .arg( + flag("locked", "Require Cargo.lock is up to date") + .help_heading(heading::MANIFEST_OPTIONS) + .global(true), + ) + .arg( + flag("offline", "Run without accessing the network") + .help_heading(heading::MANIFEST_OPTIONS) + .global(true), + ) .arg(multi_opt("config", "KEY=VALUE", "Override a configuration value").global(true)) .arg( Arg::new("unstable-features") diff --git a/src/bin/cargo/commands/add.rs b/src/bin/cargo/commands/add.rs index 52fc38b7433f..56df762683e9 100644 --- a/src/bin/cargo/commands/add.rs +++ b/src/bin/cargo/commands/add.rs @@ -79,8 +79,8 @@ Example uses: ]) .arg_manifest_path() .arg_package("Package to modify") - .arg_quiet() .arg_dry_run("Don't actually write the manifest") + .arg_quiet() .next_help_heading("Source") .args([ clap::Arg::new("path") diff --git a/src/bin/cargo/commands/bench.rs b/src/bin/cargo/commands/bench.rs index 3739d880e2c1..7f4c4eeafc6a 100644 --- a/src/bin/cargo/commands/bench.rs +++ b/src/bin/cargo/commands/bench.rs @@ -4,7 +4,7 @@ use cargo::ops::{self, TestOptions}; pub fn cli() -> Command { subcommand("bench") .about("Execute all benchmarks of a local package") - .arg_quiet() + .next_display_order(0) .arg( Arg::new("BENCHNAME") .action(ArgAction::Set) @@ -16,6 +16,19 @@ pub fn cli() -> Command { .num_args(0..) .last(true), ) + .arg(flag("no-run", "Compile, but don't run benchmarks")) + .arg(flag( + "no-fail-fast", + "Run all benchmarks regardless of failure", + )) + .arg_ignore_rust_version() + .arg_message_format() + .arg_quiet() + .arg_package_spec( + "Package to run benchmarks for", + "Benchmark all packages in the workspace", + "Exclude packages from the benchmark", + ) .arg_targets_all( "Benchmark only this package's library", "Benchmark only the specified binary", @@ -28,26 +41,14 @@ pub fn cli() -> Command { "Benchmark all benches", "Benchmark all targets", ) - .arg(flag("no-run", "Compile, but don't run benchmarks")) - .arg_package_spec( - "Package to run benchmarks for", - "Benchmark all packages in the workspace", - "Exclude packages from the benchmark", - ) + .arg_features() .arg_jobs() .arg_profile("Build artifacts with the specified profile") - .arg_features() .arg_target_triple("Build for the target triple") .arg_target_dir() - .arg_manifest_path() - .arg_ignore_rust_version() - .arg_message_format() - .arg(flag( - "no-fail-fast", - "Run all benchmarks regardless of failure", - )) .arg_unit_graph() .arg_timings() + .arg_manifest_path() .after_help("Run `cargo help bench` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/build.rs b/src/bin/cargo/commands/build.rs index a78da38a4e3f..e25638aa0d8e 100644 --- a/src/bin/cargo/commands/build.rs +++ b/src/bin/cargo/commands/build.rs @@ -7,13 +7,15 @@ pub fn cli() -> Command { // subcommand aliases are handled in aliased_command() // .alias("b") .about("Compile a local package and all of its dependencies") + .arg_ignore_rust_version() + .arg_future_incompat_report() + .arg_message_format() .arg_quiet() .arg_package_spec( "Package to build (see `cargo help pkgid`)", "Build all packages in the workspace", "Exclude packages from the build", ) - .arg_jobs() .arg_targets_all( "Build only this package's library", "Build only the specified binary", @@ -26,9 +28,10 @@ pub fn cli() -> Command { "Build all benches", "Build all targets", ) + .arg_features() .arg_release("Build artifacts in release mode, with optimizations") .arg_profile("Build artifacts with the specified profile") - .arg_features() + .arg_jobs() .arg_target_triple("Build for the target triple") .arg_target_dir() .arg( @@ -36,15 +39,13 @@ pub fn cli() -> Command { "out-dir", "Copy final artifacts to this directory (unstable)", ) - .value_name("PATH"), + .value_name("PATH") + .help_heading(heading::COMPILATION_OPTIONS), ) - .arg_manifest_path() - .arg_ignore_rust_version() - .arg_message_format() .arg_build_plan() .arg_unit_graph() - .arg_future_incompat_report() .arg_timings() + .arg_manifest_path() .after_help("Run `cargo help build` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/check.rs b/src/bin/cargo/commands/check.rs index c9f6e0b38876..ab6f990488b6 100644 --- a/src/bin/cargo/commands/check.rs +++ b/src/bin/cargo/commands/check.rs @@ -7,13 +7,15 @@ pub fn cli() -> Command { // subcommand aliases are handled in aliased_command() // .alias("c") .about("Check a local package and all of its dependencies for errors") + .arg_ignore_rust_version() + .arg_future_incompat_report() + .arg_message_format() .arg_quiet() .arg_package_spec( "Package(s) to check", "Check all packages in the workspace", "Exclude packages from the check", ) - .arg_jobs() .arg_targets_all( "Check only this package's library", "Check only the specified binary", @@ -26,17 +28,15 @@ pub fn cli() -> Command { "Check all benches", "Check all targets", ) + .arg_features() + .arg_jobs() .arg_release("Check artifacts in release mode, with optimizations") .arg_profile("Check artifacts with the specified profile") - .arg_features() .arg_target_triple("Check for the target triple") .arg_target_dir() - .arg_manifest_path() - .arg_ignore_rust_version() - .arg_message_format() .arg_unit_graph() - .arg_future_incompat_report() .arg_timings() + .arg_manifest_path() .after_help("Run `cargo help check` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/clean.rs b/src/bin/cargo/commands/clean.rs index 162461c47ca1..9fa3c8527007 100644 --- a/src/bin/cargo/commands/clean.rs +++ b/src/bin/cargo/commands/clean.rs @@ -6,14 +6,14 @@ use cargo::util::print_available_packages; pub fn cli() -> Command { subcommand("clean") .about("Remove artifacts that cargo has generated in the past") + .arg_doc("Whether or not to clean just the documentation directory") .arg_quiet() .arg_package_spec_simple("Package to clean artifacts for") - .arg_manifest_path() - .arg_target_triple("Target triple to clean output for") - .arg_target_dir() .arg_release("Whether or not to clean release artifacts") .arg_profile("Clean artifacts of the specified profile") - .arg_doc("Whether or not to clean just the documentation directory") + .arg_target_triple("Target triple to clean output for") + .arg_target_dir() + .arg_manifest_path() .after_help("Run `cargo help clean` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/doc.rs b/src/bin/cargo/commands/doc.rs index 932058afb0b8..c3dfe426dd0e 100644 --- a/src/bin/cargo/commands/doc.rs +++ b/src/bin/cargo/commands/doc.rs @@ -7,22 +7,24 @@ pub fn cli() -> Command { // subcommand aliases are handled in aliased_command() // .alias("d") .about("Build a package's documentation") - .arg_quiet() .arg(flag( "open", "Opens the docs in a browser after the operation", )) - .arg_package_spec( - "Package to document", - "Document all packages in the workspace", - "Exclude packages from the build", - ) .arg(flag( "no-deps", "Don't build documentation for dependencies", )) .arg(flag("document-private-items", "Document private items")) - .arg_jobs() + .arg_ignore_rust_version() + .arg_message_format() + .arg_quiet() + .arg_package_spec( + "Package to document", + "Document all packages in the workspace", + "Exclude packages from the build", + ) + .arg_features() .arg_targets_lib_bin_example( "Document only this package's library", "Document only the specified binary", @@ -30,16 +32,14 @@ pub fn cli() -> Command { "Document only the specified example", "Document all examples", ) + .arg_jobs() .arg_release("Build artifacts in release mode, with optimizations") .arg_profile("Build artifacts with the specified profile") - .arg_features() .arg_target_triple("Build for the target triple") .arg_target_dir() - .arg_manifest_path() - .arg_message_format() - .arg_ignore_rust_version() .arg_unit_graph() .arg_timings() + .arg_manifest_path() .after_help("Run `cargo help doc` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/fetch.rs b/src/bin/cargo/commands/fetch.rs index 2fbbc478cab4..4b1fcb40f253 100644 --- a/src/bin/cargo/commands/fetch.rs +++ b/src/bin/cargo/commands/fetch.rs @@ -7,8 +7,8 @@ pub fn cli() -> Command { subcommand("fetch") .about("Fetch dependencies of a package from the network") .arg_quiet() - .arg_manifest_path() .arg_target_triple("Fetch dependencies for the target triple") + .arg_manifest_path() .after_help("Run `cargo help fetch` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/fix.rs b/src/bin/cargo/commands/fix.rs index 5238d5852d16..1f98dd67e0f2 100644 --- a/src/bin/cargo/commands/fix.rs +++ b/src/bin/cargo/commands/fix.rs @@ -5,13 +5,35 @@ use cargo::ops; pub fn cli() -> Command { subcommand("fix") .about("Automatically fix lint warnings reported by rustc") + .arg(flag("edition", "Fix in preparation for the next edition")) + .arg(flag( + "edition-idioms", + "Fix warnings to migrate to the idioms of an edition", + )) + .arg(flag( + "broken-code", + "Fix code even if it already has compiler errors", + )) + .arg(flag( + "allow-no-vcs", + "Fix code even if a VCS was not detected", + )) + .arg(flag( + "allow-dirty", + "Fix code even if the working directory is dirty", + )) + .arg(flag( + "allow-staged", + "Fix code even if the working directory has staged changes", + )) + .arg_ignore_rust_version() + .arg_message_format() .arg_quiet() .arg_package_spec( "Package(s) to fix", "Fix all packages in the workspace", "Exclude packages from the fixes", ) - .arg_jobs() .arg_targets_all( "Fix only this package's library", "Fix only the specified binary", @@ -24,36 +46,14 @@ pub fn cli() -> Command { "Fix all benches", "Fix all targets (default)", ) + .arg_features() + .arg_jobs() .arg_release("Fix artifacts in release mode, with optimizations") .arg_profile("Build artifacts with the specified profile") - .arg_features() .arg_target_triple("Fix for the target triple") .arg_target_dir() - .arg_manifest_path() - .arg_message_format() - .arg(flag( - "broken-code", - "Fix code even if it already has compiler errors", - )) - .arg(flag("edition", "Fix in preparation for the next edition")) - .arg(flag( - "edition-idioms", - "Fix warnings to migrate to the idioms of an edition", - )) - .arg(flag( - "allow-no-vcs", - "Fix code even if a VCS was not detected", - )) - .arg(flag( - "allow-dirty", - "Fix code even if the working directory is dirty", - )) - .arg(flag( - "allow-staged", - "Fix code even if the working directory has staged changes", - )) - .arg_ignore_rust_version() .arg_timings() + .arg_manifest_path() .after_help("Run `cargo help fix` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/init.rs b/src/bin/cargo/commands/init.rs index b280d4fe4a2d..fdb3dc208dec 100644 --- a/src/bin/cargo/commands/init.rs +++ b/src/bin/cargo/commands/init.rs @@ -5,10 +5,10 @@ use cargo::ops; pub fn cli() -> Command { subcommand("init") .about("Create a new cargo package in an existing directory") - .arg_quiet() .arg(Arg::new("path").action(ArgAction::Set).default_value(".")) - .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_new_opts() + .arg(opt("registry", "Registry to use").value_name("REGISTRY")) + .arg_quiet() .after_help("Run `cargo help init` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/install.rs b/src/bin/cargo/commands/install.rs index 3bb90c2d533b..8abb00190441 100644 --- a/src/bin/cargo/commands/install.rs +++ b/src/bin/cargo/commands/install.rs @@ -10,7 +10,6 @@ use cargo_util::paths; pub fn cli() -> Command { subcommand("install") .about("Install a Rust binary. Default location is $HOME/.cargo/bin") - .arg_quiet() .arg( Arg::new("crate") .value_parser(clap::builder::NonEmptyStringValueParser::new()) @@ -22,6 +21,18 @@ pub fn cli() -> Command { .value_name("VERSION") .requires("crate"), ) + .arg( + opt("index", "Registry index to install from") + .value_name("INDEX") + .requires("crate") + .conflicts_with_all(&["git", "path", "registry"]), + ) + .arg( + opt("registry", "Registry to use") + .value_name("REGISTRY") + .requires("crate") + .conflicts_with_all(&["git", "path", "index"]), + ) .arg( opt("git", "Git URL to install the specified crate from") .value_name("URL") @@ -47,42 +58,31 @@ pub fn cli() -> Command { .value_name("PATH") .conflicts_with_all(&["git", "index", "registry"]), ) - .arg(flag( - "list", - "list all installed packages and their versions", - )) - .arg_jobs() + .arg(opt("root", "Directory to install packages into").value_name("DIR")) .arg(flag("force", "Force overwriting existing crates or binaries").short('f')) .arg(flag("no-track", "Do not save tracking information")) - .arg_features() - .arg_profile("Install artifacts with the specified profile") .arg(flag( - "debug", - "Build in debug mode (with the 'dev' profile) instead of release mode", + "list", + "list all installed packages and their versions", )) + .arg_ignore_rust_version() + .arg_message_format() + .arg_quiet() .arg_targets_bins_examples( "Install only the specified binary", "Install all binaries", "Install only the specified example", "Install all examples", ) + .arg_features() + .arg_jobs() + .arg(flag( + "debug", + "Build in debug mode (with the 'dev' profile) instead of release mode", + )) + .arg_profile("Install artifacts with the specified profile") .arg_target_triple("Build for the target triple") .arg_target_dir() - .arg(opt("root", "Directory to install packages into").value_name("DIR")) - .arg( - opt("index", "Registry index to install from") - .value_name("INDEX") - .requires("crate") - .conflicts_with_all(&["git", "path", "registry"]), - ) - .arg( - opt("registry", "Registry to use") - .value_name("REGISTRY") - .requires("crate") - .conflicts_with_all(&["git", "path", "index"]), - ) - .arg_ignore_rust_version() - .arg_message_format() .arg_timings() .after_help("Run `cargo help install` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/locate_project.rs b/src/bin/cargo/commands/locate_project.rs index 26c35cd91226..69f015300047 100644 --- a/src/bin/cargo/commands/locate_project.rs +++ b/src/bin/cargo/commands/locate_project.rs @@ -6,8 +6,7 @@ use serde::Serialize; pub fn cli() -> Command { subcommand("locate-project") .about("Print a JSON representation of a Cargo.toml file's location") - .arg_quiet() - .arg_manifest_path() + .arg(flag("workspace", "Locate Cargo.toml of the workspace root")) .arg( opt( "message-format", @@ -15,7 +14,8 @@ pub fn cli() -> Command { ) .value_name("FMT"), ) - .arg(flag("workspace", "Locate Cargo.toml of the workspace root")) + .arg_quiet() + .arg_manifest_path() .after_help("Run `cargo help locate-project` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/login.rs b/src/bin/cargo/commands/login.rs index 1d68059a069d..d6769b0f8a27 100644 --- a/src/bin/cargo/commands/login.rs +++ b/src/bin/cargo/commands/login.rs @@ -5,9 +5,9 @@ use cargo::ops; pub fn cli() -> Command { subcommand("login") .about("Log in to a registry.") - .arg_quiet() .arg(Arg::new("token").action(ArgAction::Set)) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) + .arg_quiet() .after_help("Run `cargo help login` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/logout.rs b/src/bin/cargo/commands/logout.rs index 0b4d8b83f4ba..4320240c6317 100644 --- a/src/bin/cargo/commands/logout.rs +++ b/src/bin/cargo/commands/logout.rs @@ -4,8 +4,8 @@ use cargo::ops; pub fn cli() -> Command { subcommand("logout") .about("Remove an API token from the registry locally") - .arg_quiet() .arg(opt("registry", "Registry to use").value_name("REGISTRY")) + .arg_quiet() .after_help("Run `cargo help logout` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/metadata.rs b/src/bin/cargo/commands/metadata.rs index fdf59654c8f5..54257dee3db2 100644 --- a/src/bin/cargo/commands/metadata.rs +++ b/src/bin/cargo/commands/metadata.rs @@ -8,8 +8,6 @@ pub fn cli() -> Command { the concrete used versions including overrides, \ in machine-readable format", ) - .arg_quiet() - .arg_features() .arg(multi_opt( "filter-platform", "TRIPLE", @@ -20,12 +18,14 @@ pub fn cli() -> Command { "Output information only about the workspace members \ and don't fetch dependencies", )) - .arg_manifest_path() .arg( opt("format-version", "Format version") .value_name("VERSION") .value_parser(["1"]), ) + .arg_quiet() + .arg_features() + .arg_manifest_path() .after_help("Run `cargo help metadata` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/new.rs b/src/bin/cargo/commands/new.rs index 18cf93d2efbf..6124444c0e8c 100644 --- a/src/bin/cargo/commands/new.rs +++ b/src/bin/cargo/commands/new.rs @@ -5,10 +5,10 @@ use cargo::ops; pub fn cli() -> Command { subcommand("new") .about("Create a new cargo package at ") - .arg_quiet() .arg(Arg::new("path").action(ArgAction::Set).required(true)) - .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_new_opts() + .arg(opt("registry", "Registry to use").value_name("REGISTRY")) + .arg_quiet() .after_help("Run `cargo help new` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/owner.rs b/src/bin/cargo/commands/owner.rs index 8c213d8666b3..223327c3163a 100644 --- a/src/bin/cargo/commands/owner.rs +++ b/src/bin/cargo/commands/owner.rs @@ -6,7 +6,6 @@ use cargo_credential::Secret; pub fn cli() -> Command { subcommand("owner") .about("Manage the owners of a crate on the registry") - .arg_quiet() .arg(Arg::new("crate").action(ArgAction::Set)) .arg( multi_opt( @@ -28,6 +27,7 @@ pub fn cli() -> Command { .arg(opt("index", "Registry index to modify owners for").value_name("INDEX")) .arg(opt("token", "API token to use when authenticating").value_name("TOKEN")) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) + .arg_quiet() .after_help("Run `cargo help owner` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/package.rs b/src/bin/cargo/commands/package.rs index cef530fdc6c9..cf4ac795c6b3 100644 --- a/src/bin/cargo/commands/package.rs +++ b/src/bin/cargo/commands/package.rs @@ -5,7 +5,6 @@ use cargo::ops::{self, PackageOpts}; pub fn cli() -> Command { subcommand("package") .about("Assemble the local package into a distributable tarball") - .arg_quiet() .arg( flag( "list", @@ -25,16 +24,17 @@ pub fn cli() -> Command { "allow-dirty", "Allow dirty working directories to be packaged", )) - .arg_target_triple("Build for the target triple") - .arg_target_dir() - .arg_features() + .arg_quiet() .arg_package_spec_no_all( "Package(s) to assemble", "Assemble all packages in the workspace", "Don't assemble specified packages", ) - .arg_manifest_path() + .arg_features() + .arg_target_triple("Build for the target triple") + .arg_target_dir() .arg_jobs() + .arg_manifest_path() .after_help("Run `cargo help package` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/pkgid.rs b/src/bin/cargo/commands/pkgid.rs index cd92e9998db4..ba4540cf1ac4 100644 --- a/src/bin/cargo/commands/pkgid.rs +++ b/src/bin/cargo/commands/pkgid.rs @@ -6,8 +6,8 @@ use cargo::util::print_available_packages; pub fn cli() -> Command { subcommand("pkgid") .about("Print a fully qualified package specification") - .arg_quiet() .arg(Arg::new("spec").action(ArgAction::Set)) + .arg_quiet() .arg_package("Argument to get the package ID specifier for") .arg_manifest_path() .after_help("Run `cargo help pkgid` for more detailed information.\n") diff --git a/src/bin/cargo/commands/publish.rs b/src/bin/cargo/commands/publish.rs index e550e1544c04..bda240c8c821 100644 --- a/src/bin/cargo/commands/publish.rs +++ b/src/bin/cargo/commands/publish.rs @@ -5,8 +5,9 @@ use cargo::ops::{self, PublishOpts}; pub fn cli() -> Command { subcommand("publish") .about("Upload a package to the registry") - .arg_quiet() + .arg_dry_run("Perform all checks without uploading") .arg_index() + .arg(opt("registry", "Registry to publish to").value_name("REGISTRY")) .arg(opt("token", "Token to use when uploading").value_name("TOKEN")) .arg(flag( "no-verify", @@ -16,14 +17,13 @@ pub fn cli() -> Command { "allow-dirty", "Allow dirty working directories to be packaged", )) - .arg_target_triple("Build for the target triple") - .arg_target_dir() + .arg_quiet() .arg_package("Package to publish") - .arg_manifest_path() .arg_features() .arg_jobs() - .arg_dry_run("Perform all checks without uploading") - .arg(opt("registry", "Registry to publish to").value_name("REGISTRY")) + .arg_target_triple("Build for the target triple") + .arg_target_dir() + .arg_manifest_path() .after_help("Run `cargo help publish` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/remove.rs b/src/bin/cargo/commands/remove.rs index 50bc8b7e6aed..2f03226c3163 100644 --- a/src/bin/cargo/commands/remove.rs +++ b/src/bin/cargo/commands/remove.rs @@ -24,10 +24,8 @@ pub fn cli() -> clap::Command { .num_args(1..) .value_name("DEP_ID") .help("Dependencies to be removed")]) - .arg_package("Package to remove from") - .arg_manifest_path() - .arg_quiet() .arg_dry_run("Don't actually write the manifest") + .arg_quiet() .next_help_heading("Section") .args([ clap::Arg::new("dev") @@ -49,6 +47,8 @@ pub fn cli() -> clap::Command { .value_parser(clap::builder::NonEmptyStringValueParser::new()) .help("Remove as dependency from the given target platform"), ]) + .arg_package("Package to remove from") + .arg_manifest_path() } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs index 366e19396d62..1649f72ac31b 100644 --- a/src/bin/cargo/commands/run.rs +++ b/src/bin/cargo/commands/run.rs @@ -14,7 +14,6 @@ pub fn cli() -> Command { // subcommand aliases are handled in aliased_command() // .alias("r") .about("Run a binary or example of the local package") - .arg_quiet() .arg( Arg::new("args") .help("Arguments for the binary or example to run") @@ -22,21 +21,22 @@ pub fn cli() -> Command { .num_args(0..) .trailing_var_arg(true), ) + .arg_ignore_rust_version() + .arg_message_format() + .arg_quiet() + .arg_package("Package with the target to run") .arg_targets_bin_example( "Name of the bin target to run", "Name of the example target to run", ) - .arg_package("Package with the target to run") + .arg_features() .arg_jobs() .arg_release("Build artifacts in release mode, with optimizations") .arg_profile("Build artifacts with the specified profile") - .arg_features() .arg_target_triple("Build for the target triple") .arg_target_dir() .arg_manifest_path() - .arg_message_format() .arg_unit_graph() - .arg_ignore_rust_version() .arg_timings() .after_help("Run `cargo help run` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/rustc.rs b/src/bin/cargo/commands/rustc.rs index de73eb80c8da..0a0364e3755e 100644 --- a/src/bin/cargo/commands/rustc.rs +++ b/src/bin/cargo/commands/rustc.rs @@ -8,15 +8,29 @@ const CRATE_TYPE_ARG_NAME: &str = "crate-type"; pub fn cli() -> Command { subcommand("rustc") .about("Compile a package, and pass extra options to the compiler") - .arg_quiet() .arg( Arg::new("args") .num_args(0..) .help("Extra rustc flags") .trailing_var_arg(true), ) + .arg( + opt( + PRINT_ARG_NAME, + "Output compiler information without compiling", + ) + .value_name("INFO"), + ) + .arg(multi_opt( + CRATE_TYPE_ARG_NAME, + "CRATE-TYPE", + "Comma separated list of types of crates for the compiler to emit", + )) + .arg_future_incompat_report() + .arg_ignore_rust_version() + .arg_message_format() + .arg_quiet() .arg_package("Package to build") - .arg_jobs() .arg_targets_all( "Build only this package's library", "Build only the specified binary", @@ -29,29 +43,15 @@ pub fn cli() -> Command { "Build all benches", "Build all targets", ) + .arg_features() + .arg_jobs() .arg_release("Build artifacts in release mode, with optimizations") .arg_profile("Build artifacts with the specified profile") - .arg_features() .arg_target_triple("Target triple which compiles will be for") - .arg( - opt( - PRINT_ARG_NAME, - "Output compiler information without compiling", - ) - .value_name("INFO"), - ) - .arg(multi_opt( - CRATE_TYPE_ARG_NAME, - "CRATE-TYPE", - "Comma separated list of types of crates for the compiler to emit", - )) .arg_target_dir() - .arg_manifest_path() - .arg_message_format() .arg_unit_graph() - .arg_ignore_rust_version() - .arg_future_incompat_report() .arg_timings() + .arg_manifest_path() .after_help("Run `cargo help rustc` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/rustdoc.rs b/src/bin/cargo/commands/rustdoc.rs index e87f435fd1f8..488256ba7dce 100644 --- a/src/bin/cargo/commands/rustdoc.rs +++ b/src/bin/cargo/commands/rustdoc.rs @@ -5,7 +5,6 @@ use crate::command_prelude::*; pub fn cli() -> Command { subcommand("rustdoc") .about("Build a package's documentation, using specified custom flags.") - .arg_quiet() .arg( Arg::new("args") .help("Extra rustdoc flags") @@ -16,8 +15,10 @@ pub fn cli() -> Command { "open", "Opens the docs in a browser after the operation", )) + .arg_ignore_rust_version() + .arg_message_format() + .arg_quiet() .arg_package("Package to document") - .arg_jobs() .arg_targets_all( "Build only this package's library", "Build only the specified binary", @@ -30,16 +31,15 @@ pub fn cli() -> Command { "Build all benches", "Build all targets", ) + .arg_features() + .arg_jobs() .arg_release("Build artifacts in release mode, with optimizations") .arg_profile("Build artifacts with the specified profile") - .arg_features() .arg_target_triple("Build for the target triple") .arg_target_dir() - .arg_manifest_path() - .arg_message_format() .arg_unit_graph() - .arg_ignore_rust_version() .arg_timings() + .arg_manifest_path() .after_help("Run `cargo help rustdoc` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/search.rs b/src/bin/cargo/commands/search.rs index c55d932cc7a3..656172e77d3b 100644 --- a/src/bin/cargo/commands/search.rs +++ b/src/bin/cargo/commands/search.rs @@ -7,9 +7,7 @@ use cargo::ops; pub fn cli() -> Command { subcommand("search") .about("Search packages in crates.io") - .arg_quiet() .arg(Arg::new("query").num_args(0..)) - .arg_index() .arg( opt( "limit", @@ -17,7 +15,9 @@ pub fn cli() -> Command { ) .value_name("LIMIT"), ) + .arg_index() .arg(opt("registry", "Registry to use").value_name("REGISTRY")) + .arg_quiet() .after_help("Run `cargo help search` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/test.rs b/src/bin/cargo/commands/test.rs index 424ed3f00d6f..e9cc4b931135 100644 --- a/src/bin/cargo/commands/test.rs +++ b/src/bin/cargo/commands/test.rs @@ -17,6 +17,12 @@ pub fn cli() -> Command { .num_args(0..) .last(true), ) + .arg(flag("doc", "Test only this library's documentation")) + .arg(flag("no-run", "Compile, but don't run tests")) + .arg(flag("no-fail-fast", "Run all tests regardless of failure")) + .arg_ignore_rust_version() + .arg_future_incompat_report() + .arg_message_format() .arg( flag( "quiet", @@ -24,6 +30,11 @@ pub fn cli() -> Command { ) .short('q'), ) + .arg_package_spec( + "Package to run tests for", + "Test all packages in the workspace", + "Exclude packages from the test", + ) .arg_targets_all( "Test only this package's library unit tests", "Test only the specified binary", @@ -36,26 +47,15 @@ pub fn cli() -> Command { "Test all benches", "Test all targets (does not include doctests)", ) - .arg(flag("doc", "Test only this library's documentation")) - .arg(flag("no-run", "Compile, but don't run tests")) - .arg(flag("no-fail-fast", "Run all tests regardless of failure")) - .arg_package_spec( - "Package to run tests for", - "Test all packages in the workspace", - "Exclude packages from the test", - ) + .arg_features() .arg_jobs() .arg_release("Build artifacts in release mode, with optimizations") .arg_profile("Build artifacts with the specified profile") - .arg_features() .arg_target_triple("Build for the target triple") .arg_target_dir() - .arg_manifest_path() - .arg_ignore_rust_version() - .arg_message_format() .arg_unit_graph() - .arg_future_incompat_report() .arg_timings() + .arg_manifest_path() .after_help( "Run `cargo help test` for more detailed information.\n\ Run `cargo test -- --help` for test binary options.\n", diff --git a/src/bin/cargo/commands/tree.rs b/src/bin/cargo/commands/tree.rs index 94bf3fff1067..4472765a92d1 100644 --- a/src/bin/cargo/commands/tree.rs +++ b/src/bin/cargo/commands/tree.rs @@ -12,24 +12,12 @@ use std::str::FromStr; pub fn cli() -> Command { subcommand("tree") .about("Display a tree visualization of a dependency graph") - .arg_quiet() - .arg_manifest_path() - .arg_package_spec_no_all( - "Package to be used as the root of the tree", - "Display the tree for all packages in the workspace", - "Exclude specific workspace members", - ) .arg( flag("all", "Deprecated, use --no-dedupe instead") .short('a') .hide(true), ) - .arg(flag("all-targets", "Deprecated, use --target=all instead").hide(true)) - .arg_features() - .arg_target_triple( - "Filter dependencies matching the given target-triple (default host platform). \ - Pass `all` to include all targets.", - ) + .arg_quiet() .arg(flag("no-dev-dependencies", "Deprecated, use -e=no-dev instead").hide(true)) .arg( multi_opt( @@ -96,6 +84,18 @@ pub fn cli() -> Command { .short('V') .hide(true), ) + .arg_package_spec_no_all( + "Package to be used as the root of the tree", + "Display the tree for all packages in the workspace", + "Exclude specific workspace members", + ) + .arg_features() + .arg(flag("all-targets", "Deprecated, use --target=all instead").hide(true)) + .arg_target_triple( + "Filter dependencies matching the given target-triple (default host platform). \ + Pass `all` to include all targets.", + ) + .arg_manifest_path() .after_help("Run `cargo help tree` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/uninstall.rs b/src/bin/cargo/commands/uninstall.rs index 46654b66897d..398979bf4969 100644 --- a/src/bin/cargo/commands/uninstall.rs +++ b/src/bin/cargo/commands/uninstall.rs @@ -5,11 +5,14 @@ use cargo::ops; pub fn cli() -> Command { subcommand("uninstall") .about("Remove a Rust binary") - .arg_quiet() .arg(Arg::new("spec").num_args(0..)) - .arg_package_spec_simple("Package to uninstall") - .arg(multi_opt("bin", "NAME", "Only uninstall the binary NAME")) .arg(opt("root", "Directory to uninstall packages from").value_name("DIR")) + .arg_quiet() + .arg_package_spec_simple("Package to uninstall") + .arg( + multi_opt("bin", "NAME", "Only uninstall the binary NAME") + .help_heading(heading::TARGET_SELECTION), + ) .after_help("Run `cargo help uninstall` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/update.rs b/src/bin/cargo/commands/update.rs index bd3f3de4cbb3..31175ef168cb 100644 --- a/src/bin/cargo/commands/update.rs +++ b/src/bin/cargo/commands/update.rs @@ -6,9 +6,7 @@ use cargo::util::print_available_packages; pub fn cli() -> Command { subcommand("update") .about("Update dependencies as recorded in the local lock file") - .arg_quiet() - .arg(flag("workspace", "Only update the workspace packages").short('w')) - .arg_package_spec_simple("Package to update") + .arg_dry_run("Don't actually write the lockfile") .arg( flag( "aggressive", @@ -24,8 +22,14 @@ pub fn cli() -> Command { .value_name("PRECISE") .requires("package"), ) + .arg_quiet() + .arg( + flag("workspace", "Only update the workspace packages") + .short('w') + .help_heading(heading::PACKAGE_SELECTION), + ) + .arg_package_spec_simple("Package to update") .arg_manifest_path() - .arg_dry_run("Don't actually write the lockfile") .after_help("Run `cargo help update` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/vendor.rs b/src/bin/cargo/commands/vendor.rs index 1fd79ec51fa6..69b4ee3802c8 100644 --- a/src/bin/cargo/commands/vendor.rs +++ b/src/bin/cargo/commands/vendor.rs @@ -5,8 +5,6 @@ use std::path::PathBuf; pub fn cli() -> Command { subcommand("vendor") .about("Vendor all dependencies for a project locally") - .arg_quiet() - .arg_manifest_path() .arg( Arg::new("path") .action(ArgAction::Set) @@ -38,6 +36,8 @@ pub fn cli() -> Command { .arg(flag("relative-path", "Not supported").hide(true)) .arg(flag("only-git-deps", "Not supported").hide(true)) .arg(flag("disallow-duplicates", "Not supported").hide(true)) + .arg_quiet() + .arg_manifest_path() .after_help("Run `cargo help vendor` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/yank.rs b/src/bin/cargo/commands/yank.rs index 758259324b1f..e6700bd2fb4e 100644 --- a/src/bin/cargo/commands/yank.rs +++ b/src/bin/cargo/commands/yank.rs @@ -6,7 +6,6 @@ use cargo_credential::Secret; pub fn cli() -> Command { subcommand("yank") .about("Remove a pushed crate from the index") - .arg_quiet() .arg(Arg::new("crate").action(ArgAction::Set)) .arg( opt("version", "The version to yank or un-yank") @@ -18,8 +17,9 @@ pub fn cli() -> Command { "Undo a yank, putting a version back into the index", )) .arg(opt("index", "Registry index to yank from").value_name("INDEX")) - .arg(opt("token", "API token to use when authenticating").value_name("TOKEN")) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) + .arg(opt("token", "API token to use when authenticating").value_name("TOKEN")) + .arg_quiet() .after_help("Run `cargo help yank` for more detailed information.\n") } diff --git a/src/bin/cargo/main.rs b/src/bin/cargo/main.rs index 462332fb7ed1..e9c717b9d4e5 100644 --- a/src/bin/cargo/main.rs +++ b/src/bin/cargo/main.rs @@ -20,10 +20,7 @@ mod commands; use crate::command_prelude::*; fn main() { - #[cfg(feature = "pretty-env-logger")] - pretty_env_logger::init_custom_env("CARGO_LOG"); - #[cfg(not(feature = "pretty-env-logger"))] - env_logger::init_from_env("CARGO_LOG"); + setup_logger(); let mut config = cli::LazyConfig::new(); @@ -40,6 +37,15 @@ fn main() { } } +fn setup_logger() { + let env = tracing_subscriber::EnvFilter::from_env("CARGO_LOG"); + + tracing_subscriber::fmt() + .with_writer(std::io::stderr) + .with_env_filter(env) + .init(); +} + /// Table for defining the aliases which come builtin in `Cargo`. /// The contents are structured as: `(alias, aliased_command, description)`. const BUILTIN_ALIASES: [(&str, &str, &str); 6] = [ diff --git a/src/cargo/core/compiler/build_context/target_info.rs b/src/cargo/core/compiler/build_context/target_info.rs index e6e41c5226fb..754adcf3cd0a 100644 --- a/src/cargo/core/compiler/build_context/target_info.rs +++ b/src/cargo/core/compiler/build_context/target_info.rs @@ -185,6 +185,12 @@ impl TargetInfo { .args(&rustflags) .env_remove("RUSTC_LOG"); + // Removes `FD_CLOEXEC` set by `jobserver::Client` to pass jobserver + // as environment variables specify. + if let Some(client) = config.jobserver_from_env() { + process.inherit_jobserver(client); + } + if let CompileKind::Target(target) = kind { process.arg("--target").arg(target.rustc_target()); } @@ -1065,7 +1071,7 @@ impl RustDocFingerprint { if fingerprint.rustc_vv == actual_rustdoc_target_data.rustc_vv { return Ok(()); } else { - log::debug!( + tracing::debug!( "doc fingerprint changed:\noriginal:\n{}\nnew:\n{}", fingerprint.rustc_vv, actual_rustdoc_target_data.rustc_vv @@ -1073,11 +1079,11 @@ impl RustDocFingerprint { } } Err(e) => { - log::debug!("could not deserialize {:?}: {}", fingerprint_path, e); + tracing::debug!("could not deserialize {:?}: {}", fingerprint_path, e); } }; // Fingerprint does not match, delete the doc directories and write a new fingerprint. - log::debug!( + tracing::debug!( "fingerprint {:?} mismatch, clearing doc directories", fingerprint_path ); diff --git a/src/cargo/core/compiler/context/compilation_files.rs b/src/cargo/core/compiler/context/compilation_files.rs index 1c9d28461f98..f781effdfd19 100644 --- a/src/cargo/core/compiler/context/compilation_files.rs +++ b/src/cargo/core/compiler/context/compilation_files.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use lazycell::LazyCell; -use log::debug; +use tracing::debug; use super::{BuildContext, CompileKind, Context, FileFlavor, Layout}; use crate::core::compiler::{CompileMode, CompileTarget, CrateType, FileType, Unit}; diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index d1746217497c..85306aaac878 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -690,7 +690,17 @@ impl BuildOutput { continue; } let data = match iter.next() { - Some(val) => val, + Some(val) => { + if val.starts_with(":") { + // Line started with `cargo::`. + bail!("unsupported output in {}: `{}`\n\ + Found a `cargo::key=value` build directive which is reserved for future use.\n\ + Either change the directive to `cargo:key=value` syntax (note the single `:`) or upgrade your version of Rust.\n\ + See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \ + for more information about build script outputs.", whence, line); + } + val + } None => continue, }; diff --git a/src/cargo/core/compiler/fingerprint/mod.rs b/src/cargo/core/compiler/fingerprint/mod.rs index 7bb852e79e5f..2e6fb7eed073 100644 --- a/src/cargo/core/compiler/fingerprint/mod.rs +++ b/src/cargo/core/compiler/fingerprint/mod.rs @@ -366,10 +366,10 @@ use std::time::SystemTime; use anyhow::{bail, format_err, Context as _}; use cargo_util::{paths, ProcessBuilder}; use filetime::FileTime; -use log::{debug, info}; use serde::de; use serde::ser; use serde::{Deserialize, Serialize}; +use tracing::{debug, info}; use crate::core::compiler::unit_graph::UnitDep; use crate::core::Package; @@ -1815,7 +1815,7 @@ pub fn parse_dep_info( let info = match EncodedDepInfo::parse(&data) { Some(info) => info, None => { - log::warn!("failed to parse cargo's dep-info at {:?}", dep_info); + tracing::warn!("failed to parse cargo's dep-info at {:?}", dep_info); return Ok(None); } }; diff --git a/src/cargo/core/compiler/future_incompat.rs b/src/cargo/core/compiler/future_incompat.rs index 955dfb8f2d0e..ccea28b9416a 100644 --- a/src/cargo/core/compiler/future_incompat.rs +++ b/src/cargo/core/compiler/future_incompat.rs @@ -417,7 +417,7 @@ pub fn save_and_display_report( let current_reports = match OnDiskReports::load(bcx.ws) { Ok(r) => r, Err(e) => { - log::debug!( + tracing::debug!( "saving future-incompatible reports failed to load current reports: {:?}", e ); diff --git a/src/cargo/core/compiler/job_queue/mod.rs b/src/cargo/core/compiler/job_queue/mod.rs index 6e8866b2b064..26fcd4826929 100644 --- a/src/cargo/core/compiler/job_queue/mod.rs +++ b/src/cargo/core/compiler/job_queue/mod.rs @@ -125,8 +125,8 @@ use std::time::Duration; use anyhow::{format_err, Context as _}; use cargo_util::ProcessBuilder; use jobserver::{Acquired, HelperThread}; -use log::{debug, trace}; use semver::Version; +use tracing::{debug, trace}; pub use self::job::Freshness::{self, Dirty, Fresh}; pub use self::job::{Job, Work}; @@ -840,7 +840,7 @@ impl<'cfg> DrainState<'cfg> { } err_state.count += 1; } else { - log::warn!("{:?}", new_err.error); + tracing::warn!("{:?}", new_err.error); } } diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 31e63c226b77..7024a2ac561f 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -65,7 +65,7 @@ use std::sync::Arc; use anyhow::{Context as _, Error}; use lazycell::LazyCell; -use log::{debug, trace}; +use tracing::{debug, trace}; pub use self::build_config::{BuildConfig, CompileMode, MessageFormat, TimingOutput}; pub use self::build_context::{ @@ -368,7 +368,7 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc) -> Car // See rust-lang/cargo#8348. if output.hardlink.is_some() && output.path.exists() { _ = paths::remove_file(&output.path).map_err(|e| { - log::debug!( + tracing::debug!( "failed to delete previous output file `{:?}`: {e:?}", output.path ); diff --git a/src/cargo/core/compiler/output_depinfo.rs b/src/cargo/core/compiler/output_depinfo.rs index d659d620cbc3..db98adf92bb6 100644 --- a/src/cargo/core/compiler/output_depinfo.rs +++ b/src/cargo/core/compiler/output_depinfo.rs @@ -9,7 +9,7 @@ use std::path::{Path, PathBuf}; use super::{fingerprint, Context, FileFlavor, Unit}; use crate::util::{internal, CargoResult}; use cargo_util::paths; -use log::debug; +use tracing::debug; /// Bacially just normalizes a given path and converts it to a string. fn render_filename>(path: P, basedir: Option<&str>) -> CargoResult { diff --git a/src/cargo/core/compiler/rustdoc.rs b/src/cargo/core/compiler/rustdoc.rs index f6fdd005a3fa..aa4bd0dd4cba 100644 --- a/src/cargo/core/compiler/rustdoc.rs +++ b/src/cargo/core/compiler/rustdoc.rs @@ -112,7 +112,7 @@ pub fn add_root_urls( ) -> CargoResult<()> { let config = cx.bcx.config; if !config.cli_unstable().rustdoc_map { - log::debug!("`doc.extern-map` ignored, requires -Zrustdoc-map flag"); + tracing::debug!("`doc.extern-map` ignored, requires -Zrustdoc-map flag"); return Ok(()); } let map = config.doc_extern_map()?; @@ -125,7 +125,7 @@ pub fn add_root_urls( if let Ok(index_url) = config.get_registry_index(name) { Some((name, index_url)) } else { - log::warn!( + tracing::warn!( "`doc.extern-map.{}` specifies a registry that is not defined", name ); @@ -181,7 +181,7 @@ pub fn add_root_urls( })?; Some(url.to_string()) } else { - log::warn!( + tracing::warn!( "`doc.extern-map.std` is \"local\", but local docs don't appear to exist at {}", html_root.display() ); diff --git a/src/cargo/core/compiler/timings.rs b/src/cargo/core/compiler/timings.rs index 0e0dc03eeeda..57ded9bf84b3 100644 --- a/src/cargo/core/compiler/timings.rs +++ b/src/cargo/core/compiler/timings.rs @@ -122,7 +122,7 @@ impl<'cfg> Timings<'cfg> { match State::current() { Ok(state) => Some(state), Err(e) => { - log::info!("failed to get CPU state, CPU tracking disabled: {:?}", e); + tracing::info!("failed to get CPU state, CPU tracking disabled: {:?}", e); None } } @@ -276,7 +276,7 @@ impl<'cfg> Timings<'cfg> { let current = match State::current() { Ok(s) => s, Err(e) => { - log::info!("failed to get CPU state: {:?}", e); + tracing::info!("failed to get CPU state: {:?}", e); return; } }; diff --git a/src/cargo/core/compiler/unit_dependencies.rs b/src/cargo/core/compiler/unit_dependencies.rs index 369fd83180d6..686822356057 100644 --- a/src/cargo/core/compiler/unit_dependencies.rs +++ b/src/cargo/core/compiler/unit_dependencies.rs @@ -17,7 +17,7 @@ use std::collections::{HashMap, HashSet}; -use log::trace; +use tracing::trace; use crate::core::compiler::artifact::match_artifacts_kind_with_targets; use crate::core::compiler::unit_graph::{UnitDep, UnitGraph}; diff --git a/src/cargo/core/dependency.rs b/src/cargo/core/dependency.rs index 0b3aba8ada5b..c8fee6262ec8 100644 --- a/src/cargo/core/dependency.rs +++ b/src/cargo/core/dependency.rs @@ -1,5 +1,4 @@ use cargo_platform::Platform; -use log::trace; use semver::VersionReq; use serde::ser; use serde::Serialize; @@ -7,6 +6,7 @@ use std::borrow::Cow; use std::fmt; use std::path::PathBuf; use std::rc::Rc; +use tracing::trace; use crate::core::compiler::{CompileKind, CompileTarget}; use crate::core::{PackageId, SourceId, Summary}; diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 093c64d72d30..c84941462b46 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -13,9 +13,9 @@ use bytesize::ByteSize; use curl::easy::Easy; use curl::multi::{EasyHandle, Multi}; use lazycell::LazyCell; -use log::debug; use semver::Version; use serde::Serialize; +use tracing::debug; use crate::core::compiler::{CompileKind, RustcTargetData}; use crate::core::dependency::DepKind; diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index e20531b709c2..da3d612d0474 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -8,7 +8,7 @@ use crate::util::errors::CargoResult; use crate::util::interning::InternedString; use crate::util::{CanonicalUrl, Config}; use anyhow::{bail, Context as _}; -use log::{debug, trace}; +use tracing::{debug, trace}; use url::Url; /// Source of information about a group of packages. @@ -876,7 +876,7 @@ fn summary_for_patch( // Since the locked patch did not match anything, try the unlocked one. let orig_matches = ready!(source.query_vec(orig_patch, QueryKind::Exact)).unwrap_or_else(|e| { - log::warn!( + tracing::warn!( "could not determine unlocked summaries for dep {:?}: {:?}", orig_patch, e @@ -895,7 +895,7 @@ fn summary_for_patch( let name_summaries = ready!(source.query_vec(&name_only_dep, QueryKind::Exact)).unwrap_or_else(|e| { - log::warn!( + tracing::warn!( "failed to do name-only summary query for {:?}: {:?}", name_only_dep, e diff --git a/src/cargo/core/resolver/conflict_cache.rs b/src/cargo/core/resolver/conflict_cache.rs index 10c41761d20a..fba497506d4f 100644 --- a/src/cargo/core/resolver/conflict_cache.rs +++ b/src/cargo/core/resolver/conflict_cache.rs @@ -1,6 +1,6 @@ use std::collections::{BTreeMap, HashMap, HashSet}; -use log::trace; +use tracing::trace; use super::types::ConflictMap; use crate::core::resolver::Context; diff --git a/src/cargo/core/resolver/context.rs b/src/cargo/core/resolver/context.rs index 4854dcde7e2d..f19c678a6953 100644 --- a/src/cargo/core/resolver/context.rs +++ b/src/cargo/core/resolver/context.rs @@ -6,9 +6,9 @@ use crate::core::{Dependency, PackageId, SourceId, Summary}; use crate::util::interning::InternedString; use crate::util::Graph; use anyhow::format_err; -use log::debug; use std::collections::HashMap; use std::num::NonZeroU64; +use tracing::debug; pub use super::encode::Metadata; pub use super::encode::{EncodableDependency, EncodablePackageId, EncodableResolve}; diff --git a/src/cargo/core/resolver/dep_cache.rs b/src/cargo/core/resolver/dep_cache.rs index 54b0ce97ff27..9975330147b5 100644 --- a/src/cargo/core/resolver/dep_cache.rs +++ b/src/cargo/core/resolver/dep_cache.rs @@ -23,10 +23,10 @@ use crate::util::errors::CargoResult; use crate::util::interning::InternedString; use anyhow::Context as _; -use log::debug; use std::collections::{BTreeSet, HashMap, HashSet}; use std::rc::Rc; use std::task::Poll; +use tracing::debug; pub struct RegistryQueryer<'a> { pub registry: &'a mut (dyn Registry + 'a), diff --git a/src/cargo/core/resolver/encode.rs b/src/cargo/core/resolver/encode.rs index 000044d2168a..1ee0d23f40a1 100644 --- a/src/cargo/core/resolver/encode.rs +++ b/src/cargo/core/resolver/encode.rs @@ -117,13 +117,13 @@ use crate::util::errors::CargoResult; use crate::util::interning::InternedString; use crate::util::{internal, Graph}; use anyhow::{bail, Context as _}; -use log::debug; use serde::de; use serde::ser; use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap, HashSet}; use std::fmt; use std::str::FromStr; +use tracing::debug; /// The `Cargo.lock` structure. #[derive(Serialize, Deserialize, Debug)] diff --git a/src/cargo/core/resolver/features.rs b/src/cargo/core/resolver/features.rs index 3670e87112f7..4518f9fe7cf0 100644 --- a/src/cargo/core/resolver/features.rs +++ b/src/cargo/core/resolver/features.rs @@ -470,7 +470,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> { deferred_weak_dependencies: HashMap::new(), }; r.do_resolve(specs, cli_features)?; - log::debug!("features={:#?}", r.activated_features); + tracing::debug!("features={:#?}", r.activated_features); if r.opts.compare { r.compare(); } @@ -518,7 +518,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> { fk: FeaturesFor, fvs: &[FeatureValue], ) -> CargoResult<()> { - log::trace!("activate_pkg {} {}", pkg_id.name(), fk); + tracing::trace!("activate_pkg {} {}", pkg_id.name(), fk); // Add an empty entry to ensure everything is covered. This is intended for // finding bugs where the resolver missed something it should have visited. // Remove this in the future if `activated_features` uses an empty default. @@ -566,7 +566,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> { fk: FeaturesFor, fv: &FeatureValue, ) -> CargoResult<()> { - log::trace!("activate_fv {} {} {}", pkg_id.name(), fk, fv); + tracing::trace!("activate_fv {} {} {}", pkg_id.name(), fk, fv); match fv { FeatureValue::Feature(f) => { self.activate_rec(pkg_id, fk, *f)?; @@ -593,7 +593,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> { fk: FeaturesFor, feature_to_enable: InternedString, ) -> CargoResult<()> { - log::trace!( + tracing::trace!( "activate_rec {} {} feat={}", pkg_id.name(), fk, @@ -615,7 +615,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> { // TODO: this should only happen for optional dependencies. // Other cases should be validated by Summary's `build_feature_map`. // Figure out some way to validate this assumption. - log::debug!( + tracing::debug!( "pkg {:?} does not define feature {}", pkg_id, feature_to_enable @@ -654,7 +654,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> { } if let Some(to_enable) = &to_enable { for dep_feature in to_enable { - log::trace!( + tracing::trace!( "activate deferred {} {} -> {}/{}", pkg_id.name(), fk, @@ -697,7 +697,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> { { // This is weak, but not yet activated. Defer in case // something comes along later and enables it. - log::trace!( + tracing::trace!( "deferring feature {} {} -> {}/{}", pkg_id.name(), fk, diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index b9c29fb872b6..e3da6fe5ad22 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -63,7 +63,7 @@ use std::mem; use std::rc::Rc; use std::time::{Duration, Instant}; -use log::{debug, trace}; +use tracing::{debug, trace}; use crate::core::PackageIdSpec; use crate::core::{Dependency, PackageId, Registry, Summary}; diff --git a/src/cargo/core/source/source_id.rs b/src/cargo/core/source/source_id.rs index 43c141b7a247..6bbc07a5df3f 100644 --- a/src/cargo/core/source/source_id.rs +++ b/src/cargo/core/source/source_id.rs @@ -3,7 +3,6 @@ use crate::sources::registry::CRATES_IO_HTTP_INDEX; use crate::sources::{DirectorySource, CRATES_IO_DOMAIN, CRATES_IO_INDEX, CRATES_IO_REGISTRY}; use crate::sources::{GitSource, PathSource, RegistrySource}; use crate::util::{config, CanonicalUrl, CargoResult, Config, IntoUrl}; -use log::trace; use serde::de; use serde::ser; use std::cmp::{self, Ordering}; @@ -14,6 +13,7 @@ use std::path::{Path, PathBuf}; use std::ptr; use std::sync::Mutex; use std::sync::OnceLock; +use tracing::trace; use url::Url; static SOURCE_ID_CACHE: OnceLock>> = OnceLock::new(); diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index db9c18010734..9ee0cbe04304 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -7,7 +7,7 @@ use std::rc::Rc; use anyhow::{anyhow, bail, Context as _}; use glob::glob; use itertools::Itertools; -use log::debug; +use tracing::debug; use url::Url; use crate::core::compiler::Unit; diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index a03d51199787..9f6edf80d2a5 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -147,7 +147,7 @@ use crate::core::shell::Verbosity::Verbose; use crate::core::Shell; use anyhow::Error; -use log::debug; +use tracing::debug; pub use crate::util::errors::{AlreadyPrintedError, InternalError, VerboseError}; pub use crate::util::{indented_lines, CargoResult, CliError, CliResult, Config}; diff --git a/src/cargo/ops/cargo_compile/mod.rs b/src/cargo/ops/cargo_compile/mod.rs index f53a9e934262..9287fdf4fc58 100644 --- a/src/cargo/ops/cargo_compile/mod.rs +++ b/src/cargo/ops/cargo_compile/mod.rs @@ -753,7 +753,7 @@ fn remove_duplicate_doc( .into_iter() .partition(|unit| cb(unit) && !root_units.contains(unit)); for unit in to_remove { - log::debug!( + tracing::debug!( "removing duplicate doc due to {} for package {} target `{}`", reason, unit.pkg, diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index 6267b08f5882..fddf83f1998a 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -6,9 +6,9 @@ use crate::ops; use crate::util::config::Config; use crate::util::CargoResult; use anyhow::Context; -use log::debug; use std::collections::{BTreeMap, HashSet}; use termcolor::Color::{self, Cyan, Green, Red, Yellow}; +use tracing::debug; pub struct UpdateOptions<'a> { pub config: &'a Config, diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index b113671b078e..0809cefc373a 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -879,7 +879,7 @@ mod tests { .arg(&path_of_source_file) .exec_with_output() { - log::warn!("failed to call rustfmt: {:#}", e); + tracing::warn!("failed to call rustfmt: {:#}", e); } } } diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index e904dba83f04..93469607bc8f 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -22,9 +22,9 @@ use anyhow::Context as _; use cargo_util::paths; use flate2::read::GzDecoder; use flate2::{Compression, GzBuilder}; -use log::debug; use serde::Serialize; use tar::{Archive, Builder, EntryType, Header, HeaderMode}; +use tracing::debug; use unicase::Ascii as UncasedAscii; pub struct PackageOpts<'cfg> { diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index 2dfe900860fd..d9daea5da2ce 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -9,7 +9,7 @@ use crate::util::important_paths::find_project_manifest_exact; use crate::util::toml::read_manifest; use crate::util::Config; use cargo_util::paths; -use log::{info, trace}; +use tracing::{info, trace}; pub fn read_package( path: &Path, diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 67b784ab76ac..1166ea6832cb 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -149,7 +149,7 @@ fn run_unit_tests( unit: unit.clone(), kind: test_kind, }; - report_test_error(ws, &options.compile_opts, &unit_err, e); + report_test_error(ws, test_args, &options.compile_opts, &unit_err, e); errors.push(unit_err); if !options.no_fail_fast { return Err(CliError::code(code)); @@ -275,7 +275,7 @@ fn run_doc_tests( unit: unit.clone(), kind: TestKind::Doctest, }; - report_test_error(ws, &options.compile_opts, &unit_err, e); + report_test_error(ws, test_args, &options.compile_opts, &unit_err, e); errors.push(unit_err); if !options.no_fail_fast { return Err(CliError::code(code)); @@ -407,6 +407,7 @@ fn no_fail_fast_err( /// Displays an error on the console about a test failure. fn report_test_error( ws: &Workspace<'_>, + test_args: &[&str], opts: &ops::CompileOptions, unit_err: &UnitTestError, test_error: anyhow::Error, @@ -420,17 +421,23 @@ fn report_test_error( let mut err = format_err!("{}, to rerun pass `{}`", which, unit_err.cli_args(ws, opts)); // Don't show "process didn't exit successfully" for simple errors. // libtest exits with 101 for normal errors. - let is_simple = test_error + let (is_simple, executed) = test_error .downcast_ref::() .and_then(|proc_err| proc_err.code) - .map_or(false, |code| code == 101); + .map_or((false, false), |code| (code == 101, true)); + if !is_simple { err = test_error.context(err); } crate::display_error(&err, &mut ws.config().shell()); - drop(ws.config().shell().note( - "test was terminated by the signal, stderr might be truncated, \ - pass `--nocapture` disable output buffering.", - )); + + let harness: bool = unit_err.unit.target.harness(); + let nocapture: bool = test_args.contains(&"--nocapture"); + + if !is_simple && executed && harness && !nocapture { + drop(ws.config().shell().note( + "test exited abnormally; to see the full output pass --nocapture to the harness.", + )); + } } diff --git a/src/cargo/ops/fix.rs b/src/cargo/ops/fix.rs index be24967f8b91..0e678d61c6be 100644 --- a/src/cargo/ops/fix.rs +++ b/src/cargo/ops/fix.rs @@ -46,10 +46,10 @@ use std::{env, fs, str}; use anyhow::{bail, Context as _}; use cargo_util::{exit_status_to_string, is_simple_exit_code, paths, ProcessBuilder}; -use log::{debug, trace, warn}; use rustfix::diagnostics::Diagnostic; use rustfix::{self, CodeFix}; use semver::Version; +use tracing::{debug, trace, warn}; use crate::core::compiler::RustcTargetData; use crate::core::resolver::features::{DiffMap, FeatureOpts, FeatureResolver, FeaturesFor}; diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index ea5eded4aa2c..6246311a5c5b 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -71,8 +71,8 @@ use crate::sources::PathSource; use crate::util::errors::CargoResult; use crate::util::{profile, CanonicalUrl}; use anyhow::Context as _; -use log::{debug, trace}; use std::collections::{HashMap, HashSet}; +use tracing::{debug, trace}; /// Result for `resolve_ws_with_opts`. pub struct WorkspaceResolve<'cfg> { diff --git a/src/cargo/ops/tree/graph.rs b/src/cargo/ops/tree/graph.rs index d01d07f1a1a3..f0dad4e5d3f2 100644 --- a/src/cargo/ops/tree/graph.rs +++ b/src/cargo/ops/tree/graph.rs @@ -642,7 +642,7 @@ fn add_feature_rec( let dep_indexes = match graph.dep_name_map[&package_index].get(dep_name) { Some(indexes) => indexes.clone(), None => { - log::debug!( + tracing::debug!( "enabling feature {} on {}, found {}/{}, \ dep appears to not be enabled", feature_name, diff --git a/src/cargo/sources/config.rs b/src/cargo/sources/config.rs index 4097567bbf61..c51c1f009689 100644 --- a/src/cargo/sources/config.rs +++ b/src/cargo/sources/config.rs @@ -10,8 +10,8 @@ use crate::util::config::{self, ConfigRelativePath, OptValue}; use crate::util::errors::CargoResult; use crate::util::{Config, IntoUrl}; use anyhow::{bail, Context as _}; -use log::debug; use std::collections::{HashMap, HashSet}; +use tracing::debug; use url::Url; /// Represents the entire [`[source]` replacement table][1] in Cargo configuration. diff --git a/src/cargo/sources/git/known_hosts.rs b/src/cargo/sources/git/known_hosts.rs index 41b965693a66..0b0dd3208aa6 100644 --- a/src/cargo/sources/git/known_hosts.rs +++ b/src/cargo/sources/git/known_hosts.rs @@ -342,7 +342,7 @@ fn check_ssh_known_hosts( }; match parse_known_hosts_line(&line_value.val, location) { Some(known_host) => known_hosts.push(known_host), - None => log::warn!( + None => tracing::warn!( "failed to parse known host {} from {}", line_value.val, line_value.definition diff --git a/src/cargo/sources/git/oxide.rs b/src/cargo/sources/git/oxide.rs index e86c63e8ee96..ec4fcecdd67c 100644 --- a/src/cargo/sources/git/oxide.rs +++ b/src/cargo/sources/git/oxide.rs @@ -6,12 +6,12 @@ use crate::util::{human_readable_bytes, network, MetricsCounter, Progress}; use crate::{CargoResult, Config}; use cargo_util::paths; use gix::bstr::{BString, ByteSlice}; -use log::debug; use std::cell::RefCell; use std::path::Path; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Weak}; use std::time::{Duration, Instant}; +use tracing::debug; /// For the time being, `repo_path` makes it easy to instantiate a gitoxide repo just for fetching. /// In future this may change to be the gitoxide repository itself. diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 7cba21693623..10796562df00 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -10,9 +10,9 @@ use crate::util::hex::short_hash; use crate::util::Config; use anyhow::Context; use cargo_util::paths::exclude_from_backups_and_indexing; -use log::trace; use std::fmt::{self, Debug, Formatter}; use std::task::Poll; +use tracing::trace; use url::Url; /// `GitSource` contains one or more packages gathering from a Git repository. diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index 0c7ce8b64367..09363109184d 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -11,7 +11,6 @@ use anyhow::{anyhow, Context as _}; use cargo_util::{paths, ProcessBuilder}; use curl::easy::List; use git2::{self, ErrorClass, ObjectType, Oid}; -use log::{debug, info}; use serde::ser; use serde::Serialize; use std::borrow::Cow; @@ -21,6 +20,7 @@ use std::process::Command; use std::str; use std::sync::atomic::{AtomicBool, Ordering}; use std::time::{Duration, Instant}; +use tracing::{debug, info}; use url::Url; /// A file indicates that if present, `git reset` has been done and a repo @@ -1316,7 +1316,7 @@ fn clean_repo_temp_files(repo: &git2::Repository) { let pattern = match path.to_str() { Some(p) => p, None => { - log::warn!("cannot convert {path:?} to a string"); + tracing::warn!("cannot convert {path:?} to a string"); return; } }; @@ -1327,8 +1327,10 @@ fn clean_repo_temp_files(repo: &git2::Repository) { for path in paths { if let Ok(path) = path { match paths::remove_file(&path) { - Ok(_) => log::debug!("removed stale temp git file {path:?}"), - Err(e) => log::warn!("failed to remove {path:?} while cleaning temp files: {e}"), + Ok(_) => tracing::debug!("removed stale temp git file {path:?}"), + Err(e) => { + tracing::warn!("failed to remove {path:?} while cleaning temp files: {e}") + } } } } diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index bb40ec9b11b6..1d8ffc35c8b7 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -11,7 +11,7 @@ use anyhow::Context as _; use cargo_util::paths; use filetime::FileTime; use ignore::gitignore::GitignoreBuilder; -use log::{trace, warn}; +use tracing::{trace, warn}; use walkdir::WalkDir; /// A source represents one or multiple packages gathering from a given root @@ -203,7 +203,7 @@ impl<'cfg> PathSource<'cfg> { let repo = match git2::Repository::discover(root) { Ok(repo) => repo, Err(e) => { - log::debug!( + tracing::debug!( "could not discover git repo at or above {}: {}", root.display(), e @@ -223,7 +223,7 @@ impl<'cfg> PathSource<'cfg> { let repo_relative_path = match paths::strip_prefix_canonical(root, repo_root) { Ok(p) => p, Err(e) => { - log::warn!( + tracing::warn!( "cannot determine if path `{:?}` is in git repo `{:?}`: {:?}", root, repo_root, diff --git a/src/cargo/sources/registry/http_remote.rs b/src/cargo/sources/registry/http_remote.rs index 05920eab11e8..52f6f392e9d9 100644 --- a/src/cargo/sources/registry/http_remote.rs +++ b/src/cargo/sources/registry/http_remote.rs @@ -14,7 +14,6 @@ use cargo_credential::Operation; use cargo_util::paths; use curl::easy::{Easy, List}; use curl::multi::{EasyHandle, Multi}; -use log::{debug, trace}; use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::fs::{self, File}; @@ -23,6 +22,7 @@ use std::path::{Path, PathBuf}; use std::str; use std::task::{ready, Poll}; use std::time::Duration; +use tracing::{debug, trace}; use url::Url; // HTTP headers @@ -394,11 +394,11 @@ impl<'cfg> HttpRegistry<'cfg> { Ok(json) => { self.registry_config = Some(json); } - Err(e) => log::debug!("failed to decode cached config.json: {}", e), + Err(e) => tracing::debug!("failed to decode cached config.json: {}", e), }, Err(e) => { if e.kind() != ErrorKind::NotFound { - log::debug!("failed to read config.json cache: {}", e) + tracing::debug!("failed to read config.json cache: {}", e) } } } @@ -423,7 +423,7 @@ impl<'cfg> HttpRegistry<'cfg> { self.registry_config = Some(serde_json::from_slice(&raw_data)?); if paths::create_dir_all(&config_json_path.parent().unwrap()).is_ok() { if let Err(e) = fs::write(&config_json_path, &raw_data) { - log::debug!("failed to write config.json cache: {}", e); + tracing::debug!("failed to write config.json cache: {}", e); } } Poll::Ready(Ok(self.registry_config.as_ref().unwrap())) diff --git a/src/cargo/sources/registry/index.rs b/src/cargo/sources/registry/index.rs index 6d565da8f5b2..d82a0d24742b 100644 --- a/src/cargo/sources/registry/index.rs +++ b/src/cargo/sources/registry/index.rs @@ -94,7 +94,6 @@ use crate::util::IntoUrl; use crate::util::{internal, CargoResult, Config, Filesystem, OptVersionReq, ToSemver}; use anyhow::bail; use cargo_util::{paths, registry::make_dep_path}; -use log::{debug, info}; use semver::Version; use serde::Deserialize; use std::borrow::Cow; @@ -105,6 +104,7 @@ use std::io::ErrorKind; use std::path::Path; use std::str; use std::task::{ready, Poll}; +use tracing::{debug, info}; /// The current version of [`SummariesCache`]. const CURRENT_CACHE_VERSION: u8 = 3; @@ -673,23 +673,23 @@ impl Summaries { index_version = Some(v); } Err(e) => { - log::debug!("failed to parse {:?} cache: {}", relative, e); + tracing::debug!("failed to parse {:?} cache: {}", relative, e); } }, - Err(e) => log::debug!("cache missing for {:?} error: {}", relative, e), + Err(e) => tracing::debug!("cache missing for {:?} error: {}", relative, e), } let response = ready!(load.load(root, relative, index_version.as_deref())?); match response { LoadResponse::CacheValid => { - log::debug!("fast path for registry cache of {:?}", relative); + tracing::debug!("fast path for registry cache of {:?}", relative); return Poll::Ready(Ok(cached_summaries)); } LoadResponse::NotFound => { if let Err(e) = fs::remove_file(cache_path) { if e.kind() != ErrorKind::NotFound { - log::debug!("failed to remove from cache: {}", e); + tracing::debug!("failed to remove from cache: {}", e); } } return Poll::Ready(Ok(None)); @@ -701,7 +701,7 @@ impl Summaries { // This is the fallback path where we actually talk to the registry backend to load // information. Here we parse every single line in the index (as we need // to find the versions) - log::debug!("slow path for {:?}", relative); + tracing::debug!("slow path for {:?}", relative); let mut cache = SummariesCache::default(); let mut ret = Summaries::default(); ret.raw_data = raw_data; @@ -722,7 +722,11 @@ impl Summaries { // entries in the cache preventing those newer // versions from reading them (that is, until the // cache is rebuilt). - log::info!("failed to parse {:?} registry package: {}", relative, e); + tracing::info!( + "failed to parse {:?} registry package: {}", + relative, + e + ); continue; } }; @@ -731,7 +735,7 @@ impl Summaries { ret.versions.insert(version, summary.into()); } if let Some(index_version) = index_version { - log::trace!("caching index_version {}", index_version); + tracing::trace!("caching index_version {}", index_version); let cache_bytes = cache.serialize(index_version.as_str()); // Once we have our `cache_bytes` which represents the `Summaries` we're // about to return, write that back out to disk so future Cargo @@ -743,7 +747,7 @@ impl Summaries { let path = Filesystem::new(cache_path.clone()); config.assert_package_cache_locked(&path); if let Err(e) = fs::write(cache_path, &cache_bytes) { - log::info!("failed to write cache: {}", e); + tracing::info!("failed to write cache: {}", e); } } @@ -906,7 +910,7 @@ impl IndexSummary { v, } = serde_json::from_slice(line)?; let v = v.unwrap_or(1); - log::trace!("json parsed registry {}/{}", name, vers); + tracing::trace!("json parsed registry {}/{}", name, vers); let pkgid = PackageId::new(name, &vers, source_id)?; let deps = deps .into_iter() diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index a0178db55e8c..b53e88d58a85 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -195,10 +195,10 @@ use std::task::{ready, Poll}; use anyhow::Context as _; use cargo_util::paths::{self, exclude_from_backups_and_indexing}; use flate2::read::GzDecoder; -use log::debug; use serde::Deserialize; use serde::Serialize; use tar::Archive; +use tracing::debug; use crate::core::dependency::Dependency; use crate::core::source::MaybePackage; @@ -589,9 +589,9 @@ impl<'cfg> RegistrySource<'cfg> { } _ => { if ok == "ok" { - log::debug!("old `ok` content found, clearing cache"); + tracing::debug!("old `ok` content found, clearing cache"); } else { - log::warn!("unrecognized .cargo-ok content, clearing cache: {ok}"); + tracing::warn!("unrecognized .cargo-ok content, clearing cache: {ok}"); } // See comment of `unpack_package` about why removing all stuff. paths::remove_dir_all(dst.as_path_unlocked())?; diff --git a/src/cargo/sources/registry/remote.rs b/src/cargo/sources/registry/remote.rs index 4223b0303867..89927181f643 100644 --- a/src/cargo/sources/registry/remote.rs +++ b/src/cargo/sources/registry/remote.rs @@ -12,13 +12,13 @@ use crate::util::{Config, Filesystem}; use anyhow::Context as _; use cargo_util::paths; use lazycell::LazyCell; -use log::{debug, trace}; use std::cell::{Cell, Ref, RefCell}; use std::fs::File; use std::mem; use std::path::Path; use std::str; use std::task::{ready, Poll}; +use tracing::{debug, trace}; /// A remote registry is a registry that lives at a remote URL (such as /// crates.io). The git index is cloned locally, and `.crate` files are diff --git a/src/cargo/util/auth/mod.rs b/src/cargo/util/auth/mod.rs index 1e221a2c7b74..e1e672994a16 100644 --- a/src/cargo/util/auth/mod.rs +++ b/src/cargo/util/auth/mod.rs @@ -12,7 +12,6 @@ use cargo_credential::{ use core::fmt; use serde::Deserialize; -use std::collections::HashMap; use std::error::Error; use time::{Duration, OffsetDateTime}; use url::Url; @@ -31,7 +30,7 @@ use super::{ /// `[registries.NAME]` tables. /// /// The values here should be kept in sync with `RegistryConfigExtended` -#[derive(Deserialize)] +#[derive(Deserialize, Clone, Debug)] #[serde(rename_all = "kebab-case")] pub struct RegistryConfig { pub index: Option, @@ -208,7 +207,20 @@ pub fn registry_credential_config_raw( config: &Config, sid: &SourceId, ) -> CargoResult> { - log::trace!("loading credential config for {}", sid); + let mut cache = config.registry_config(); + if let Some(cfg) = cache.get(&sid) { + return Ok(cfg.clone()); + } + let cfg = registry_credential_config_raw_uncached(config, sid)?; + cache.insert(*sid, cfg.clone()); + return Ok(cfg); +} + +fn registry_credential_config_raw_uncached( + config: &Config, + sid: &SourceId, +) -> CargoResult> { + tracing::trace!("loading credential config for {}", sid); config.load_credentials()?; if !sid.is_remote_registry() { bail!( @@ -237,6 +249,7 @@ pub fn registry_credential_config_raw( // This also allows the authorization token for a registry to be set // without knowing the registry name by using the _INDEX and _TOKEN // environment variables. + let name = { // Discover names from environment variables. let index = sid.canonical_url(); @@ -256,14 +269,17 @@ pub fn registry_credential_config_raw( // Discover names from the configuration only if none were found in the environment. if names.len() == 0 { - names = config - .get::>("registries")? - .iter() - .filter_map(|(k, v)| Some((k, v.index.as_deref()?))) - .filter_map(|(k, v)| Some((k, CanonicalUrl::new(&v.into_url().ok()?).ok()?))) - .filter(|(_, v)| v == index) - .map(|(k, _)| k.to_string()) - .collect(); + if let Some(registries) = config.values()?.get("registries") { + let (registries, _) = registries.table("registries")?; + for (name, value) in registries { + if let Some(v) = value.table(&format!("registries.{name}"))?.0.get("index") { + let (v, _) = v.string(&format!("registries.{name}.index"))?; + if index == &CanonicalUrl::new(&v.into_url()?)? { + names.push(name.clone()); + } + } + } + } } names.sort(); match names.len() { @@ -291,10 +307,10 @@ pub fn registry_credential_config_raw( } if let Some(name) = &name { - log::debug!("found alternative registry name `{name}` for {sid}"); + tracing::debug!("found alternative registry name `{name}` for {sid}"); config.get::>(&format!("registries.{name}")) } else { - log::debug!("no registry name found for {sid}"); + tracing::debug!("no registry name found for {sid}"); Ok(None) } } @@ -304,7 +320,7 @@ fn resolve_credential_alias(config: &Config, mut provider: PathAndArgs) -> Vec(&key) { - log::debug!("resolving credential alias '{key}' -> '{alias:?}'"); + tracing::debug!("resolving credential alias '{key}' -> '{alias:?}'"); provider = alias; } } @@ -428,7 +444,7 @@ fn credential_action( for provider in providers { let args: Vec<&str> = provider.iter().map(String::as_str).collect(); let process = args[0]; - log::debug!("attempting credential provider: {args:?}"); + tracing::debug!("attempting credential provider: {args:?}"); let provider: Box = match process { "cargo:token" => Box::new(TokenCredential::new(config)), "cargo:paseto" => Box::new(PasetoCredential::new(config)), @@ -494,7 +510,7 @@ fn auth_token_optional( operation: Operation<'_>, headers: Vec, ) -> CargoResult>> { - log::trace!("token requested for {}", sid.display_registry_name()); + tracing::trace!("token requested for {}", sid.display_registry_name()); let mut cache = config.credential_cache(); let url = sid.canonical_url(); if let Some(cached_token) = cache.get(url) { @@ -504,7 +520,7 @@ fn auth_token_optional( .unwrap_or(true) { if cached_token.operation_independent || matches!(operation, Operation::Read) { - log::trace!("using token from in-memory cache"); + tracing::trace!("using token from in-memory cache"); return Ok(Some(cached_token.token_value.clone())); } } else { @@ -532,7 +548,7 @@ fn auth_token_optional( bail!("credential provider produced unexpected response for `get` request: {credential_response:?}") }; let token = Secret::from(token); - log::trace!("found token"); + tracing::trace!("found token"); let expiration = match cache_control { CacheControl::Expires(expiration) => Some(expiration), CacheControl::Session => None, diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 46ed7dd7cd1d..db6fae348222 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -26,6 +26,14 @@ pub use clap::Command; use super::config::JobsConfig; +pub mod heading { + pub const PACKAGE_SELECTION: &str = "Package Selection"; + pub const TARGET_SELECTION: &str = "Target Selection"; + pub const FEATURE_SELECTION: &str = "Feature Selection"; + pub const COMPILATION_OPTIONS: &str = "Compilation Options"; + pub const MANIFEST_OPTIONS: &str = "Manifest Options"; +} + pub trait CommandExt: Sized { fn _arg(self, arg: Arg) -> Self; @@ -37,8 +45,10 @@ pub trait CommandExt: Sized { all: &'static str, exclude: &'static str, ) -> Self { - self.arg_package_spec_no_all(package, all, exclude) - ._arg(flag("all", "Alias for --workspace (deprecated)")) + self.arg_package_spec_no_all(package, all, exclude)._arg( + flag("all", "Alias for --workspace (deprecated)") + .help_heading(heading::PACKAGE_SELECTION), + ) } /// Variant of arg_package_spec that does not include the `--all` flag @@ -51,19 +61,24 @@ pub trait CommandExt: Sized { exclude: &'static str, ) -> Self { self.arg_package_spec_simple(package) - ._arg(flag("workspace", all)) - ._arg(multi_opt("exclude", "SPEC", exclude)) + ._arg(flag("workspace", all).help_heading(heading::PACKAGE_SELECTION)) + ._arg(multi_opt("exclude", "SPEC", exclude).help_heading(heading::PACKAGE_SELECTION)) } fn arg_package_spec_simple(self, package: &'static str) -> Self { - self._arg(optional_multi_opt("package", "SPEC", package).short('p')) + self._arg( + optional_multi_opt("package", "SPEC", package) + .short('p') + .help_heading(heading::PACKAGE_SELECTION), + ) } fn arg_package(self, package: &'static str) -> Self { self._arg( optional_opt("package", package) .short('p') - .value_name("SPEC"), + .value_name("SPEC") + .help_heading(heading::PACKAGE_SELECTION), ) } @@ -72,12 +87,16 @@ pub trait CommandExt: Sized { opt("jobs", "Number of parallel jobs, defaults to # of CPUs.") .short('j') .value_name("N") - .allow_hyphen_values(true), + .allow_hyphen_values(true) + .help_heading(heading::COMPILATION_OPTIONS), + ) + ._arg( + flag( + "keep-going", + "Do not abort the build as soon as there is an error (unstable)", + ) + .help_heading(heading::COMPILATION_OPTIONS), ) - ._arg(flag( - "keep-going", - "Do not abort the build as soon as there is an error (unstable)", - )) } fn arg_targets_all( @@ -94,11 +113,13 @@ pub trait CommandExt: Sized { all: &'static str, ) -> Self { self.arg_targets_lib_bin_example(lib, bin, bins, example, examples) - ._arg(flag("tests", tests)) - ._arg(optional_multi_opt("test", "NAME", test)) - ._arg(flag("benches", benches)) - ._arg(optional_multi_opt("bench", "NAME", bench)) - ._arg(flag("all-targets", all)) + ._arg(flag("tests", tests).help_heading(heading::TARGET_SELECTION)) + ._arg(optional_multi_opt("test", "NAME", test).help_heading(heading::TARGET_SELECTION)) + ._arg(flag("benches", benches).help_heading(heading::TARGET_SELECTION)) + ._arg( + optional_multi_opt("bench", "NAME", bench).help_heading(heading::TARGET_SELECTION), + ) + ._arg(flag("all-targets", all).help_heading(heading::TARGET_SELECTION)) } fn arg_targets_lib_bin_example( @@ -109,11 +130,14 @@ pub trait CommandExt: Sized { example: &'static str, examples: &'static str, ) -> Self { - self._arg(flag("lib", lib)) - ._arg(flag("bins", bins)) - ._arg(optional_multi_opt("bin", "NAME", bin)) - ._arg(flag("examples", examples)) - ._arg(optional_multi_opt("example", "NAME", example)) + self._arg(flag("lib", lib).help_heading(heading::TARGET_SELECTION)) + ._arg(flag("bins", bins).help_heading(heading::TARGET_SELECTION)) + ._arg(optional_multi_opt("bin", "NAME", bin).help_heading(heading::TARGET_SELECTION)) + ._arg(flag("examples", examples).help_heading(heading::TARGET_SELECTION)) + ._arg( + optional_multi_opt("example", "NAME", example) + .help_heading(heading::TARGET_SELECTION), + ) } fn arg_targets_bins_examples( @@ -123,15 +147,21 @@ pub trait CommandExt: Sized { example: &'static str, examples: &'static str, ) -> Self { - self._arg(optional_multi_opt("bin", "NAME", bin)) - ._arg(flag("bins", bins)) - ._arg(optional_multi_opt("example", "NAME", example)) - ._arg(flag("examples", examples)) + self._arg(optional_multi_opt("bin", "NAME", bin).help_heading(heading::TARGET_SELECTION)) + ._arg(flag("bins", bins).help_heading(heading::TARGET_SELECTION)) + ._arg( + optional_multi_opt("example", "NAME", example) + .help_heading(heading::TARGET_SELECTION), + ) + ._arg(flag("examples", examples).help_heading(heading::TARGET_SELECTION)) } fn arg_targets_bin_example(self, bin: &'static str, example: &'static str) -> Self { - self._arg(optional_multi_opt("bin", "NAME", bin)) - ._arg(optional_multi_opt("example", "NAME", example)) + self._arg(optional_multi_opt("bin", "NAME", bin).help_heading(heading::TARGET_SELECTION)) + ._arg( + optional_multi_opt("example", "NAME", example) + .help_heading(heading::TARGET_SELECTION), + ) } fn arg_features(self) -> Self { @@ -141,21 +171,36 @@ pub trait CommandExt: Sized { "FEATURES", "Space or comma separated list of features to activate", ) - .short('F'), + .short('F') + .help_heading(heading::FEATURE_SELECTION), + ) + ._arg( + flag("all-features", "Activate all available features") + .help_heading(heading::FEATURE_SELECTION), + ) + ._arg( + flag( + "no-default-features", + "Do not activate the `default` feature", + ) + .help_heading(heading::FEATURE_SELECTION), ) - ._arg(flag("all-features", "Activate all available features")) - ._arg(flag( - "no-default-features", - "Do not activate the `default` feature", - )) } fn arg_release(self, release: &'static str) -> Self { - self._arg(flag("release", release).short('r')) + self._arg( + flag("release", release) + .short('r') + .help_heading(heading::COMPILATION_OPTIONS), + ) } fn arg_profile(self, profile: &'static str) -> Self { - self._arg(opt("profile", profile).value_name("PROFILE-NAME")) + self._arg( + opt("profile", profile) + .value_name("PROFILE-NAME") + .help_heading(heading::COMPILATION_OPTIONS), + ) } fn arg_doc(self, doc: &'static str) -> Self { @@ -163,17 +208,23 @@ pub trait CommandExt: Sized { } fn arg_target_triple(self, target: &'static str) -> Self { - self._arg(multi_opt("target", "TRIPLE", target)) + self._arg(multi_opt("target", "TRIPLE", target).help_heading(heading::COMPILATION_OPTIONS)) } fn arg_target_dir(self) -> Self { self._arg( - opt("target-dir", "Directory for all generated artifacts").value_name("DIRECTORY"), + opt("target-dir", "Directory for all generated artifacts") + .value_name("DIRECTORY") + .help_heading(heading::COMPILATION_OPTIONS), ) } fn arg_manifest_path(self) -> Self { - self._arg(opt("manifest-path", "Path to Cargo.toml").value_name("PATH")) + self._arg( + opt("manifest-path", "Path to Cargo.toml") + .value_name("PATH") + .help_heading(heading::MANIFEST_OPTIONS), + ) } fn arg_message_format(self) -> Self { @@ -181,14 +232,17 @@ pub trait CommandExt: Sized { } fn arg_build_plan(self) -> Self { - self._arg(flag( - "build-plan", - "Output the build plan in JSON (unstable)", - )) + self._arg( + flag("build-plan", "Output the build plan in JSON (unstable)") + .help_heading(heading::COMPILATION_OPTIONS), + ) } fn arg_unit_graph(self) -> Self { - self._arg(flag("unit-graph", "Output build graph in JSON (unstable)")) + self._arg( + flag("unit-graph", "Output build graph in JSON (unstable)") + .help_heading(heading::COMPILATION_OPTIONS), + ) } fn arg_new_opts(self) -> Self { @@ -252,7 +306,8 @@ pub trait CommandExt: Sized { "Timing output formats (unstable) (comma separated): html, json", ) .value_name("FMTS") - .require_equals(true), + .require_equals(true) + .help_heading(heading::COMPILATION_OPTIONS), ) } } diff --git a/src/cargo/util/config/mod.rs b/src/cargo/util/config/mod.rs index 8f1cfe073f5e..cf977d38d135 100644 --- a/src/cargo/util/config/mod.rs +++ b/src/cargo/util/config/mod.rs @@ -106,6 +106,8 @@ pub use target::{TargetCfgConfig, TargetConfig}; mod environment; use environment::Env; +use super::auth::RegistryConfig; + // Helper macro for creating typed access methods. macro_rules! get_value_typed { ($name:ident, $ty:ty, $variant:ident, $expected:expr) => { @@ -208,6 +210,8 @@ pub struct Config { /// Cache of credentials from configuration or credential providers. /// Maps from url to credential value. credential_cache: LazyCell>>, + /// Cache of registry config from from the `[registries]` table. + registry_config: LazyCell>>>, /// Lock, if held, of the global package cache along with the number of /// acquisitions so far. package_cache_lock: RefCell, usize)>>, @@ -299,6 +303,7 @@ impl Config { env, updated_sources: LazyCell::new(), credential_cache: LazyCell::new(), + registry_config: LazyCell::new(), package_cache_lock: RefCell::new(None), http_config: LazyCell::new(), future_incompat_config: LazyCell::new(), @@ -488,6 +493,13 @@ impl Config { .borrow_mut() } + /// Cache of already parsed registries from the `[registries]` table. + pub(crate) fn registry_config(&self) -> RefMut<'_, HashMap>> { + self.registry_config + .borrow_with(|| RefCell::new(HashMap::new())) + .borrow_mut() + } + /// Gets all config values from disk. /// /// This will lazy-load the values as necessary. Callers are responsible @@ -599,7 +611,7 @@ impl Config { key: &ConfigKey, vals: &HashMap, ) -> CargoResult> { - log::trace!("get cv {:?}", key); + tracing::trace!("get cv {:?}", key); if key.is_root() { // Returning the entire root table (for example `cargo config get` // with no key). The definition here shouldn't matter. @@ -2786,7 +2798,7 @@ fn disables_multiplexing_for_bad_curl( .iter() .any(|v| curl_version.starts_with(v)) { - log::info!("disabling multiplexing with proxy, curl version is {curl_version}"); + tracing::info!("disabling multiplexing with proxy, curl version is {curl_version}"); http.multiplexing = Some(false); } } diff --git a/src/cargo/util/config/target.rs b/src/cargo/util/config/target.rs index cdafe73dd679..b8aaf906d6fc 100644 --- a/src/cargo/util/config/target.rs +++ b/src/cargo/util/config/target.rs @@ -45,7 +45,7 @@ pub(super) fn load_target_cfgs(config: &Config) -> CargoResult = config.get("target")?; - log::debug!("Got all targets {:#?}", target); + tracing::debug!("Got all targets {:#?}", target); for (key, cfg) in target { if key.starts_with("cfg(") { // Unfortunately this is not able to display the location of the diff --git a/src/cargo/util/credential/process.rs b/src/cargo/util/credential/process.rs index 07551aee303b..89eac1af6c43 100644 --- a/src/cargo/util/credential/process.rs +++ b/src/cargo/util/credential/process.rs @@ -35,7 +35,7 @@ impl<'a> Credential for CredentialProcessCredential { cmd.stdout(Stdio::piped()); cmd.stdin(Stdio::piped()); cmd.arg("--cargo-plugin"); - log::debug!("credential-process: {cmd:?}"); + tracing::debug!("credential-process: {cmd:?}"); let mut child = cmd.spawn().context("failed to spawn credential process")?; let mut output_from_child = BufReader::new(child.stdout.take().unwrap()); let mut input_to_child = child.stdin.take().unwrap(); @@ -45,7 +45,7 @@ impl<'a> Credential for CredentialProcessCredential { .context("failed to read hello from credential provider")?; let credential_hello: CredentialHello = serde_json::from_str(&buffer).context("failed to deserialize hello")?; - log::debug!("credential-process > {credential_hello:?}"); + tracing::debug!("credential-process > {credential_hello:?}"); let req = CredentialRequest { v: cargo_credential::PROTOCOL_VERSION_1, @@ -54,7 +54,7 @@ impl<'a> Credential for CredentialProcessCredential { args: args.to_vec(), }; let request = serde_json::to_string(&req).context("failed to serialize request")?; - log::debug!("credential-process < {req:?}"); + tracing::debug!("credential-process < {req:?}"); writeln!(input_to_child, "{request}").context("failed to write to credential provider")?; buffer.clear(); @@ -63,7 +63,7 @@ impl<'a> Credential for CredentialProcessCredential { .context("failed to read response from credential provider")?; let response: Result = serde_json::from_str(&buffer).context("failed to deserialize response")?; - log::debug!("credential-process > {response:?}"); + tracing::debug!("credential-process > {response:?}"); drop(input_to_child); let status = child.wait().context("credential process never started")?; if !status.success() { @@ -74,7 +74,7 @@ impl<'a> Credential for CredentialProcessCredential { ) .into()); } - log::trace!("credential process exited successfully"); + tracing::trace!("credential process exited successfully"); response } } diff --git a/src/cargo/util/diagnostic_server.rs b/src/cargo/util/diagnostic_server.rs index 36215735be27..f8eeabfc29dc 100644 --- a/src/cargo/util/diagnostic_server.rs +++ b/src/cargo/util/diagnostic_server.rs @@ -11,8 +11,8 @@ use std::thread::{self, JoinHandle}; use anyhow::{Context, Error}; use cargo_util::ProcessBuilder; -use log::warn; use serde::{Deserialize, Serialize}; +use tracing::warn; use crate::core::Edition; use crate::util::errors::CargoResult; diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 91258c53c08b..9589e1ae33ec 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -87,7 +87,9 @@ impl HttpNotSuccessful { .headers .iter() .filter(|header| { - let Some((name, _)) = header.split_once(":") else { return false }; + let Some((name, _)) = header.split_once(":") else { + return false; + }; DEBUG_HEADERS.contains(&name.to_ascii_lowercase().trim()) }) .collect(); diff --git a/src/cargo/util/job.rs b/src/cargo/util/job.rs index f2bcf94a26b1..1d68fc4338d6 100644 --- a/src/cargo/util/job.rs +++ b/src/cargo/util/job.rs @@ -49,7 +49,7 @@ mod imp { use std::ptr; use std::ptr::addr_of; - use log::info; + use tracing::info; use windows_sys::Win32::Foundation::CloseHandle; use windows_sys::Win32::Foundation::HANDLE; diff --git a/src/cargo/util/network/http.rs b/src/cargo/util/network/http.rs index f077ce2b6409..e5e429611f78 100644 --- a/src/cargo/util/network/http.rs +++ b/src/cargo/util/network/http.rs @@ -8,8 +8,8 @@ use curl::easy::Easy; use curl::easy::InfoType; use curl::easy::SslOpt; use curl::easy::SslVersion; -use log::log; -use log::Level; +use tracing::debug; +use tracing::trace; use crate::util::config::SslVersionConfig; use crate::util::config::SslVersionConfigRange; @@ -135,14 +135,19 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult< if let Some(true) = http.debug { handle.verbose(true)?; - log::debug!("{:#?}", curl::Version::get()); + tracing::debug!("{:#?}", curl::Version::get()); handle.debug_function(|kind, data| { + enum LogLevel { + Debug, + Trace, + } + use LogLevel::*; let (prefix, level) = match kind { - InfoType::Text => ("*", Level::Debug), - InfoType::HeaderIn => ("<", Level::Debug), - InfoType::HeaderOut => (">", Level::Debug), - InfoType::DataIn => ("{", Level::Trace), - InfoType::DataOut => ("}", Level::Trace), + InfoType::Text => ("*", Debug), + InfoType::HeaderIn => ("<", Debug), + InfoType::HeaderOut => (">", Debug), + InfoType::DataIn => ("{", Trace), + InfoType::DataOut => ("}", Trace), InfoType::SslDataIn | InfoType::SslDataOut => return, _ => return, }; @@ -159,16 +164,18 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult< } else if starts_with_ignore_case(line, "set-cookie") { line = "set-cookie: [REDACTED]"; } - log!(level, "http-debug: {} {}", prefix, line); + match level { + Debug => debug!("http-debug: {prefix} {line}"), + Trace => trace!("http-debug: {prefix} {line}"), + } } } Err(_) => { - log!( - level, - "http-debug: {} ({} bytes of data)", - prefix, - data.len() - ); + let len = data.len(); + match level { + Debug => debug!("http-debug: {prefix} ({len} bytes of data)"), + Trace => trace!("http-debug: {prefix} ({len} bytes of data)"), + } } } })?; diff --git a/src/cargo/util/network/mod.rs b/src/cargo/util/network/mod.rs index b078fa3527d2..5db594945151 100644 --- a/src/cargo/util/network/mod.rs +++ b/src/cargo/util/network/mod.rs @@ -29,7 +29,7 @@ macro_rules! try_old_curl { let result = $e; if cfg!(target_os = "macos") { if let Err(e) = result { - ::log::warn!("ignoring libcurl {} error: {}", $msg, e); + ::tracing::warn!("ignoring libcurl {} error: {}", $msg, e); } } else { use ::anyhow::Context; diff --git a/src/cargo/util/network/sleep.rs b/src/cargo/util/network/sleep.rs index d4105065e29e..fab53263b7d7 100644 --- a/src/cargo/util/network/sleep.rs +++ b/src/cargo/util/network/sleep.rs @@ -68,7 +68,7 @@ impl SleepTracker { let now = Instant::now(); let mut result = Vec::new(); while let Some(next) = self.heap.peek() { - log::debug!("ERIC: now={now:?} next={:?}", next.wakeup); + tracing::debug!("ERIC: now={now:?} next={:?}", next.wakeup); if next.wakeup < now { result.push(self.heap.pop().unwrap().data); } else { diff --git a/src/cargo/util/rustc.rs b/src/cargo/util/rustc.rs index 3f1da64d4312..238145af6810 100644 --- a/src/cargo/util/rustc.rs +++ b/src/cargo/util/rustc.rs @@ -6,8 +6,8 @@ use std::sync::Mutex; use anyhow::Context as _; use cargo_util::{paths, ProcessBuilder, ProcessError}; -use log::{debug, info, warn}; use serde::{Deserialize, Serialize}; +use tracing::{debug, info, warn}; use crate::util::interning::InternedString; use crate::util::{profile, CargoResult, Config, StableHasher}; diff --git a/src/cargo/util/toml/embedded.rs b/src/cargo/util/toml/embedded.rs index cd0c7c6ee3a8..395430c1b58d 100644 --- a/src/cargo/util/toml/embedded.rs +++ b/src/cargo/util/toml/embedded.rs @@ -18,7 +18,7 @@ pub fn expand_manifest( let comment = match extract_comment(content) { Ok(comment) => Some(comment), Err(err) => { - log::trace!("failed to extract doc comment: {err}"); + tracing::trace!("failed to extract doc comment: {err}"); None } } @@ -26,7 +26,7 @@ pub fn expand_manifest( let manifest = match extract_manifest(&comment)? { Some(manifest) => Some(manifest), None => { - log::trace!("failed to extract manifest"); + tracing::trace!("failed to extract manifest"); None } } diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 284c5dd35d15..963c4afaa925 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -11,12 +11,12 @@ use cargo_platform::Platform; use cargo_util::paths; use itertools::Itertools; use lazycell::LazyCell; -use log::{debug, trace}; use semver::{self, VersionReq}; use serde::de::IntoDeserializer as _; use serde::de::{self, Unexpected}; use serde::ser; use serde::{Deserialize, Serialize}; +use tracing::{debug, trace}; use url::Url; use crate::core::compiler::{CompileKind, CompileTarget}; diff --git a/src/doc/contrib/src/implementation/debugging.md b/src/doc/contrib/src/implementation/debugging.md index e148d72c36b6..03940e2ffe1a 100644 --- a/src/doc/contrib/src/implementation/debugging.md +++ b/src/doc/contrib/src/implementation/debugging.md @@ -2,11 +2,11 @@ ## Logging -Cargo uses the [`env_logger`] crate to display debug log messages. The -`CARGO_LOG` environment variable can be set to enable debug logging, with a -value such as `trace`, `debug`, or `warn`. It also supports filtering for -specific modules. Feel free to use the standard [`log`] macros to help with -diagnosing problems. +Cargo uses the [`tracing`] crate to display debug log messages. +The `CARGO_LOG` environment variable can be set to enable debug logging, with a value such as `trace`, `debug`, or `warn`. +It also supports filtering for specific modules with comma-separated [directives]. +Feel free to use [shorthand macros] to help with diagnosing problems. +We're looking forward to making Cargo logging mechanism more structural! ```sh # Outputs all logs with levels debug and higher @@ -22,5 +22,6 @@ CARGO_HTTP_DEBUG=true CARGO_LOG=cargo::ops::registry=debug cargo fetch CARGO_LOG=cargo::core::compiler::fingerprint=trace cargo build ``` -[`env_logger`]: https://docs.rs/env_logger -[`log`]: https://docs.rs/log +[`tracing`]: https://docs.rs/tracing +[directive]: https://docs.rs/tracing_subscriber/filter/struct.EnvFilter.html#directives +[shorthand macros]: https://docs.rs/tracing/index.html#shorthand-macros diff --git a/src/doc/src/reference/environment-variables.md b/src/doc/src/reference/environment-variables.md index ab0562cc1fe8..25881d1388de 100644 --- a/src/doc/src/reference/environment-variables.md +++ b/src/doc/src/reference/environment-variables.md @@ -9,7 +9,7 @@ with them: You can override these environment variables to change Cargo's behavior on your system: -* `CARGO_LOG` --- Cargo uses the [`env_logger`] crate to display debug log messages. +* `CARGO_LOG` --- Cargo uses the [`tracing`] crate to display debug log messages. The `CARGO_LOG` environment variable can be set to enable debug logging, with a value such as `trace`, `debug`, or `warn`. Usually it is only used during debugging. For more details refer to the @@ -389,7 +389,7 @@ let out_dir = env::var("OUT_DIR").unwrap(); the environment; scripts should use `CARGO_ENCODED_RUSTFLAGS` instead. * `CARGO_PKG_` --- The package information variables, with the same names and values as are [provided during crate building][variables set for crates]. -[`env_logger`]: https://docs.rs/env_logger +[`tracing`]: https://docs.rs/tracing [debug logging]: https://doc.crates.io/contrib/architecture/console.html#debug-logging [unix-like platforms]: ../../reference/conditional-compilation.html#unix-and-windows [windows-like platforms]: ../../reference/conditional-compilation.html#unix-and-windows diff --git a/tests/testsuite/alt_registry.rs b/tests/testsuite/alt_registry.rs index ac60ca92fa88..91157cd5327c 100644 --- a/tests/testsuite/alt_registry.rs +++ b/tests/testsuite/alt_registry.rs @@ -1506,3 +1506,44 @@ fn publish_with_transitive_dep() { .build(); p2.cargo("publish").run(); } + +#[cargo_test] +fn warn_for_unused_fields() { + let _ = RegistryBuilder::new() + .no_configure_token() + .alternative() + .build(); + let p = project() + .file("src/lib.rs", "") + .file( + ".cargo/config.toml", + "[registry] + unexpected-field = 'foo' + [registries.alternative] + unexpected-field = 'foo' + ", + ) + .build(); + + p.cargo("publish --registry alternative") + .with_status(101) + .with_stderr( + "\ +[UPDATING] `alternative` index +[WARNING] unused config key `registries.alternative.unexpected-field` in `[..]config.toml` +[ERROR] no token found for `alternative`, please run `cargo login --registry alternative` +or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN", + ) + .run(); + + p.cargo("publish --registry crates-io") + .with_status(101) + .with_stderr( + "\ +[UPDATING] crates.io index +[WARNING] unused config key `registry.unexpected-field` in `[..]config.toml` +[ERROR] no token found, please run `cargo login` +or use environment variable CARGO_REGISTRY_TOKEN", + ) + .run(); +} diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index 4840356c6bae..400d10547c43 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -5140,6 +5140,35 @@ for more information about build script outputs. .run(); } +#[cargo_test] +fn wrong_syntax_with_two_colons() { + let p = project() + .file("src/lib.rs", "") + .file( + "build.rs", + r#" + fn main() { + println!("cargo::foo=bar"); + } + "#, + ) + .build(); + + p.cargo("build") + .with_status(101) + .with_stderr( + "\ +[COMPILING] foo [..] +error: unsupported output in build script of `foo v0.0.1 ([ROOT]/foo)`: `cargo::foo=bar` +Found a `cargo::key=value` build directive which is reserved for future use. +Either change the directive to `cargo:key=value` syntax (note the single `:`) or upgrade your version of Rust. +See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \ +for more information about build script outputs. +", + ) + .run(); +} + #[cargo_test] fn custom_build_closes_stdin() { // Ensure stdin is closed to prevent deadlock. diff --git a/tests/testsuite/cargo/help/stdout.log b/tests/testsuite/cargo/help/stdout.log index 8f06dcb2652f..26bcd745bd60 100644 --- a/tests/testsuite/cargo/help/stdout.log +++ b/tests/testsuite/cargo/help/stdout.log @@ -4,7 +4,6 @@ Usage: cargo [..][OPTIONS] [COMMAND] cargo [..][OPTIONS] -Zscript [ARGS]... Options: - -h, --help Print help -V, --version Print version info and exit --list List installed commands --explain Run `rustc --explain CODE` @@ -17,6 +16,7 @@ Options: --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help Some common cargo commands are (see all commands with --list): build, b Compile the current package diff --git a/tests/testsuite/cargo_add/help/stdout.log b/tests/testsuite/cargo_add/help/stdout.log index 0bb8781853f1..0daba1a94978 100644 --- a/tests/testsuite/cargo_add/help/stdout.log +++ b/tests/testsuite/cargo_add/help/stdout.log @@ -42,20 +42,11 @@ Options: --ignore-rust-version Ignore `rust-version` specification in packages (unstable) - --manifest-path - Path to Cargo.toml - - -p, --package [] - Package to modify - - -q, --quiet - Do not print cargo log messages - --dry-run Don't actually write the manifest - -h, --help - Print help (see a summary with '-h') + -q, --quiet + Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) @@ -63,6 +54,19 @@ Options: --color Coloring: auto, always, never + --config + Override a configuration value + + -Z + Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + + -h, --help + Print help (see a summary with '-h') + +Manifest Options: + --manifest-path + Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date @@ -72,11 +76,9 @@ Options: --offline Run without accessing the network - --config - Override a configuration value - - -Z - Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details +Package Selection: + -p, --package [] + Package to modify Source: --path diff --git a/tests/testsuite/cargo_bench/help/stdout.log b/tests/testsuite/cargo_bench/help/stdout.log index 09f36154a5f1..4fe8cb5e2635 100644 --- a/tests/testsuite/cargo_bench/help/stdout.log +++ b/tests/testsuite/cargo_bench/help/stdout.log @@ -7,44 +7,54 @@ Arguments: [args]... Arguments for the bench binary Options: - -q, --quiet Do not print cargo log messages - --lib Benchmark only this package's library - --bins Benchmark all binaries - --bin [] Benchmark only the specified binary - --examples Benchmark all examples - --example [] Benchmark only the specified example - --tests Benchmark all tests - --test [] Benchmark only the specified test target - --benches Benchmark all benches - --bench [] Benchmark only the specified bench target - --all-targets Benchmark all targets - --no-run Compile, but don't run benchmarks - -p, --package [] Package to run benchmarks for - --workspace Benchmark all packages in the workspace - --exclude Exclude packages from the benchmark - --all Alias for --workspace (deprecated) + --no-run Compile, but don't run benchmarks + --no-fail-fast Run all benchmarks regardless of failure + --ignore-rust-version Ignore `rust-version` specification in packages + --message-format Error format + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for + details + -h, --help Print help + +Package Selection: + -p, --package [] Package to run benchmarks for + --workspace Benchmark all packages in the workspace + --exclude Exclude packages from the benchmark + --all Alias for --workspace (deprecated) + +Target Selection: + --lib Benchmark only this package's library + --bins Benchmark all binaries + --bin [] Benchmark only the specified binary + --examples Benchmark all examples + --example [] Benchmark only the specified example + --tests Benchmark all tests + --test [] Benchmark only the specified test target + --benches Benchmark all benches + --bench [] Benchmark only the specified bench target + --all-targets Benchmark all targets + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. --keep-going Do not abort the build as soon as there is an error (unstable) --profile Build artifacts with the specified profile - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature --target Build for the target triple --target-dir Directory for all generated artifacts - --manifest-path Path to Cargo.toml - --ignore-rust-version Ignore `rust-version` specification in packages - --message-format Error format - --no-fail-fast Run all benchmarks regardless of failure --unit-graph Output build graph in JSON (unstable) --timings[=] Timing output formats (unstable) (comma separated): html, json - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help bench` for more detailed information. diff --git a/tests/testsuite/cargo_build/help/stdout.log b/tests/testsuite/cargo_build/help/stdout.log index 1f13061b8a73..af906c24f428 100644 --- a/tests/testsuite/cargo_build/help/stdout.log +++ b/tests/testsuite/cargo_build/help/stdout.log @@ -3,46 +3,56 @@ Compile a local package and all of its dependencies Usage: cargo[EXE] build [OPTIONS] Options: + --ignore-rust-version Ignore `rust-version` specification in packages + --future-incompat-report Outputs a future incompatibility report at the end of the build + --message-format Error format -q, --quiet Do not print cargo log messages - -p, --package [] Package to build (see `cargo help pkgid`) - --workspace Build all packages in the workspace - --exclude Exclude packages from the build - --all Alias for --workspace (deprecated) - -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) - --lib Build only this package's library - --bins Build all binaries - --bin [] Build only the specified binary - --examples Build all examples - --example [] Build only the specified example - --tests Build all tests - --test [] Build only the specified test target - --benches Build all benches - --bench [] Build only the specified bench target - --all-targets Build all targets + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for + details + -h, --help Print help + +Package Selection: + -p, --package [] Package to build (see `cargo help pkgid`) + --workspace Build all packages in the workspace + --exclude Exclude packages from the build + --all Alias for --workspace (deprecated) + +Target Selection: + --lib Build only this package's library + --bins Build all binaries + --bin [] Build only the specified binary + --examples Build all examples + --example [] Build only the specified example + --tests Build all tests + --test [] Build only the specified test target + --benches Build all benches + --bench [] Build only the specified bench target + --all-targets Build all targets + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: -r, --release Build artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature + -j, --jobs Number of parallel jobs, defaults to # of CPUs. + --keep-going Do not abort the build as soon as there is an error (unstable) --target Build for the target triple --target-dir Directory for all generated artifacts --out-dir Copy final artifacts to this directory (unstable) - --manifest-path Path to Cargo.toml - --ignore-rust-version Ignore `rust-version` specification in packages - --message-format Error format --build-plan Output the build plan in JSON (unstable) --unit-graph Output build graph in JSON (unstable) - --future-incompat-report Outputs a future incompatibility report at the end of the build --timings[=] Timing output formats (unstable) (comma separated): html, json - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help build` for more detailed information. diff --git a/tests/testsuite/cargo_check/help/stdout.log b/tests/testsuite/cargo_check/help/stdout.log index 076bcb86947b..7c87615cd72f 100644 --- a/tests/testsuite/cargo_check/help/stdout.log +++ b/tests/testsuite/cargo_check/help/stdout.log @@ -3,44 +3,54 @@ Check a local package and all of its dependencies for errors Usage: cargo[EXE] check [OPTIONS] Options: + --ignore-rust-version Ignore `rust-version` specification in packages + --future-incompat-report Outputs a future incompatibility report at the end of the build + --message-format Error format -q, --quiet Do not print cargo log messages - -p, --package [] Package(s) to check - --workspace Check all packages in the workspace - --exclude Exclude packages from the check - --all Alias for --workspace (deprecated) + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for + details + -h, --help Print help + +Package Selection: + -p, --package [] Package(s) to check + --workspace Check all packages in the workspace + --exclude Exclude packages from the check + --all Alias for --workspace (deprecated) + +Target Selection: + --lib Check only this package's library + --bins Check all binaries + --bin [] Check only the specified binary + --examples Check all examples + --example [] Check only the specified example + --tests Check all tests + --test [] Check only the specified test target + --benches Check all benches + --bench [] Check only the specified bench target + --all-targets Check all targets + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. --keep-going Do not abort the build as soon as there is an error (unstable) - --lib Check only this package's library - --bins Check all binaries - --bin [] Check only the specified binary - --examples Check all examples - --example [] Check only the specified example - --tests Check all tests - --test [] Check only the specified test target - --benches Check all benches - --bench [] Check only the specified bench target - --all-targets Check all targets -r, --release Check artifacts in release mode, with optimizations --profile Check artifacts with the specified profile - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature --target Check for the target triple --target-dir Directory for all generated artifacts - --manifest-path Path to Cargo.toml - --ignore-rust-version Ignore `rust-version` specification in packages - --message-format Error format --unit-graph Output build graph in JSON (unstable) - --future-incompat-report Outputs a future incompatibility report at the end of the build --timings[=] Timing output formats (unstable) (comma separated): html, json - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help check` for more detailed information. diff --git a/tests/testsuite/cargo_clean/help/stdout.log b/tests/testsuite/cargo_clean/help/stdout.log index ea2f0ef0bf85..fd3c8855c508 100644 --- a/tests/testsuite/cargo_clean/help/stdout.log +++ b/tests/testsuite/cargo_clean/help/stdout.log @@ -3,22 +3,27 @@ Remove artifacts that cargo has generated in the past Usage: cargo[EXE] clean [OPTIONS] Options: - -q, --quiet Do not print cargo log messages - -p, --package [] Package to clean artifacts for - --manifest-path Path to Cargo.toml - --target Target triple to clean output for - --target-dir Directory for all generated artifacts + --doc Whether or not to clean just the documentation directory + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Package Selection: + -p, --package [] Package to clean artifacts for + +Compilation Options: -r, --release Whether or not to clean release artifacts --profile Clean artifacts of the specified profile - --doc Whether or not to clean just the documentation directory - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + --target Target triple to clean output for + --target-dir Directory for all generated artifacts + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help clean` for more detailed information. diff --git a/tests/testsuite/cargo_config/help/stdout.log b/tests/testsuite/cargo_config/help/stdout.log index 947b6e38fa59..50caca72a4cb 100644 --- a/tests/testsuite/cargo_config/help/stdout.log +++ b/tests/testsuite/cargo_config/help/stdout.log @@ -6,11 +6,13 @@ Commands: get Options: - -h, --help Print help -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network diff --git a/tests/testsuite/cargo_doc/help/stdout.log b/tests/testsuite/cargo_doc/help/stdout.log index 51e5d14bb0ea..480e189c10e4 100644 --- a/tests/testsuite/cargo_doc/help/stdout.log +++ b/tests/testsuite/cargo_doc/help/stdout.log @@ -3,41 +3,51 @@ Build a package's documentation Usage: cargo[EXE] doc [OPTIONS] Options: - -q, --quiet Do not print cargo log messages --open Opens the docs in a browser after the operation - -p, --package [] Package to document - --workspace Document all packages in the workspace - --exclude Exclude packages from the build - --all Alias for --workspace (deprecated) --no-deps Don't build documentation for dependencies --document-private-items Document private items + --ignore-rust-version Ignore `rust-version` specification in packages + --message-format Error format + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for + details + -h, --help Print help + +Package Selection: + -p, --package [] Package to document + --workspace Document all packages in the workspace + --exclude Exclude packages from the build + --all Alias for --workspace (deprecated) + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Target Selection: + --lib Document only this package's library + --bins Document all binaries + --bin [] Document only the specified binary + --examples Document all examples + --example [] Document only the specified example + +Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. --keep-going Do not abort the build as soon as there is an error (unstable) - --lib Document only this package's library - --bins Document all binaries - --bin [] Document only the specified binary - --examples Document all examples - --example [] Document only the specified example -r, --release Build artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature --target Build for the target triple --target-dir Directory for all generated artifacts - --manifest-path Path to Cargo.toml - --message-format Error format - --ignore-rust-version Ignore `rust-version` specification in packages --unit-graph Output build graph in JSON (unstable) --timings[=] Timing output formats (unstable) (comma separated): html, json - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help doc` for more detailed information. diff --git a/tests/testsuite/cargo_features.rs b/tests/testsuite/cargo_features.rs index 6e5531431749..ed5f53a1e6d4 100644 --- a/tests/testsuite/cargo_features.rs +++ b/tests/testsuite/cargo_features.rs @@ -295,6 +295,7 @@ fn allow_features_to_rustc() { .file( "src/lib.rs", r#" + #![allow(internal_features)] #![feature(test_2018_feature)] "#, ) diff --git a/tests/testsuite/cargo_fetch/help/stdout.log b/tests/testsuite/cargo_fetch/help/stdout.log index 9fbb295b67be..b9bd6c35bb19 100644 --- a/tests/testsuite/cargo_fetch/help/stdout.log +++ b/tests/testsuite/cargo_fetch/help/stdout.log @@ -3,17 +3,20 @@ Fetch dependencies of a package from the network Usage: cargo[EXE] fetch [OPTIONS] Options: - -q, --quiet Do not print cargo log messages + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Compilation Options: + --target Fetch dependencies for the target triple + +Manifest Options: --manifest-path Path to Cargo.toml - --target Fetch dependencies for the target triple - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details Run `cargo help fetch` for more detailed information. diff --git a/tests/testsuite/cargo_fix/help/stdout.log b/tests/testsuite/cargo_fix/help/stdout.log index 42d486da7766..c0a98218a230 100644 --- a/tests/testsuite/cargo_fix/help/stdout.log +++ b/tests/testsuite/cargo_fix/help/stdout.log @@ -3,48 +3,58 @@ Automatically fix lint warnings reported by rustc Usage: cargo[EXE] fix [OPTIONS] Options: - -q, --quiet Do not print cargo log messages - -p, --package [] Package(s) to fix - --workspace Fix all packages in the workspace - --exclude Exclude packages from the fixes - --all Alias for --workspace (deprecated) + --edition Fix in preparation for the next edition + --edition-idioms Fix warnings to migrate to the idioms of an edition + --broken-code Fix code even if it already has compiler errors + --allow-no-vcs Fix code even if a VCS was not detected + --allow-dirty Fix code even if the working directory is dirty + --allow-staged Fix code even if the working directory has staged changes + --ignore-rust-version Ignore `rust-version` specification in packages + --message-format Error format + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for + details + -h, --help Print help + +Package Selection: + -p, --package [] Package(s) to fix + --workspace Fix all packages in the workspace + --exclude Exclude packages from the fixes + --all Alias for --workspace (deprecated) + +Target Selection: + --lib Fix only this package's library + --bins Fix all binaries + --bin [] Fix only the specified binary + --examples Fix all examples + --example [] Fix only the specified example + --tests Fix all tests + --test [] Fix only the specified test target + --benches Fix all benches + --bench [] Fix only the specified bench target + --all-targets Fix all targets (default) + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. --keep-going Do not abort the build as soon as there is an error (unstable) - --lib Fix only this package's library - --bins Fix all binaries - --bin [] Fix only the specified binary - --examples Fix all examples - --example [] Fix only the specified example - --tests Fix all tests - --test [] Fix only the specified test target - --benches Fix all benches - --bench [] Fix only the specified bench target - --all-targets Fix all targets (default) -r, --release Fix artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature --target Fix for the target triple --target-dir Directory for all generated artifacts - --manifest-path Path to Cargo.toml - --message-format Error format - --broken-code Fix code even if it already has compiler errors - --edition Fix in preparation for the next edition - --edition-idioms Fix warnings to migrate to the idioms of an edition - --allow-no-vcs Fix code even if a VCS was not detected - --allow-dirty Fix code even if the working directory is dirty - --allow-staged Fix code even if the working directory has staged changes - --ignore-rust-version Ignore `rust-version` specification in packages --timings[=] Timing output formats (unstable) (comma separated): html, json - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help fix` for more detailed information. diff --git a/tests/testsuite/cargo_generate_lockfile/help/stdout.log b/tests/testsuite/cargo_generate_lockfile/help/stdout.log index 9d6c0880eb0f..07eff888a20e 100644 --- a/tests/testsuite/cargo_generate_lockfile/help/stdout.log +++ b/tests/testsuite/cargo_generate_lockfile/help/stdout.log @@ -3,16 +3,17 @@ Generate the lockfile for a package Usage: cargo[EXE] generate-lockfile [OPTIONS] Options: - -q, --quiet Do not print cargo log messages + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: --manifest-path Path to Cargo.toml - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details Run `cargo help generate-lockfile` for more detailed information. diff --git a/tests/testsuite/cargo_help/help/stdout.log b/tests/testsuite/cargo_help/help/stdout.log index 364a47acc2a9..a03946b45ff8 100644 --- a/tests/testsuite/cargo_help/help/stdout.log +++ b/tests/testsuite/cargo_help/help/stdout.log @@ -6,11 +6,13 @@ Arguments: [COMMAND] Options: - -h, --help Print help -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network diff --git a/tests/testsuite/cargo_init/help/stdout.log b/tests/testsuite/cargo_init/help/stdout.log index 2da1fe534f4c..5dfb02498d7f 100644 --- a/tests/testsuite/cargo_init/help/stdout.log +++ b/tests/testsuite/cargo_init/help/stdout.log @@ -6,8 +6,6 @@ Arguments: [path] [default: .] Options: - -q, --quiet Do not print cargo log messages - --registry Registry to use --vcs Initialize a new repository for the given version control system (git, hg, pijul, or fossil) or do not initialize any version control at all (none), overriding a global configuration. [possible values: git, hg, @@ -17,13 +15,17 @@ Options: --edition Edition to set for the crate generated [possible values: 2015, 2018, 2021] --name Set the resulting package name, defaults to the directory name - -h, --help Print help + --registry Registry to use + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help init` for more detailed information. diff --git a/tests/testsuite/cargo_install/help/stdout.log b/tests/testsuite/cargo_install/help/stdout.log index 8fb61711a40f..a07fa47f6fd3 100644 --- a/tests/testsuite/cargo_install/help/stdout.log +++ b/tests/testsuite/cargo_install/help/stdout.log @@ -6,43 +6,51 @@ Arguments: [crate]... Options: - -q, --quiet Do not print cargo log messages - --version Specify a version to install - --git Git URL to install the specified crate from - --branch Branch to use when installing from git - --tag Tag to use when installing from git - --rev Specific commit to use when installing from git - --path Filesystem path to local crate to install - --list list all installed packages and their versions + --version Specify a version to install + --index Registry index to install from + --registry Registry to use + --git Git URL to install the specified crate from + --branch Branch to use when installing from git + --tag Tag to use when installing from git + --rev Specific commit to use when installing from git + --path Filesystem path to local crate to install + --root Directory to install packages into + -f, --force Force overwriting existing crates or binaries + --no-track Do not save tracking information + --list list all installed packages and their versions + --ignore-rust-version Ignore `rust-version` specification in packages + --message-format Error format + -q, --quiet Do not print cargo log messages + --debug Build in debug mode (with the 'dev' profile) instead of release mode + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for + details + -h, --help Print help + +Target Selection: + --bin [] Install only the specified binary + --bins Install all binaries + --example [] Install only the specified example + --examples Install all examples + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. --keep-going Do not abort the build as soon as there is an error (unstable) - -f, --force Force overwriting existing crates or binaries - --no-track Do not save tracking information - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature --profile Install artifacts with the specified profile - --debug Build in debug mode (with the 'dev' profile) instead of release mode - --bin [] Install only the specified binary - --bins Install all binaries - --example [] Install only the specified example - --examples Install all examples --target Build for the target triple --target-dir Directory for all generated artifacts - --root Directory to install packages into - --index Registry index to install from - --registry Registry to use - --ignore-rust-version Ignore `rust-version` specification in packages - --message-format Error format --timings[=] Timing output formats (unstable) (comma separated): html, json - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help install` for more detailed information. diff --git a/tests/testsuite/cargo_locate_project/help/stdout.log b/tests/testsuite/cargo_locate_project/help/stdout.log index 584a27a64f3c..1c6ea7b25611 100644 --- a/tests/testsuite/cargo_locate_project/help/stdout.log +++ b/tests/testsuite/cargo_locate_project/help/stdout.log @@ -3,18 +3,20 @@ Print a JSON representation of a Cargo.toml file's location Usage: cargo[EXE] locate-project [OPTIONS] Options: - -q, --quiet Do not print cargo log messages - --manifest-path Path to Cargo.toml - --message-format Output representation [possible values: json, plain] --workspace Locate Cargo.toml of the workspace root - -h, --help Print help + --message-format Output representation [possible values: json, plain] + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help locate-project` for more detailed information. diff --git a/tests/testsuite/cargo_login/help/stdout.log b/tests/testsuite/cargo_login/help/stdout.log index 3a327fdf26cd..6d426ad2d5da 100644 --- a/tests/testsuite/cargo_login/help/stdout.log +++ b/tests/testsuite/cargo_login/help/stdout.log @@ -6,15 +6,17 @@ Arguments: [token] Options: - -q, --quiet Do not print cargo log messages --registry Registry to use - -h, --help Print help + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help login` for more detailed information. diff --git a/tests/testsuite/cargo_logout/help/stdout.log b/tests/testsuite/cargo_logout/help/stdout.log index 8585c6f1adcf..fe328d765a92 100644 --- a/tests/testsuite/cargo_logout/help/stdout.log +++ b/tests/testsuite/cargo_logout/help/stdout.log @@ -3,15 +3,17 @@ Remove an API token from the registry locally Usage: cargo[EXE] logout [OPTIONS] Options: - -q, --quiet Do not print cargo log messages --registry Registry to use - -h, --help Print help + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help logout` for more detailed information. diff --git a/tests/testsuite/cargo_metadata/help/stdout.log b/tests/testsuite/cargo_metadata/help/stdout.log index 199b5a4b8d69..939fc40c9c0f 100644 --- a/tests/testsuite/cargo_metadata/help/stdout.log +++ b/tests/testsuite/cargo_metadata/help/stdout.log @@ -4,23 +4,27 @@ machine-readable format Usage: cargo[EXE] metadata [OPTIONS] Options: - -q, --quiet Do not print cargo log messages - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature --filter-platform Only include resolve dependencies matching the given target-triple --no-deps Output information only about the workspace members and don't fetch dependencies - --manifest-path Path to Cargo.toml --format-version Format version [possible values: 1] - -h, --help Print help + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help metadata` for more detailed information. diff --git a/tests/testsuite/cargo_new/help/stdout.log b/tests/testsuite/cargo_new/help/stdout.log index 47ff8f3055a8..7252e0da1f04 100644 --- a/tests/testsuite/cargo_new/help/stdout.log +++ b/tests/testsuite/cargo_new/help/stdout.log @@ -6,8 +6,6 @@ Arguments: Options: - -q, --quiet Do not print cargo log messages - --registry Registry to use --vcs Initialize a new repository for the given version control system (git, hg, pijul, or fossil) or do not initialize any version control at all (none), overriding a global configuration. [possible values: git, hg, @@ -17,13 +15,17 @@ Options: --edition Edition to set for the crate generated [possible values: 2015, 2018, 2021] --name Set the resulting package name, defaults to the directory name - -h, --help Print help + --registry Registry to use + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help new` for more detailed information. diff --git a/tests/testsuite/cargo_owner/help/stdout.log b/tests/testsuite/cargo_owner/help/stdout.log index 5ee24005d8a2..3c8495ff02ae 100644 --- a/tests/testsuite/cargo_owner/help/stdout.log +++ b/tests/testsuite/cargo_owner/help/stdout.log @@ -6,20 +6,22 @@ Arguments: [crate] Options: - -q, --quiet Do not print cargo log messages -a, --add Name of a user or team to invite as an owner -r, --remove Name of a user or team to remove as an owner -l, --list List owners of a crate --index Registry index to modify owners for --token API token to use when authenticating --registry Registry to use - -h, --help Print help + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help owner` for more detailed information. diff --git a/tests/testsuite/cargo_package/help/stdout.log b/tests/testsuite/cargo_package/help/stdout.log index cae5aa145643..35e32f3133de 100644 --- a/tests/testsuite/cargo_package/help/stdout.log +++ b/tests/testsuite/cargo_package/help/stdout.log @@ -3,30 +3,37 @@ Assemble the local package into a distributable tarball Usage: cargo[EXE] package [OPTIONS] Options: - -q, --quiet Do not print cargo log messages - -l, --list Print files included in a package without making one - --no-verify Don't verify the contents by building them - --no-metadata Ignore warnings about a lack of human-usable metadata - --allow-dirty Allow dirty working directories to be packaged + -l, --list Print files included in a package without making one + --no-verify Don't verify the contents by building them + --no-metadata Ignore warnings about a lack of human-usable metadata + --allow-dirty Allow dirty working directories to be packaged + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Package Selection: + -p, --package [] Package(s) to assemble + --workspace Assemble all packages in the workspace + --exclude Don't assemble specified packages + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: --target Build for the target triple --target-dir Directory for all generated artifacts - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature - -p, --package [] Package(s) to assemble - --workspace Assemble all packages in the workspace - --exclude Don't assemble specified packages - --manifest-path Path to Cargo.toml -j, --jobs Number of parallel jobs, defaults to # of CPUs. --keep-going Do not abort the build as soon as there is an error (unstable) - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help package` for more detailed information. diff --git a/tests/testsuite/cargo_pkgid/help/stdout.log b/tests/testsuite/cargo_pkgid/help/stdout.log index b00a2e9c456f..ed48bb7ea83b 100644 --- a/tests/testsuite/cargo_pkgid/help/stdout.log +++ b/tests/testsuite/cargo_pkgid/help/stdout.log @@ -6,17 +6,20 @@ Arguments: [spec] Options: - -q, --quiet Do not print cargo log messages - -p, --package [] Argument to get the package ID specifier for + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Package Selection: + -p, --package [] Argument to get the package ID specifier for + +Manifest Options: --manifest-path Path to Cargo.toml - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details Run `cargo help pkgid` for more detailed information. diff --git a/tests/testsuite/cargo_publish/help/stdout.log b/tests/testsuite/cargo_publish/help/stdout.log index 4ed02b0a5be9..c02522887a83 100644 --- a/tests/testsuite/cargo_publish/help/stdout.log +++ b/tests/testsuite/cargo_publish/help/stdout.log @@ -3,30 +3,37 @@ Upload a package to the registry Usage: cargo[EXE] publish [OPTIONS] Options: - -q, --quiet Do not print cargo log messages - --index Registry index URL to upload the package to - --token Token to use when uploading - --no-verify Don't verify the contents by building them - --allow-dirty Allow dirty working directories to be packaged - --target Build for the target triple - --target-dir Directory for all generated artifacts - -p, --package [] Package to publish - --manifest-path Path to Cargo.toml - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature + --dry-run Perform all checks without uploading + --index Registry index URL to upload the package to + --registry Registry to publish to + --token Token to use when uploading + --no-verify Don't verify the contents by building them + --allow-dirty Allow dirty working directories to be packaged + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Package Selection: + -p, --package [] Package to publish + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. --keep-going Do not abort the build as soon as there is an error (unstable) - --dry-run Perform all checks without uploading - --registry Registry to publish to - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + --target Build for the target triple + --target-dir Directory for all generated artifacts + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help publish` for more detailed information. diff --git a/tests/testsuite/cargo_read_manifest/help/stdout.log b/tests/testsuite/cargo_read_manifest/help/stdout.log index 038fc4d6fdb7..83db5413d92d 100644 --- a/tests/testsuite/cargo_read_manifest/help/stdout.log +++ b/tests/testsuite/cargo_read_manifest/help/stdout.log @@ -5,14 +5,15 @@ Deprecated, use `cargo metadata --no-deps` instead. Usage: cargo[EXE] read-manifest [OPTIONS] Options: - -q, --quiet Do not print cargo log messages + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: --manifest-path Path to Cargo.toml - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details diff --git a/tests/testsuite/cargo_remove/help/stdout.log b/tests/testsuite/cargo_remove/help/stdout.log index 1b1c1fa1e30e..81a2d78b690b 100644 --- a/tests/testsuite/cargo_remove/help/stdout.log +++ b/tests/testsuite/cargo_remove/help/stdout.log @@ -6,21 +6,24 @@ Arguments: ... Dependencies to be removed Options: - -p, --package [] Package to remove from - --manifest-path Path to Cargo.toml - -q, --quiet Do not print cargo log messages - --dry-run Don't actually write the manifest - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + --dry-run Don't actually write the manifest + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help Section: --dev Remove as development dependency --build Remove as build dependency --target Remove as dependency from the given target platform + +Package Selection: + -p, --package [] Package to remove from + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network diff --git a/tests/testsuite/cargo_report/help/stdout.log b/tests/testsuite/cargo_report/help/stdout.log index 1048c5e43acd..67819de55c4a 100644 --- a/tests/testsuite/cargo_report/help/stdout.log +++ b/tests/testsuite/cargo_report/help/stdout.log @@ -6,13 +6,15 @@ Commands: future-incompatibilities Reports any crates which will eventually stop compiling Options: - -h, --help Print help -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help report` for more detailed information. diff --git a/tests/testsuite/cargo_run/help/stdout.log b/tests/testsuite/cargo_run/help/stdout.log index e48a32edf67f..6ab0e76b13fd 100644 --- a/tests/testsuite/cargo_run/help/stdout.log +++ b/tests/testsuite/cargo_run/help/stdout.log @@ -6,32 +6,42 @@ Arguments: [args]... Arguments for the binary or example to run Options: - -q, --quiet Do not print cargo log messages - --bin [] Name of the bin target to run - --example [] Name of the example target to run - -p, --package [] Package with the target to run + --ignore-rust-version Ignore `rust-version` specification in packages + --message-format Error format + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for + details + -h, --help Print help + +Package Selection: + -p, --package [] Package with the target to run + +Target Selection: + --bin [] Name of the bin target to run + --example [] Name of the example target to run + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. --keep-going Do not abort the build as soon as there is an error (unstable) -r, --release Build artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature --target Build for the target triple --target-dir Directory for all generated artifacts - --manifest-path Path to Cargo.toml - --message-format Error format --unit-graph Output build graph in JSON (unstable) - --ignore-rust-version Ignore `rust-version` specification in packages --timings[=] Timing output formats (unstable) (comma separated): html, json - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help run` for more detailed information. diff --git a/tests/testsuite/cargo_rustc/help/stdout.log b/tests/testsuite/cargo_rustc/help/stdout.log index 715d68bedf9a..f587c327687c 100644 --- a/tests/testsuite/cargo_rustc/help/stdout.log +++ b/tests/testsuite/cargo_rustc/help/stdout.log @@ -6,43 +6,53 @@ Arguments: [args]... Extra rustc flags Options: - -q, --quiet Do not print cargo log messages - -p, --package [] Package to build - -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) - --lib Build only this package's library - --bins Build all binaries - --bin [] Build only the specified binary - --examples Build all examples - --example [] Build only the specified example - --tests Build all tests - --test [] Build only the specified test target - --benches Build all benches - --bench [] Build only the specified bench target - --all-targets Build all targets - -r, --release Build artifacts in release mode, with optimizations - --profile Build artifacts with the specified profile - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature - --target Target triple which compiles will be for --print Output compiler information without compiling --crate-type Comma separated list of types of crates for the compiler to emit - --target-dir Directory for all generated artifacts - --manifest-path Path to Cargo.toml - --message-format Error format - --unit-graph Output build graph in JSON (unstable) - --ignore-rust-version Ignore `rust-version` specification in packages --future-incompat-report Outputs a future incompatibility report at the end of the build - --timings[=] Timing output formats (unstable) (comma separated): html, json - -h, --help Print help + --ignore-rust-version Ignore `rust-version` specification in packages + --message-format Error format + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Package Selection: + -p, --package [] Package to build + +Target Selection: + --lib Build only this package's library + --bins Build all binaries + --bin [] Build only the specified binary + --examples Build all examples + --example [] Build only the specified example + --tests Build all tests + --test [] Build only the specified test target + --benches Build all benches + --bench [] Build only the specified bench target + --all-targets Build all targets + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: + -j, --jobs Number of parallel jobs, defaults to # of CPUs. + --keep-going Do not abort the build as soon as there is an error (unstable) + -r, --release Build artifacts in release mode, with optimizations + --profile Build artifacts with the specified profile + --target Target triple which compiles will be for + --target-dir Directory for all generated artifacts + --unit-graph Output build graph in JSON (unstable) + --timings[=] Timing output formats (unstable) (comma separated): html, json + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help rustc` for more detailed information. diff --git a/tests/testsuite/cargo_rustdoc/help/stdout.log b/tests/testsuite/cargo_rustdoc/help/stdout.log index 54de75091c08..4cac29e0af34 100644 --- a/tests/testsuite/cargo_rustdoc/help/stdout.log +++ b/tests/testsuite/cargo_rustdoc/help/stdout.log @@ -6,41 +6,51 @@ Arguments: [args]... Extra rustdoc flags Options: - -q, --quiet Do not print cargo log messages - --open Opens the docs in a browser after the operation - -p, --package [] Package to document + --open Opens the docs in a browser after the operation + --ignore-rust-version Ignore `rust-version` specification in packages + --message-format Error format + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for + details + -h, --help Print help + +Package Selection: + -p, --package [] Package to document + +Target Selection: + --lib Build only this package's library + --bins Build all binaries + --bin [] Build only the specified binary + --examples Build all examples + --example [] Build only the specified example + --tests Build all tests + --test [] Build only the specified test target + --benches Build all benches + --bench [] Build only the specified bench target + --all-targets Build all targets + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. --keep-going Do not abort the build as soon as there is an error (unstable) - --lib Build only this package's library - --bins Build all binaries - --bin [] Build only the specified binary - --examples Build all examples - --example [] Build only the specified example - --tests Build all tests - --test [] Build only the specified test target - --benches Build all benches - --bench [] Build only the specified bench target - --all-targets Build all targets -r, --release Build artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature --target Build for the target triple --target-dir Directory for all generated artifacts - --manifest-path Path to Cargo.toml - --message-format Error format --unit-graph Output build graph in JSON (unstable) - --ignore-rust-version Ignore `rust-version` specification in packages --timings[=] Timing output formats (unstable) (comma separated): html, json - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help rustdoc` for more detailed information. diff --git a/tests/testsuite/cargo_search/help/stdout.log b/tests/testsuite/cargo_search/help/stdout.log index 70876e015e7a..8572064e357c 100644 --- a/tests/testsuite/cargo_search/help/stdout.log +++ b/tests/testsuite/cargo_search/help/stdout.log @@ -6,17 +6,19 @@ Arguments: [query]... Options: - -q, --quiet Do not print cargo log messages - --index Registry index URL to upload the package to --limit Limit the number of results (default: 10, max: 100) + --index Registry index URL to upload the package to --registry Registry to use - -h, --help Print help + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help search` for more detailed information. diff --git a/tests/testsuite/cargo_test/help/stdout.log b/tests/testsuite/cargo_test/help/stdout.log index 7e60fa424441..a0c842bb5b8d 100644 --- a/tests/testsuite/cargo_test/help/stdout.log +++ b/tests/testsuite/cargo_test/help/stdout.log @@ -7,48 +7,58 @@ Arguments: [args]... Arguments for the test binary Options: - -q, --quiet Display one character per test instead of one line - --lib Test only this package's library unit tests - --bins Test all binaries - --bin [] Test only the specified binary - --examples Test all examples - --example [] Test only the specified example - --tests Test all tests - --test [] Test only the specified test target - --benches Test all benches - --bench [] Test only the specified bench target - --all-targets Test all targets (does not include doctests) --doc Test only this library's documentation --no-run Compile, but don't run tests --no-fail-fast Run all tests regardless of failure - -p, --package [] Package to run tests for - --workspace Test all packages in the workspace - --exclude Exclude packages from the test - --all Alias for --workspace (deprecated) + --ignore-rust-version Ignore `rust-version` specification in packages + --future-incompat-report Outputs a future incompatibility report at the end of the build + --message-format Error format + -q, --quiet Display one character per test instead of one line + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for + details + -h, --help Print help + +Package Selection: + -p, --package [] Package to run tests for + --workspace Test all packages in the workspace + --exclude Exclude packages from the test + --all Alias for --workspace (deprecated) + +Target Selection: + --lib Test only this package's library unit tests + --bins Test all binaries + --bin [] Test only the specified binary + --examples Test all examples + --example [] Test only the specified example + --tests Test all tests + --test [] Test only the specified test target + --benches Test all benches + --bench [] Test only the specified bench target + --all-targets Test all targets (does not include doctests) + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. --keep-going Do not abort the build as soon as there is an error (unstable) -r, --release Build artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature --target Build for the target triple --target-dir Directory for all generated artifacts - --manifest-path Path to Cargo.toml - --ignore-rust-version Ignore `rust-version` specification in packages - --message-format Error format --unit-graph Output build graph in JSON (unstable) - --future-incompat-report Outputs a future incompatibility report at the end of the build --timings[=] Timing output formats (unstable) (comma separated): html, json - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help test` for more detailed information. Run `cargo test -- --help` for test binary options. diff --git a/tests/testsuite/cargo_tree/help/stdout.log b/tests/testsuite/cargo_tree/help/stdout.log index 28723b17b259..268b6b2ada68 100644 --- a/tests/testsuite/cargo_tree/help/stdout.log +++ b/tests/testsuite/cargo_tree/help/stdout.log @@ -3,36 +3,43 @@ Display a tree visualization of a dependency graph Usage: cargo[EXE] tree [OPTIONS] Options: - -q, --quiet Do not print cargo log messages + -q, --quiet Do not print cargo log messages + -e, --edges The kinds of dependencies to display (features, normal, build, dev, all, + no-normal, no-build, no-dev, no-proc-macro) + -i, --invert [] Invert the tree direction and focus on the given package + --prune Prune the given package from the display of the dependency tree + --depth Maximum display depth of the dependency tree + --prefix Change the prefix (indentation) of how each entry is displayed [default: + indent] [possible values: depth, indent, none] + --no-dedupe Do not de-duplicate (repeats all shared dependencies) + -d, --duplicates Show only dependencies which come in multiple versions (implies -i) + --charset Character set to use in output [default: utf8] [possible values: utf8, + ascii] + -f, --format Format string used for printing dependencies [default: {p}] + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Package Selection: + -p, --package [] Package to be used as the root of the tree + --workspace Display the tree for all packages in the workspace + --exclude Exclude specific workspace members + +Feature Selection: + -F, --features Space or comma separated list of features to activate + --all-features Activate all available features + --no-default-features Do not activate the `default` feature + +Compilation Options: + --target Filter dependencies matching the given target-triple (default host + platform). Pass `all` to include all targets. + +Manifest Options: --manifest-path Path to Cargo.toml - -p, --package [] Package to be used as the root of the tree - --workspace Display the tree for all packages in the workspace - --exclude Exclude specific workspace members - -F, --features Space or comma separated list of features to activate - --all-features Activate all available features - --no-default-features Do not activate the `default` feature - --target Filter dependencies matching the given target-triple (default host - platform). Pass `all` to include all targets. - -e, --edges The kinds of dependencies to display (features, normal, build, dev, - all, no-normal, no-build, no-dev, no-proc-macro) - -i, --invert [] Invert the tree direction and focus on the given package - --prune Prune the given package from the display of the dependency tree - --depth Maximum display depth of the dependency tree - --prefix Change the prefix (indentation) of how each entry is displayed - [default: indent] [possible values: depth, indent, none] - --no-dedupe Do not de-duplicate (repeats all shared dependencies) - -d, --duplicates Show only dependencies which come in multiple versions (implies -i) - --charset Character set to use in output [default: utf8] [possible values: utf8, - ascii] - -f, --format Format string used for printing dependencies [default: {p}] - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details Run `cargo help tree` for more detailed information. diff --git a/tests/testsuite/cargo_uninstall/help/stdout.log b/tests/testsuite/cargo_uninstall/help/stdout.log index f12662702506..2da1a5d57a98 100644 --- a/tests/testsuite/cargo_uninstall/help/stdout.log +++ b/tests/testsuite/cargo_uninstall/help/stdout.log @@ -6,17 +6,23 @@ Arguments: [spec]... Options: - -q, --quiet Do not print cargo log messages - -p, --package [] Package to uninstall - --bin Only uninstall the binary NAME --root Directory to uninstall packages from - -h, --help Print help + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Package Selection: + -p, --package [] Package to uninstall + +Target Selection: + --bin Only uninstall the binary NAME + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help uninstall` for more detailed information. diff --git a/tests/testsuite/cargo_update/help/stdout.log b/tests/testsuite/cargo_update/help/stdout.log index 222914423f1a..6cc10915179a 100644 --- a/tests/testsuite/cargo_update/help/stdout.log +++ b/tests/testsuite/cargo_update/help/stdout.log @@ -3,21 +3,24 @@ Update dependencies as recorded in the local lock file Usage: cargo[EXE] update [OPTIONS] Options: - -q, --quiet Do not print cargo log messages - -w, --workspace Only update the workspace packages - -p, --package [] Package to update - --aggressive Force updating all dependencies of SPEC as well when used with -p - --precise Update a single dependency to exactly PRECISE when used with -p + --dry-run Don't actually write the lockfile + --aggressive Force updating all dependencies of SPEC as well when used with -p + --precise Update a single dependency to exactly PRECISE when used with -p + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Package Selection: + -w, --workspace Only update the workspace packages + -p, --package [] Package to update + +Manifest Options: --manifest-path Path to Cargo.toml - --dry-run Don't actually write the lockfile - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details Run `cargo help update` for more detailed information. diff --git a/tests/testsuite/cargo_vendor/help/stdout.log b/tests/testsuite/cargo_vendor/help/stdout.log index be6de10637bd..7f37ab56edde 100644 --- a/tests/testsuite/cargo_vendor/help/stdout.log +++ b/tests/testsuite/cargo_vendor/help/stdout.log @@ -6,20 +6,22 @@ Arguments: [path] Where to vendor crates (`vendor` by default) Options: - -q, --quiet Do not print cargo log messages - --manifest-path Path to Cargo.toml --no-delete Don't delete older crates in the vendor directory -s, --sync Additional `Cargo.toml` to sync and vendor --respect-source-config Respect `[source]` config in `.cargo/config` --versioned-dirs Always include version in subdir name - -h, --help Print help + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --manifest-path Path to Cargo.toml + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help vendor` for more detailed information. diff --git a/tests/testsuite/cargo_verify_project/help/stdout.log b/tests/testsuite/cargo_verify_project/help/stdout.log index 306fc10e5848..a61534500d59 100644 --- a/tests/testsuite/cargo_verify_project/help/stdout.log +++ b/tests/testsuite/cargo_verify_project/help/stdout.log @@ -3,16 +3,17 @@ Check correctness of crate manifest Usage: cargo[EXE] verify-project [OPTIONS] Options: - -q, --quiet Do not print cargo log messages + -q, --quiet Do not print cargo log messages + -v, --verbose... Use verbose output (-vv very verbose/build.rs output) + --color Coloring: auto, always, never + --config Override a configuration value + -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: --manifest-path Path to Cargo.toml - -h, --help Print help - -v, --verbose... Use verbose output (-vv very verbose/build.rs output) - --color Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date --offline Run without accessing the network - --config Override a configuration value - -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for - details Run `cargo help verify-project` for more detailed information. diff --git a/tests/testsuite/cargo_version/help/stdout.log b/tests/testsuite/cargo_version/help/stdout.log index 657ff659e500..3f79051ad403 100644 --- a/tests/testsuite/cargo_version/help/stdout.log +++ b/tests/testsuite/cargo_version/help/stdout.log @@ -4,13 +4,15 @@ Usage: cargo[EXE] version [OPTIONS] Options: -q, --quiet Do not print cargo log messages - -h, --help Print help -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help version` for more detailed information. diff --git a/tests/testsuite/cargo_yank/help/stdout.log b/tests/testsuite/cargo_yank/help/stdout.log index a50965ccd71c..25b04e6c7d08 100644 --- a/tests/testsuite/cargo_yank/help/stdout.log +++ b/tests/testsuite/cargo_yank/help/stdout.log @@ -6,19 +6,21 @@ Arguments: [crate] Options: - -q, --quiet Do not print cargo log messages --version The version to yank or un-yank --undo Undo a yank, putting a version back into the index --index Registry index to yank from - --token API token to use when authenticating --registry Registry to use - -h, --help Print help + --token API token to use when authenticating + -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never - --frozen Require Cargo.lock and cache are up to date - --locked Require Cargo.lock is up to date - --offline Run without accessing the network --config Override a configuration value -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help Print help + +Manifest Options: + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + --offline Run without accessing the network Run `cargo help yank` for more detailed information. diff --git a/tests/testsuite/custom_target.rs b/tests/testsuite/custom_target.rs index b7ad4d835ec3..491d3233ca3e 100644 --- a/tests/testsuite/custom_target.rs +++ b/tests/testsuite/custom_target.rs @@ -4,6 +4,7 @@ use cargo_test_support::{basic_manifest, project}; use std::fs; const MINIMAL_LIB: &str = r#" +#![allow(internal_features)] #![feature(no_core)] #![feature(lang_items)] #![no_core] @@ -80,6 +81,7 @@ fn custom_target_dependency() { .file( "src/lib.rs", r#" + #![allow(internal_features)] #![feature(no_core)] #![feature(lang_items)] #![feature(auto_traits)] diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index 265457eb9a54..481df859045f 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -756,6 +756,7 @@ fn doc_target() { .file( "src/lib.rs", r#" + #![allow(internal_features)] #![feature(no_core, lang_items)] #![no_core] diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 455246b852b1..d93ea5ac8f78 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -4794,6 +4794,7 @@ error: test failed, to rerun pass `--test t2` Caused by: process didn't exit successfully: `[ROOT]/foo/target/debug/deps/t2[..]` (exit [..]: 4) +note: test exited abnormally; to see the full output pass --nocapture to the harness. ", ) .with_status(4) @@ -4825,6 +4826,7 @@ error: test failed, to rerun pass `--test t2` Caused by: process didn't exit successfully: `[ROOT]/foo/target/debug/deps/t2[..]` (exit [..]: 4) +note: test exited abnormally; to see the full output pass --nocapture to the harness. error: 2 targets failed: `--test t1` `--test t2` @@ -4834,23 +4836,10 @@ error: 2 targets failed: .run(); p.cargo("test --no-fail-fast -- --nocapture") - .with_stderr( - "\ -[FINISHED] test [..] -[RUNNING] tests/t1.rs (target/debug/deps/t1[..]) -thread 't' panicked at 'this is a normal error', tests/t1[..] -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -error: test failed, to rerun pass `--test t1` -[RUNNING] tests/t2.rs (target/debug/deps/t2[..]) -error: test failed, to rerun pass `--test t2` - -Caused by: - process didn't exit successfully: `[ROOT]/foo/target/debug/deps/t2[..]` (exit [..]: 4) -error: 2 targets failed: - `--test t1` - `--test t2` -", - ) - .with_status(101) - .run(); + .with_stderr_does_not_contain("test exited abnormally; to see the full output pass --nocapture to the harness.") + .with_stderr_contains("[..]thread 't' panicked [..] tests/t1[..]") + .with_stderr_contains("note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace") + .with_stderr_contains("[..]process didn't exit successfully: `[ROOT]/foo/target/debug/deps/t2[..]` (exit [..]: 4)") + .with_status(101) + .run(); }