diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index fedd23c61ddc..652c7bf0285c 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -89,7 +89,7 @@ use crate::core::compiler::future_incompat::FutureIncompatReport; pub use crate::core::compiler::unit::{Unit, UnitInterner}; use crate::core::manifest::TargetSourcePath; use crate::core::profiles::{PanicStrategy, Profile, StripInner}; -use crate::core::{Feature, PackageId, Target, Verbosity}; +use crate::core::{PackageId, Target, Verbosity}; use crate::util::errors::{CargoResult, VerboseError}; use crate::util::interning::InternedString; use crate::util::machine_message::{self, Message}; @@ -1437,14 +1437,7 @@ pub fn extern_args( |dep: &UnitDep, extern_crate_name: InternedString, noprelude: bool| -> CargoResult<()> { let mut value = OsString::new(); let mut opts = Vec::new(); - if unit - .pkg - .manifest() - .unstable_features() - .require(Feature::public_dependency()) - .is_ok() - && !dep.public - && unit.target.is_lib() + if !dep.public && unit.target.is_lib() && cx.bcx.config.cli_unstable().public_dependency { opts.push("priv"); *unstable_opts = true; diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index 2f52a24c0161..fca2a3e418ce 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -764,6 +764,7 @@ unstable_cli_options!( panic_abort_tests: bool = ("Enable support to run tests with -Cpanic=abort"), precise_pre_release: bool = ("Enable pre-release versions to be selected with `update --precise`"), profile_rustflags: bool = ("Enable the `rustflags` option in profiles in .cargo/config.toml file"), + public_dependency: bool = ("Respect a dependency's `public` field in Cargo.toml to control public/private dependencies"), publish_timeout: bool = ("Enable the `publish.timeout` key in .cargo/config.toml file"), rustdoc_map: bool = ("Allow passing external documentation mappings to rustdoc"), rustdoc_scrape_examples: bool = ("Allows Rustdoc to scrape code examples from reverse-dependencies"), @@ -1140,6 +1141,7 @@ impl CliUnstable { "mtime-on-use" => self.mtime_on_use = parse_empty(k, v)?, "no-index-update" => self.no_index_update = parse_empty(k, v)?, "panic-abort-tests" => self.panic_abort_tests = parse_empty(k, v)?, + "public-dependency" => self.public_dependency = parse_empty(k, v)?, "profile-rustflags" => self.profile_rustflags = parse_empty(k, v)?, "precise-pre-release" => self.precise_pre_release = parse_empty(k, v)?, "trim-paths" => self.trim_paths = parse_empty(k, v)?, diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 6bb8188dc3aa..f880965ac181 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -449,7 +449,6 @@ impl<'cfg> Workspace<'cfg> { // NOTE: Since we use ConfigRelativePath, this root isn't used as // any relative paths are resolved before they'd be joined with root. Path::new("unused-relative-path"), - self.unstable_features(), /* kind */ None, ) }) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 2ff0187feed1..3f5d1e7b17ac 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -10,8 +10,8 @@ use crate::core::compiler::{BuildConfig, CompileMode, DefaultExecutor, Executor} use crate::core::manifest::Target; use crate::core::resolver::CliFeatures; use crate::core::{registry::PackageRegistry, resolver::HasDevUnits}; -use crate::core::{Feature, Shell, Verbosity, Workspace}; use crate::core::{Package, PackageId, PackageSet, Resolve, SourceId}; +use crate::core::{Shell, Verbosity, Workspace}; use crate::sources::PathSource; use crate::util::cache_lock::CacheLockMode; use crate::util::config::JobsConfig; @@ -911,12 +911,7 @@ fn run_verify( let pkg_fingerprint = hash_all(&dst)?; let ws = Workspace::ephemeral(new_pkg, config, None, true)?; - let rustc_args = if pkg - .manifest() - .unstable_features() - .require(Feature::public_dependency()) - .is_ok() - { + let rustc_args = if ws.config().cli_unstable().public_dependency { // FIXME: Turn this on at some point in the future //Some(vec!["-D exported_private_dependencies".to_string()]) Some(vec![]) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 0ffeda2ada80..cb15d4b1ccf3 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -678,7 +678,6 @@ pub fn to_real_manifest( nested_paths: &mut nested_paths, config, warnings: &mut warnings, - features: &features, platform: None, root: package_root, }; @@ -1153,7 +1152,6 @@ fn to_virtual_manifest( config, warnings: &mut warnings, platform: None, - features: &features, root, }; (replace(&me, &mut cx)?, patch(&me, &mut cx)?) @@ -1302,7 +1300,6 @@ struct Context<'a, 'b> { warnings: &'a mut Vec, platform: Option, root: &'a Path, - features: &'a Features, } fn verify_lints(lints: Option) -> CargoResult> { @@ -1709,7 +1706,6 @@ pub(crate) fn to_dependency( warnings: &mut Vec, platform: Option, root: &Path, - features: &Features, kind: Option, ) -> CargoResult { dep_to_dependency( @@ -1723,7 +1719,6 @@ pub(crate) fn to_dependency( warnings, platform, root, - features, }, kind, ) @@ -1944,13 +1939,18 @@ fn detailed_dep_to_dependency( } if let Some(p) = orig.public { - cx.features.require(Feature::public_dependency())?; - if dep.kind() != DepKind::Normal { bail!("'public' specifier can only be used on regular dependencies, not {:?} dependencies", dep.kind()); } - dep.set_public(p); + if !cx.config.cli_unstable().public_dependency { + cx.warnings.push(format!( + "{name} uses 'public' specifier, pass `-Zpublic-dependency` to enable support for it", + name = dep.name_in_toml(), + )) + } else { + dep.set_public(p); + } } if let (Some(artifact), is_lib, target) = ( diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index 164e51edf0eb..8514a7f4bb51 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -296,11 +296,9 @@ The 'public-dependency' feature allows marking dependencies as 'public' or 'private'. When this feature is enabled, additional information is passed to rustc to allow the 'exported_private_dependencies' lint to function properly. -This requires the appropriate key to be set in `cargo-features`: +Pass `-Zpublic-dependency` to cargo to enable support for it. ```toml -cargo-features = ["public-dependency"] - [dependencies] my_dep = { version = "1.2.3", public = true } private_dep = "2.0.0" # Will be 'private' by default diff --git a/tests/testsuite/cargo/z_help/stdout.log b/tests/testsuite/cargo/z_help/stdout.log index 2a4703cc11f2..abdd93b00e76 100644 --- a/tests/testsuite/cargo/z_help/stdout.log +++ b/tests/testsuite/cargo/z_help/stdout.log @@ -25,6 +25,7 @@ Available unstable (nightly-only) flags: -Z panic-abort-tests Enable support to run tests with -Cpanic=abort -Z precise-pre-release Enable pre-release versions to be selected with `update --precise` -Z profile-rustflags Enable the `rustflags` option in profiles in .cargo/config.toml file + -Z public-dependency Respect a dependency's `public` field in Cargo.toml to control public/private dependencies -Z publish-timeout Enable the `publish.timeout` key in .cargo/config.toml file -Z rustdoc-map Allow passing external documentation mappings to rustdoc -Z rustdoc-scrape-examples Allows Rustdoc to scrape code examples from reverse-dependencies diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_public/in/primary/Cargo.toml b/tests/testsuite/cargo_add/detect_workspace_inherit_public/in/primary/Cargo.toml index b5923a106b93..b867edbbed18 100644 --- a/tests/testsuite/cargo_add/detect_workspace_inherit_public/in/primary/Cargo.toml +++ b/tests/testsuite/cargo_add/detect_workspace_inherit_public/in/primary/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [package] name = "bar" version = "0.0.0" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/detect_workspace_inherit_public/out/primary/Cargo.toml b/tests/testsuite/cargo_add/detect_workspace_inherit_public/out/primary/Cargo.toml index 665c6ae5e02e..81d004e02fb3 100644 --- a/tests/testsuite/cargo_add/detect_workspace_inherit_public/out/primary/Cargo.toml +++ b/tests/testsuite/cargo_add/detect_workspace_inherit_public/out/primary/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [package] name = "bar" version = "0.0.0" diff --git a/tests/testsuite/cargo_add/no_public/in/Cargo.toml b/tests/testsuite/cargo_add/no_public/in/Cargo.toml index e9087535be33..3ecdb6681676 100644 --- a/tests/testsuite/cargo_add/no_public/in/Cargo.toml +++ b/tests/testsuite/cargo_add/no_public/in/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/cargo_add/no_public/out/Cargo.toml b/tests/testsuite/cargo_add/no_public/out/Cargo.toml index b9f045116773..496ac8a6236c 100644 --- a/tests/testsuite/cargo_add/no_public/out/Cargo.toml +++ b/tests/testsuite/cargo_add/no_public/out/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/cargo_add/overwrite_no_public/in/Cargo.toml b/tests/testsuite/cargo_add/overwrite_no_public/in/Cargo.toml index 43d0d8238a1b..fd02884a87d7 100644 --- a/tests/testsuite/cargo_add/overwrite_no_public/in/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_no_public/in/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/cargo_add/overwrite_no_public/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_no_public/out/Cargo.toml index b9f045116773..496ac8a6236c 100644 --- a/tests/testsuite/cargo_add/overwrite_no_public/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_no_public/out/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/cargo_add/overwrite_no_public_with_public/in/Cargo.toml b/tests/testsuite/cargo_add/overwrite_no_public_with_public/in/Cargo.toml index c6e61bdca3f7..fca7be6f93a3 100644 --- a/tests/testsuite/cargo_add/overwrite_no_public_with_public/in/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_no_public_with_public/in/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/cargo_add/overwrite_no_public_with_public/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_no_public_with_public/out/Cargo.toml index 77fccaa6a57e..82f23b1b70ce 100644 --- a/tests/testsuite/cargo_add/overwrite_no_public_with_public/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_no_public_with_public/out/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/cargo_add/overwrite_public/in/Cargo.toml b/tests/testsuite/cargo_add/overwrite_public/in/Cargo.toml index 43d0d8238a1b..fd02884a87d7 100644 --- a/tests/testsuite/cargo_add/overwrite_public/in/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_public/in/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/cargo_add/overwrite_public/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_public/out/Cargo.toml index 77fccaa6a57e..82f23b1b70ce 100644 --- a/tests/testsuite/cargo_add/overwrite_public/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_public/out/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/cargo_add/overwrite_public_with_no_public/in/Cargo.toml b/tests/testsuite/cargo_add/overwrite_public_with_no_public/in/Cargo.toml index cc7ec1a9b7e0..2fa30c957dec 100644 --- a/tests/testsuite/cargo_add/overwrite_public_with_no_public/in/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_public_with_no_public/in/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/cargo_add/overwrite_public_with_no_public/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_public_with_no_public/out/Cargo.toml index cfa80cc1373b..79fda4582900 100644 --- a/tests/testsuite/cargo_add/overwrite_public_with_no_public/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_public_with_no_public/out/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/cargo_add/public/in/Cargo.toml b/tests/testsuite/cargo_add/public/in/Cargo.toml index e9087535be33..3ecdb6681676 100644 --- a/tests/testsuite/cargo_add/public/in/Cargo.toml +++ b/tests/testsuite/cargo_add/public/in/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/cargo_add/public/out/Cargo.toml b/tests/testsuite/cargo_add/public/out/Cargo.toml index 77fccaa6a57e..82f23b1b70ce 100644 --- a/tests/testsuite/cargo_add/public/out/Cargo.toml +++ b/tests/testsuite/cargo_add/public/out/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["public-dependency"] [workspace] [package] diff --git a/tests/testsuite/pub_priv.rs b/tests/testsuite/pub_priv.rs index 4195f5863136..6cc2f91b7084 100644 --- a/tests/testsuite/pub_priv.rs +++ b/tests/testsuite/pub_priv.rs @@ -13,8 +13,6 @@ fn exported_priv_warning() { .file( "Cargo.toml", r#" - cargo-features = ["public-dependency"] - [package] name = "foo" version = "0.0.1" @@ -32,7 +30,7 @@ fn exported_priv_warning() { ) .build(); - p.cargo("check --message-format=short") + p.cargo("check -Zpublic-dependency --message-format=short") .masquerade_as_nightly_cargo(&["public-dependency"]) .with_stderr_contains( "\ @@ -52,8 +50,6 @@ fn exported_pub_dep() { .file( "Cargo.toml", r#" - cargo-features = ["public-dependency"] - [package] name = "foo" version = "0.0.1" @@ -71,7 +67,7 @@ fn exported_pub_dep() { ) .build(); - p.cargo("check --message-format=short") + p.cargo("check -Zpublic-dependency --message-format=short") .masquerade_as_nightly_cargo(&["public-dependency"]) .with_stderr( "\ @@ -86,75 +82,6 @@ fn exported_pub_dep() { .run() } -#[cargo_test] -pub fn requires_nightly_cargo() { - let p = project() - .file( - "Cargo.toml", - r#" - cargo-features = ["public-dependency"] - "#, - ) - .file("src/lib.rs", "") - .build(); - - p.cargo("check --message-format=short") - .with_status(101) - .with_stderr( - "\ -error: failed to parse manifest at `[..]` - -Caused by: - the cargo feature `public-dependency` requires a nightly version of Cargo, but this is the `stable` channel - See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels. - See https://doc.rust-lang.org/[..]cargo/reference/unstable.html#public-dependency for more information about using this feature. -" - ) - .run() -} - -#[cargo_test] -fn requires_feature() { - Package::new("pub_dep", "0.1.0") - .file("src/lib.rs", "") - .publish(); - - let p = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - - [dependencies] - pub_dep = { version = "0.1.0", public = true } - "#, - ) - .file("src/lib.rs", "") - .build(); - - p.cargo("check --message-format=short") - .masquerade_as_nightly_cargo(&["public-dependency"]) - .with_status(101) - .with_stderr( - "\ -error: failed to parse manifest at `[..]` - -Caused by: - feature `public-dependency` is required - - The package requires the Cargo feature called `public-dependency`, \ - but that feature is not stabilized in this version of Cargo (1.[..]). - Consider adding `cargo-features = [\"public-dependency\"]` to the top of Cargo.toml \ - (above the [package] table) to tell Cargo you are opting in to use this unstable feature. - See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#public-dependency \ - for more information about the status of this feature. -", - ) - .run() -} - #[cargo_test] fn pub_dev_dependency() { Package::new("pub_dep", "0.1.0") @@ -165,8 +92,6 @@ fn pub_dev_dependency() { .file( "Cargo.toml", r#" - cargo-features = ["public-dependency"] - [package] name = "foo" version = "0.0.1" @@ -184,7 +109,7 @@ fn pub_dev_dependency() { ) .build(); - p.cargo("check --message-format=short") + p.cargo("check -Zpublic-dependency --message-format=short") .masquerade_as_nightly_cargo(&["public-dependency"]) .with_status(101) .with_stderr( @@ -214,8 +139,6 @@ fn workspace_pub_disallowed() { .file( "Cargo.toml", r#" - cargo-features = ["public-dependency"] - [package] name = "foo" version = "0.0.1" @@ -266,8 +189,6 @@ fn allow_priv_in_tests() { .file( "Cargo.toml", r#" - cargo-features = ["public-dependency"] - [package] name = "foo" version = "0.0.1" @@ -285,7 +206,7 @@ fn allow_priv_in_tests() { ) .build(); - p.cargo("check --tests --message-format=short") + p.cargo("check -Zpublic-dependency --tests --message-format=short") .masquerade_as_nightly_cargo(&["public-dependency"]) .with_stderr( "\ @@ -310,8 +231,6 @@ fn allow_priv_in_benchs() { .file( "Cargo.toml", r#" - cargo-features = ["public-dependency"] - [package] name = "foo" version = "0.0.1" @@ -329,7 +248,7 @@ fn allow_priv_in_benchs() { ) .build(); - p.cargo("check --benches --message-format=short") + p.cargo("check -Zpublic-dependency --benches --message-format=short") .masquerade_as_nightly_cargo(&["public-dependency"]) .with_stderr( "\ @@ -354,8 +273,6 @@ fn allow_priv_in_bins() { .file( "Cargo.toml", r#" - cargo-features = ["public-dependency"] - [package] name = "foo" version = "0.0.1" @@ -374,7 +291,7 @@ fn allow_priv_in_bins() { ) .build(); - p.cargo("check --bins --message-format=short") + p.cargo("check -Zpublic-dependency --bins --message-format=short") .masquerade_as_nightly_cargo(&["public-dependency"]) .with_stderr( "\ @@ -399,8 +316,6 @@ fn allow_priv_in_examples() { .file( "Cargo.toml", r#" - cargo-features = ["public-dependency"] - [package] name = "foo" version = "0.0.1" @@ -419,7 +334,7 @@ fn allow_priv_in_examples() { ) .build(); - p.cargo("check --examples --message-format=short") + p.cargo("check -Zpublic-dependency --examples --message-format=short") .masquerade_as_nightly_cargo(&["public-dependency"]) .with_stderr( "\ @@ -444,8 +359,6 @@ fn allow_priv_in_custom_build() { .file( "Cargo.toml", r#" - cargo-features = ["public-dependency"] - [package] name = "foo" version = "0.0.1" @@ -486,7 +399,6 @@ fn publish_package_with_public_dependency() { .file("src/lib.rs", "pub struct FromPub;") .publish(); Package::new("bar", "0.1.0") - .cargo_feature("public-dependency") .add_dep(Dependency::new("pub_bar", "0.1.0").public(true)) .file( "src/lib.rs", @@ -501,7 +413,6 @@ fn publish_package_with_public_dependency() { .file( "Cargo.toml", r#" - cargo-features = ["public-dependency"] [package] name = "foo" version = "0.0.1" @@ -518,7 +429,7 @@ fn publish_package_with_public_dependency() { ) .build(); - p.cargo("check --message-format=short") + p.cargo("check -Zpublic-dependency --message-format=short") .masquerade_as_nightly_cargo(&["public-dependency"]) .with_stderr( "\ @@ -534,3 +445,131 @@ fn publish_package_with_public_dependency() { ) .run() } + +#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")] +fn exported_pub_dep_without_z_public_dependency() { + Package::new("pub_dep", "0.1.0") + .file("src/lib.rs", "pub struct FromPub;") + .publish(); + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + + [dependencies] + pub_dep = {version = "0.1.0", public = true} + "#, + ) + .file( + "src/lib.rs", + " + extern crate pub_dep; + pub fn use_pub(_: pub_dep::FromPub) {} + ", + ) + .build(); + + p.cargo("check --message-format=short") + .masquerade_as_nightly_cargo(&["public-dependency"]) + .with_stderr( + "\ +[WARNING] pub_dep uses 'public' specifier, pass `-Zpublic-dependency` to enable support for it +[UPDATING] `[..]` index +[DOWNLOADING] crates ... +[DOWNLOADED] pub_dep v0.1.0 ([..]) +[CHECKING] pub_dep v0.1.0 +[CHECKING] foo v0.0.1 ([CWD]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")] +fn exported_priv_dep_without_z_public_dependency() { + Package::new("priv_dep", "0.1.0") + .file("src/lib.rs", "pub struct FromPriv;") + .publish(); + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + + [dependencies] + priv_dep = {version = "0.1.0", public = false} + "#, + ) + .file( + "src/lib.rs", + " + extern crate priv_dep; + pub fn use_priv(_: priv_dep::FromPriv) {} + ", + ) + .build(); + + p.cargo("check --message-format=short") + .masquerade_as_nightly_cargo(&["public-dependency"]) + .with_stderr( + "\ +[WARNING] priv_dep uses 'public' specifier, pass `-Zpublic-dependency` to enable support for it +[UPDATING] `[..]` index +[DOWNLOADING] crates ... +[DOWNLOADED] priv_dep v0.1.0 ([..]) +[CHECKING] priv_dep v0.1.0 +[CHECKING] foo v0.0.1 ([CWD]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")] +fn exported_dep_without_z_public_dependency() { + Package::new("pub_dep", "0.1.0") + .file("src/lib.rs", "pub struct FromPub;") + .publish(); + Package::new("priv_dep", "0.1.0") + .file("src/lib.rs", "pub struct FromPriv;") + .publish(); + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + + [dependencies] + pub_dep = "0.1.0" + "#, + ) + .file( + "src/lib.rs", + " + extern crate pub_dep; + pub fn use_pub(_: pub_dep::FromPub) {} + ", + ) + .build(); + + p.cargo("check --message-format=short") + .masquerade_as_nightly_cargo(&["public-dependency"]) + .with_stderr( + "\ +[UPDATING] `[..]` index +[DOWNLOADING] crates ... +[DOWNLOADED] pub_dep v0.1.0 ([..]) +[CHECKING] pub_dep v0.1.0 +[CHECKING] foo v0.0.1 ([CWD]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +}