Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust warning for rustdoc filename collision. #7244

Merged
merged 1 commit into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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