Tests for bad --extern library path and file

This commit is contained in:
Steven Tang 2022-11-22 17:09:47 +11:00
parent 395f2b84e6
commit 7169c7d105
No known key found for this signature in database
GPG Key ID: 1597520C734BAE66
5 changed files with 41 additions and 1 deletions

View File

@ -1026,7 +1026,6 @@ impl CrateError {
None => String::new(),
Some(r) => format!(" which `{}` depends on", r.name),
};
// FIXME: There are no tests for CrateLocationUnknownType or LibFilenameForm
if !locator.crate_rejections.via_filename.is_empty() {
let mismatches = locator.crate_rejections.via_filename.iter();
for CrateMismatch { path, .. } in mismatches {

View File

@ -0,0 +1,8 @@
// compile-flags: --extern foo={{src-base}}/errors/issue-104621-extern-bad-file.rs
// only-linux
extern crate foo;
//~^ ERROR extern location for foo is of an unknown type
//~| ERROR file name should be lib*.rlib or lib*.so
//~| ERROR can't find crate for `foo` [E0463]
fn main() {}

View File

@ -0,0 +1,21 @@
error: extern location for foo is of an unknown type: $DIR/issue-104621-extern-bad-file.rs
--> $DIR/issue-104621-extern-bad-file.rs:4:1
|
LL | extern crate foo;
| ^^^^^^^^^^^^^^^^^
error: file name should be lib*.rlib or lib*.so
--> $DIR/issue-104621-extern-bad-file.rs:4:1
|
LL | extern crate foo;
| ^^^^^^^^^^^^^^^^^
error[E0463]: can't find crate for `foo`
--> $DIR/issue-104621-extern-bad-file.rs:4:1
|
LL | extern crate foo;
| ^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0463`.

View File

@ -0,0 +1,4 @@
// compile-flags: --extern foo=.
extern crate foo; //~ ERROR extern location for foo is not a file: .
fn main() {}

View File

@ -0,0 +1,8 @@
error: extern location for foo is not a file: .
--> $DIR/issue-104621-extern-not-file.rs:3:1
|
LL | extern crate foo;
| ^^^^^^^^^^^^^^^^^
error: aborting due to previous error