Skip to content

Commit

Permalink
Auto merge of #7244 - ehuss:rustdoc-collision-warning, r=alexcrichton
Browse files Browse the repository at this point in the history
Adjust warning for rustdoc filename collision.

The existing warning was a little misleading, as this is a known bug, not something we currently plan to reject.

cc #6313 (comment)
  • Loading branch information
bors committed Aug 13, 2019
2 parents 0b0bb84 + 5d98fca commit d19f614
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions src/cargo/core/compiler/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
<https://github.com/rust-lang/cargo/issues/6313>.";
let rustdoc_suggestion =
"This is a known bug where multiple crates with the same name use\n\
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.";
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!(
Expand Down Expand Up @@ -443,6 +447,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
unit, other_unit))
}
};

let mut keys = self
.unit_dependencies
.keys()
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/collisions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/rust-lang/cargo/issues/6313>.
This is a known bug where multiple crates with the same name use
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
",
)
.run();
Expand Down

0 comments on commit d19f614

Please sign in to comment.