Add a test for not resolving ambiguity for multiple --extern with same name
This commit is contained in:
parent
d10216a3a8
commit
b01a2fb652
6 changed files with 79 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
pub struct Foo;
|
||||
|
|
@ -0,0 +1 @@
|
|||
pub struct Foo;
|
||||
10
tests/run-make/duplicate-dependency-no-disambiguate/main.rs
Normal file
10
tests/run-make/duplicate-dependency-no-disambiguate/main.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#![feature(custom_inner_attributes)]
|
||||
#![rustfmt::skip] // use_foo must be referenced before foo
|
||||
|
||||
// Load foo-v2 through use-foo
|
||||
use use_foo as _;
|
||||
|
||||
// Make sure we don't disambiguate this as foo-v2.
|
||||
use foo as _;
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error[E0464]: multiple candidates for `rlib` dependency `foo` found
|
||||
--> main.rs:8:5
|
||||
|
|
||||
LL | use foo as _;
|
||||
| ^^^
|
||||
|
|
||||
= note: candidate #1: /build-root/test/run-make/duplicate-dependency-no-disambiguate/rmake_out/libfoo-v1.rlib
|
||||
= note: candidate #2: /build-root/test/run-make/duplicate-dependency-no-disambiguate/rmake_out/libfoo-v2.rlib
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0464`.
|
||||
54
tests/run-make/duplicate-dependency-no-disambiguate/rmake.rs
Normal file
54
tests/run-make/duplicate-dependency-no-disambiguate/rmake.rs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
//@ needs-target-std
|
||||
|
||||
use run_make_support::{Rustc, cwd, diff, regex, rust_lib_name, rustc};
|
||||
|
||||
fn rustc_with_common_args() -> Rustc {
|
||||
let mut rustc = rustc();
|
||||
rustc.remap_path_prefix(cwd(), "$DIR");
|
||||
rustc.edition("2018"); // Don't require `extern crate`
|
||||
rustc
|
||||
}
|
||||
|
||||
fn main() {
|
||||
rustc_with_common_args()
|
||||
.input("foo-v1.rs")
|
||||
.crate_type("rlib")
|
||||
.crate_name("foo")
|
||||
.extra_filename("-v1")
|
||||
.metadata("-v1")
|
||||
.run();
|
||||
|
||||
rustc_with_common_args()
|
||||
.input("foo-v2.rs")
|
||||
.crate_type("rlib")
|
||||
.crate_name("foo")
|
||||
.extra_filename("-v2")
|
||||
.metadata("-v2")
|
||||
.run();
|
||||
|
||||
rustc_with_common_args()
|
||||
.input("use-foo.rs")
|
||||
.crate_type("rlib")
|
||||
.extern_("foo", rust_lib_name("foo-v2"))
|
||||
.run();
|
||||
|
||||
let stderr = rustc_with_common_args()
|
||||
.input("main.rs")
|
||||
.extern_("foo", rust_lib_name("foo-v1"))
|
||||
.extern_("foo", rust_lib_name("foo-v2"))
|
||||
.extern_("use_foo", rust_lib_name("use_foo"))
|
||||
.library_search_path(cwd())
|
||||
.ui_testing()
|
||||
.run_fail()
|
||||
.stderr_utf8();
|
||||
|
||||
diff()
|
||||
.expected_file("main.stderr")
|
||||
.normalize(
|
||||
regex::escape(run_make_support::build_root().canonicalize().unwrap().to_str().unwrap()),
|
||||
"/build-root",
|
||||
)
|
||||
.normalize(r"\\", "/")
|
||||
.actual_text("(rustc)", &stderr)
|
||||
.run();
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
use foo as _;
|
||||
Loading…
Add table
Add a link
Reference in a new issue