Skip to content

Commit d19f614

Browse files
committed
Auto merge of #7244 - ehuss:rustdoc-collision-warning, r=alexcrichton
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)
2 parents 0b0bb84 + 5d98fca commit d19f614

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/cargo/core/compiler/context/mod.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,13 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
412412
"Consider changing their names to be unique or compiling them separately.\n\
413413
This may become a hard error in the future; see \
414414
<https://github.com/rust-lang/cargo/issues/6313>.";
415+
let rustdoc_suggestion =
416+
"This is a known bug where multiple crates with the same name use\n\
417+
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.";
415418
let report_collision = |unit: &Unit<'_>,
416419
other_unit: &Unit<'_>,
417-
path: &PathBuf|
420+
path: &PathBuf,
421+
suggestion: &str|
418422
-> CargoResult<()> {
419423
if unit.target.name() == other_unit.target.name() {
420424
self.bcx.config.shell().warn(format!(
@@ -443,6 +447,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
443447
unit, other_unit))
444448
}
445449
};
450+
446451
let mut keys = self
447452
.unit_dependencies
448453
.keys()
@@ -453,11 +458,17 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
453458
for unit in keys {
454459
for output in self.outputs(unit)?.iter() {
455460
if let Some(other_unit) = output_collisions.insert(output.path.clone(), unit) {
456-
report_collision(unit, other_unit, &output.path)?;
461+
if unit.mode.is_doc() {
462+
// See https://github.com/rust-lang/rust/issues/56169
463+
// and https://github.com/rust-lang/rust/issues/61378
464+
report_collision(unit, other_unit, &output.path, rustdoc_suggestion)?;
465+
} else {
466+
report_collision(unit, other_unit, &output.path, suggestion)?;
467+
}
457468
}
458469
if let Some(hardlink) = output.hardlink.as_ref() {
459470
if let Some(other_unit) = output_collisions.insert(hardlink.clone(), unit) {
460-
report_collision(unit, other_unit, hardlink)?;
471+
report_collision(unit, other_unit, hardlink, suggestion)?;
461472
}
462473
}
463474
if let Some(ref export_path) = output.export_path {

tests/testsuite/collisions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ The lib target `foo` in package `foo2 v0.1.0 ([..]/foo/foo2)` has the same outpu
141141
filename as the lib target `foo` in package `foo v0.1.0 ([..]/foo)`.
142142
Colliding filename is: [..]/foo/target/doc/foo/index.html
143143
The targets should have unique names.
144-
Consider changing their names to be unique or compiling them separately.
145-
This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
144+
This is a known bug where multiple crates with the same name use
145+
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
146146
",
147147
)
148148
.run();

0 commit comments

Comments
 (0)