From 5d98fca89f1a9046887b550ef55efc7fe1ed2e63 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 12 Aug 2019 17:19:28 -0700 Subject: [PATCH] Adjust warning for rustdoc filename collision. --- src/cargo/core/compiler/context/mod.rs | 17 ++++++++++++++--- tests/testsuite/collisions.rs | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/cargo/core/compiler/context/mod.rs b/src/cargo/core/compiler/context/mod.rs index 47f03308cf4..f82026e5281 100644 --- a/src/cargo/core/compiler/context/mod.rs +++ b/src/cargo/core/compiler/context/mod.rs @@ -412,9 +412,13 @@ impl<'a, 'cfg> Context<'a, 'cfg> { "Consider changing their names to be unique or compiling them separately.\n\ This may become a hard error in the future; see \ ."; + let rustdoc_suggestion = + "This is a known bug where multiple crates with the same name use\n\ + the same path; see ."; let report_collision = |unit: &Unit<'_>, other_unit: &Unit<'_>, - path: &PathBuf| + path: &PathBuf, + suggestion: &str| -> CargoResult<()> { if unit.target.name() == other_unit.target.name() { self.bcx.config.shell().warn(format!( @@ -443,6 +447,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { unit, other_unit)) } }; + let mut keys = self .unit_dependencies .keys() @@ -453,11 +458,17 @@ impl<'a, 'cfg> Context<'a, 'cfg> { for unit in keys { for output in self.outputs(unit)?.iter() { if let Some(other_unit) = output_collisions.insert(output.path.clone(), unit) { - report_collision(unit, other_unit, &output.path)?; + if unit.mode.is_doc() { + // See https://github.com/rust-lang/rust/issues/56169 + // and https://github.com/rust-lang/rust/issues/61378 + report_collision(unit, other_unit, &output.path, rustdoc_suggestion)?; + } else { + report_collision(unit, other_unit, &output.path, suggestion)?; + } } if let Some(hardlink) = output.hardlink.as_ref() { if let Some(other_unit) = output_collisions.insert(hardlink.clone(), unit) { - report_collision(unit, other_unit, hardlink)?; + report_collision(unit, other_unit, hardlink, suggestion)?; } } if let Some(ref export_path) = output.export_path { diff --git a/tests/testsuite/collisions.rs b/tests/testsuite/collisions.rs index a9a24b7bd26..bca9fb3f8c1 100644 --- a/tests/testsuite/collisions.rs +++ b/tests/testsuite/collisions.rs @@ -141,8 +141,8 @@ The lib target `foo` in package `foo2 v0.1.0 ([..]/foo/foo2)` has the same outpu filename as the lib target `foo` in package `foo v0.1.0 ([..]/foo)`. Colliding filename is: [..]/foo/target/doc/foo/index.html The targets should have unique names. -Consider changing their names to be unique or compiling them separately. -This may become a hard error in the future; see . +This is a known bug where multiple crates with the same name use +the same path; see . ", ) .run();