@@ -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 {
0 commit comments