From 7dd5e3c1cd5c150f16261fef6a1efb76e70f022e Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 28 Jul 2023 11:31:31 +0200 Subject: [PATCH] Add regression test for resolving `--extern libc=test.rlib` I could not find a test for this particular use case. The closest I got was `tests/ui/imports/issue-37887.rs`, but that is a regression test for a different use case. --- tests/ui/imports/resolve-other-libc.rs | 14 ++++++++++++++ tests/ui/imports/resolve-other-libc.stderr | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/ui/imports/resolve-other-libc.rs create mode 100644 tests/ui/imports/resolve-other-libc.stderr diff --git a/tests/ui/imports/resolve-other-libc.rs b/tests/ui/imports/resolve-other-libc.rs new file mode 100644 index 00000000000..806d854ec89 --- /dev/null +++ b/tests/ui/imports/resolve-other-libc.rs @@ -0,0 +1,14 @@ +// Regression test for https://github.com/rust-lang/rust/issues/26043 + +// compile-flags: --extern libc=test.rlib + +// The error shall NOT be something similar to the following, because it +// indicates that `libc` was wrongly resolved to `libc` shipped with the +// compiler: +// +// error[E0658]: use of unstable library feature 'rustc_private': \ +// this crate is being loaded from the sysroot +// +extern crate libc; //~ ERROR: extern location for libc does not exist: test.rlib + +fn main() {} diff --git a/tests/ui/imports/resolve-other-libc.stderr b/tests/ui/imports/resolve-other-libc.stderr new file mode 100644 index 00000000000..e57b88e50c6 --- /dev/null +++ b/tests/ui/imports/resolve-other-libc.stderr @@ -0,0 +1,8 @@ +error: extern location for libc does not exist: test.rlib + --> $DIR/resolve-other-libc.rs:12:1 + | +LL | extern crate libc; + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error +