You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #9276 - ehuss:fix-collision-root-removal, r=alexcrichton
Fix doc duplicate removal of root units.
The doc collision removal code didn't consider the possibility that there was a collision with a root unit. This caused problems in conjunction with #9142 where cargo would panic because a root unit got removed from the graph because of a filename collision. The solution here is to avoid removing root units during the doc collision sweep.
This has a downside that this reintroduces a filename collision.
An alternate solution would be to make the set of root units mutable, and remove from that list, but I figured this is simpler and more conservative.
Fixes#9274
Copy file name to clipboardExpand all lines: tests/testsuite/collisions.rs
+66
Original file line number
Diff line number
Diff line change
@@ -478,3 +478,69 @@ fn collision_doc_target() {
478
478
)
479
479
.run();
480
480
}
481
+
482
+
#[cargo_test]
483
+
fncollision_with_root(){
484
+
// Check for a doc collision between a root package and a dependency.
485
+
// In this case, `foo-macro` comes from both the workspace and crates.io.
486
+
// This checks that the duplicate correction code doesn't choke on this
487
+
// by removing the root unit.
488
+
Package::new("foo-macro","1.0.0").publish();
489
+
490
+
let p = project()
491
+
.file(
492
+
"Cargo.toml",
493
+
r#"
494
+
[workspace]
495
+
members = ["abc", "foo-macro"]
496
+
"#,
497
+
)
498
+
.file(
499
+
"abc/Cargo.toml",
500
+
r#"
501
+
[package]
502
+
name = "abc"
503
+
version = "1.0.0"
504
+
505
+
[dependencies]
506
+
foo-macro = "1.0"
507
+
"#,
508
+
)
509
+
.file("abc/src/lib.rs","")
510
+
.file(
511
+
"foo-macro/Cargo.toml",
512
+
r#"
513
+
[package]
514
+
name = "foo-macro"
515
+
version = "1.0.0"
516
+
517
+
[lib]
518
+
proc-macro = true
519
+
520
+
[dependencies]
521
+
abc = {path="../abc"}
522
+
"#,
523
+
)
524
+
.file("foo-macro/src/lib.rs","")
525
+
.build();
526
+
527
+
p.cargo("doc")
528
+
.with_stderr_unordered("\
529
+
[UPDATING] [..]
530
+
[DOWNLOADING] crates ...
531
+
[DOWNLOADED] foo-macro v1.0.0 [..]
532
+
warning: output filename collision.
533
+
The lib target `foo-macro` in package `foo-macro v1.0.0` has the same output filename as the lib target `foo-macro` in package `foo-macro v1.0.0 [..]`.
534
+
Colliding filename is: [CWD]/target/doc/foo_macro/index.html
535
+
The targets should have unique names.
536
+
This is a known bug where multiple crates with the same name use
537
+
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
0 commit comments