Skip to content

Commit

Permalink
Change error to warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Nov 13, 2018
1 parent fa0787a commit a10eb01
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
28 changes: 14 additions & 14 deletions src/cargo/core/compiler/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::fmt::Write;
use std::path::PathBuf;
use std::sync::Arc;

use failure::Error;
use jobserver::Client;

use core::{Package, PackageId, Resolve, Target};
Expand Down Expand Up @@ -469,22 +468,23 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
path.display()
)
};
let suggestion = "Consider changing their names to be unique or compiling them separately.";
let report_collision = |unit: &Unit, other_unit: &Unit, path: &PathBuf| -> Error {
let suggestion = "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 report_collision = |unit: &Unit, other_unit: &Unit, path: &PathBuf| -> CargoResult<()> {
if unit.target.name() == other_unit.target.name() {
format_err!(
self.bcx.config.shell().warn(format!(
"output filename collision.\n\
{}\
The targets must have unique names.\n\
The targets should have unique names.\n\
{}",
describe_collision(unit, other_unit, path),
suggestion
)
))
} else {
format_err!(
self.bcx.config.shell().warn(format!(
"output filename collision.\n\
{}\
The output filenames must be unique.\n\
The output filenames should be unique.\n\
{}\n\
If this looks unexpected, it may be a bug in Cargo. Please file a bug report at\n\
https://github.com/rust-lang/cargo/issues/ with as much information as you\n\
Expand All @@ -495,7 +495,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
describe_collision(unit, other_unit, path),
suggestion,
::version(), self.bcx.host_triple(), self.bcx.target_triple(),
unit, other_unit)
unit, other_unit))
}
};
let mut keys = self
Expand All @@ -510,25 +510,25 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
if let Some(other_unit) =
output_collisions.insert(output.path.clone(), unit)
{
return Err(report_collision(unit, &other_unit, &output.path));
report_collision(unit, &other_unit, &output.path)?;
}
if let Some(hardlink) = output.hardlink.as_ref() {
if let Some(other_unit) = output_collisions.insert(hardlink.clone(), unit)
{
return Err(report_collision(unit, &other_unit, hardlink));
report_collision(unit, &other_unit, hardlink)?;
}
}
if let Some(ref export_path) = output.export_path {
if let Some(other_unit) =
output_collisions.insert(export_path.clone(), unit)
{
bail!("`--out-dir` filename collision.\n\
self.bcx.config.shell().warn(format!("`--out-dir` filename collision.\n\
{}\
The exported filenames must be unique.\n\
The exported filenames should be unique.\n\
{}",
describe_collision(unit, &other_unit, &export_path),
suggestion
);
))?;
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions tests/testsuite/collisions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ fn collision_dylib() {
.build();

p.cargo("build")
.with_stderr(&format!("\
[ERROR] output filename collision.
.with_stderr_contains(&format!("\
[WARNING] output filename collision.
The lib target `a` in package `b v1.0.0 ([..]/foo/b)` has the same output filename as the lib target `a` in package `a v1.0.0 ([..]/foo/a)`.
Colliding filename is: [..]/foo/target/debug/deps/{}a{}
The targets must have unique names.
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
", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX))
.with_status(101)
.run();
}

Expand All @@ -69,14 +69,14 @@ fn collision_example() {
.build();

p.cargo("build --examples")
.with_stderr("\
[ERROR] output filename collision.
.with_stderr_contains("\
[WARNING] output filename collision.
The example target `ex1` in package `b v1.0.0 ([..]/foo/b)` has the same output filename as the example target `ex1` in package `a v1.0.0 ([..]/foo/a)`.
Colliding filename is: [..]/foo/target/debug/examples/ex1[EXE]
The targets must have unique names.
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
")
.with_status(101)
.run();
}

Expand All @@ -91,13 +91,13 @@ fn collision_export() {

p.cargo("build --out-dir=out -Z unstable-options --bins --examples")
.masquerade_as_nightly_cargo()
.with_stderr("\
[ERROR] `--out-dir` filename collision.
.with_stderr_contains("\
[WARNING] `--out-dir` filename collision.
The example target `foo` in package `foo v1.0.0 ([..]/foo)` has the same output filename as the bin target `foo` in package `foo v1.0.0 ([..]/foo)`.
Colliding filename is: [..]/foo/out/foo[EXE]
The exported filenames must be unique.
The exported filenames should be unique.
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
")
.with_status(101)
.run();
}

0 comments on commit a10eb01

Please sign in to comment.