Skip to content

Commit a10eb01

Browse files
committed
Change error to warning.
1 parent fa0787a commit a10eb01

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::fmt::Write;
55
use std::path::PathBuf;
66
use std::sync::Arc;
77

8-
use failure::Error;
98
use jobserver::Client;
109

1110
use core::{Package, PackageId, Resolve, Target};
@@ -469,22 +468,23 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
469468
path.display()
470469
)
471470
};
472-
let suggestion = "Consider changing their names to be unique or compiling them separately.";
473-
let report_collision = |unit: &Unit, other_unit: &Unit, path: &PathBuf| -> Error {
471+
let suggestion = "Consider changing their names to be unique or compiling them separately.\n\
472+
This may become a hard error in the future, see https://github.com/rust-lang/cargo/issues/6313";
473+
let report_collision = |unit: &Unit, other_unit: &Unit, path: &PathBuf| -> CargoResult<()> {
474474
if unit.target.name() == other_unit.target.name() {
475-
format_err!(
475+
self.bcx.config.shell().warn(format!(
476476
"output filename collision.\n\
477477
{}\
478-
The targets must have unique names.\n\
478+
The targets should have unique names.\n\
479479
{}",
480480
describe_collision(unit, other_unit, path),
481481
suggestion
482-
)
482+
))
483483
} else {
484-
format_err!(
484+
self.bcx.config.shell().warn(format!(
485485
"output filename collision.\n\
486486
{}\
487-
The output filenames must be unique.\n\
487+
The output filenames should be unique.\n\
488488
{}\n\
489489
If this looks unexpected, it may be a bug in Cargo. Please file a bug report at\n\
490490
https://github.com/rust-lang/cargo/issues/ with as much information as you\n\
@@ -495,7 +495,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
495495
describe_collision(unit, other_unit, path),
496496
suggestion,
497497
::version(), self.bcx.host_triple(), self.bcx.target_triple(),
498-
unit, other_unit)
498+
unit, other_unit))
499499
}
500500
};
501501
let mut keys = self
@@ -510,25 +510,25 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
510510
if let Some(other_unit) =
511511
output_collisions.insert(output.path.clone(), unit)
512512
{
513-
return Err(report_collision(unit, &other_unit, &output.path));
513+
report_collision(unit, &other_unit, &output.path)?;
514514
}
515515
if let Some(hardlink) = output.hardlink.as_ref() {
516516
if let Some(other_unit) = output_collisions.insert(hardlink.clone(), unit)
517517
{
518-
return Err(report_collision(unit, &other_unit, hardlink));
518+
report_collision(unit, &other_unit, hardlink)?;
519519
}
520520
}
521521
if let Some(ref export_path) = output.export_path {
522522
if let Some(other_unit) =
523523
output_collisions.insert(export_path.clone(), unit)
524524
{
525-
bail!("`--out-dir` filename collision.\n\
525+
self.bcx.config.shell().warn(format!("`--out-dir` filename collision.\n\
526526
{}\
527-
The exported filenames must be unique.\n\
527+
The exported filenames should be unique.\n\
528528
{}",
529529
describe_collision(unit, &other_unit, &export_path),
530530
suggestion
531-
);
531+
))?;
532532
}
533533
}
534534
}

tests/testsuite/collisions.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ fn collision_dylib() {
4040
.build();
4141

4242
p.cargo("build")
43-
.with_stderr(&format!("\
44-
[ERROR] output filename collision.
43+
.with_stderr_contains(&format!("\
44+
[WARNING] output filename collision.
4545
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)`.
4646
Colliding filename is: [..]/foo/target/debug/deps/{}a{}
47-
The targets must have unique names.
47+
The targets should have unique names.
4848
Consider changing their names to be unique or compiling them separately.
49+
This may become a hard error in the future, see https://github.com/rust-lang/cargo/issues/6313
4950
", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX))
50-
.with_status(101)
5151
.run();
5252
}
5353

@@ -69,14 +69,14 @@ fn collision_example() {
6969
.build();
7070

7171
p.cargo("build --examples")
72-
.with_stderr("\
73-
[ERROR] output filename collision.
72+
.with_stderr_contains("\
73+
[WARNING] output filename collision.
7474
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)`.
7575
Colliding filename is: [..]/foo/target/debug/examples/ex1[EXE]
76-
The targets must have unique names.
76+
The targets should have unique names.
7777
Consider changing their names to be unique or compiling them separately.
78+
This may become a hard error in the future, see https://github.com/rust-lang/cargo/issues/6313
7879
")
79-
.with_status(101)
8080
.run();
8181
}
8282

@@ -91,13 +91,13 @@ fn collision_export() {
9191

9292
p.cargo("build --out-dir=out -Z unstable-options --bins --examples")
9393
.masquerade_as_nightly_cargo()
94-
.with_stderr("\
95-
[ERROR] `--out-dir` filename collision.
94+
.with_stderr_contains("\
95+
[WARNING] `--out-dir` filename collision.
9696
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)`.
9797
Colliding filename is: [..]/foo/out/foo[EXE]
98-
The exported filenames must be unique.
98+
The exported filenames should be unique.
9999
Consider changing their names to be unique or compiling them separately.
100+
This may become a hard error in the future, see https://github.com/rust-lang/cargo/issues/6313
100101
")
101-
.with_status(101)
102102
.run();
103103
}

0 commit comments

Comments
 (0)