Skip to content

Commit 52f35d0

Browse files
committed
Test for relative paths in crate path diagnostics
1 parent 2024e26 commit 52f35d0

File tree

5 files changed

+61
-0
lines changed

5 files changed

+61
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![crate_name = "crateresolve1"]
2+
#![crate_type = "lib"]
3+
4+
pub fn f() -> isize {
5+
10
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![crate_name = "crateresolve1"]
2+
#![crate_type = "lib"]
3+
4+
pub fn f() -> isize {
5+
20
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extern crate crateresolve1;
2+
3+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0464]: multiple candidates for `rlib` dependency `crateresolve1` found
2+
--> multiple-candidates.rs:1:1
3+
|
4+
LL | extern crate crateresolve1;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: candidate #1: ./mylibs/libcrateresolve1-1.rlib
8+
= note: candidate #2: ./mylibs/libcrateresolve1-2.rlib
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0464`.
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//@ needs-symlink
2+
//@ ignore-cross-compile
3+
4+
// Tests that the multiple candidate dependencies diagnostic prints relative
5+
// paths if a relative library path was passed in.
6+
7+
use run_make_support::{bare_rustc, diff, rfs, rustc};
8+
9+
fn main() {
10+
// Check that relative paths are preserved in the diagnostic
11+
rfs::create_dir("mylibs");
12+
rustc().input("crateresolve1-1.rs").out_dir("mylibs").extra_filename("-1").run();
13+
rustc().input("crateresolve1-2.rs").out_dir("mylibs").extra_filename("-2").run();
14+
check("./mylibs");
15+
16+
// Check that symlinks aren't followed when printing the diagnostic
17+
rfs::rename("mylibs", "original");
18+
rfs::symlink_dir("original", "mylibs");
19+
check("./mylibs");
20+
}
21+
22+
fn check(library_path: &str) {
23+
let out = rustc()
24+
.input("multiple-candidates.rs")
25+
.library_search_path(library_path)
26+
.ui_testing()
27+
.run_fail()
28+
.stderr_utf8();
29+
diff()
30+
.expected_file("multiple-candidates.stderr")
31+
.normalize(r"\\", "/")
32+
.actual_text("(rustc)", &out)
33+
.run();
34+
}

0 commit comments

Comments
 (0)