Skip to content

Commit b24c40e

Browse files
committed
Add a test for not resolving ambiguity for multiple --extern with same name
1 parent 21775c2 commit b24c40e

File tree

6 files changed

+79
-0
lines changed

6 files changed

+79
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub struct Foo;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub struct Foo;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(custom_inner_attributes)]
2+
#![rustfmt::skip] // use_foo must be referenced before foo
3+
4+
// Load foo-v2 through use-foo
5+
use use_foo as _;
6+
7+
// Make sure we don't disambiguate this as foo-v2.
8+
use foo as _;
9+
10+
fn main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0464]: multiple candidates for `rlib` dependency `foo` found
2+
--> main.rs:8:5
3+
|
4+
LL | use foo as _;
5+
| ^^^
6+
|
7+
= note: candidate #1: /build-root/test/run-make/duplicate-dependency-no-disambiguate/rmake_out/libfoo-v1.rlib
8+
= note: candidate #2: /build-root/test/run-make/duplicate-dependency-no-disambiguate/rmake_out/libfoo-v2.rlib
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0464`.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//@ needs-target-std
2+
3+
use run_make_support::{Rustc, cwd, diff, regex, rust_lib_name, rustc};
4+
5+
fn rustc_with_common_args() -> Rustc {
6+
let mut rustc = rustc();
7+
rustc.remap_path_prefix(cwd(), "$DIR");
8+
rustc.edition("2018"); // Don't require `extern crate`
9+
rustc
10+
}
11+
12+
fn main() {
13+
rustc_with_common_args()
14+
.input("foo-v1.rs")
15+
.crate_type("rlib")
16+
.crate_name("foo")
17+
.extra_filename("-v1")
18+
.metadata("-v1")
19+
.run();
20+
21+
rustc_with_common_args()
22+
.input("foo-v2.rs")
23+
.crate_type("rlib")
24+
.crate_name("foo")
25+
.extra_filename("-v2")
26+
.metadata("-v2")
27+
.run();
28+
29+
rustc_with_common_args()
30+
.input("use-foo.rs")
31+
.crate_type("rlib")
32+
.extern_("foo", rust_lib_name("foo-v2"))
33+
.run();
34+
35+
let stderr = rustc_with_common_args()
36+
.input("main.rs")
37+
.extern_("foo", rust_lib_name("foo-v1"))
38+
.extern_("foo", rust_lib_name("foo-v2"))
39+
.extern_("use_foo", rust_lib_name("use_foo"))
40+
.library_search_path(cwd())
41+
.ui_testing()
42+
.run_fail()
43+
.stderr_utf8();
44+
45+
diff()
46+
.expected_file("main.stderr")
47+
.normalize(
48+
regex::escape(run_make_support::build_root().canonicalize().unwrap().to_str().unwrap()),
49+
"/build-root",
50+
)
51+
.normalize(r"\\", "/")
52+
.actual_text("(rustc)", &stderr)
53+
.run();
54+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use foo as _;

0 commit comments

Comments
 (0)