about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2023-08-02 13:46:54 +0200
committerGitHub <noreply@github.com>2023-08-02 13:46:54 +0200
commitddda3fa0b00a127a91ab06adadb046bbbea10fea (patch)
tree6d8b9f0f79de929f1e72bb3a76e592af4a442080
parent46f6b05eb749ecf21a3728aa3e179f215d57f5a2 (diff)
parent7dd5e3c1cd5c150f16261fef6a1efb76e70f022e (diff)
downloadrust-ddda3fa0b00a127a91ab06adadb046bbbea10fea.tar.gz
rust-ddda3fa0b00a127a91ab06adadb046bbbea10fea.zip
Rollup merge of #114166 - Enselic:libc-unavailable, r=Nilstrieb
Add regression test for resolving `--extern libc=test.rlib`

Closes #26043

I could not find a test for this particular use case. The closest I got was [`tests/ui/imports/issue-37887.rs`](https://github.com/rust-lang/rust/blob/master/tests/ui/imports/issue-37887.rs), but that is a regression test for a different use case (see https://github.com/rust-lang/rust/issues/37887).
-rw-r--r--tests/ui/imports/resolve-other-libc.rs14
-rw-r--r--tests/ui/imports/resolve-other-libc.stderr8
2 files changed, 22 insertions, 0 deletions
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
+