Skip to content

Commit 7169c7d

Browse files
committed
Tests for bad --extern library path and file
1 parent 395f2b8 commit 7169c7d

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

compiler/rustc_metadata/src/locator.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,6 @@ impl CrateError {
10261026
None => String::new(),
10271027
Some(r) => format!(" which `{}` depends on", r.name),
10281028
};
1029-
// FIXME: There are no tests for CrateLocationUnknownType or LibFilenameForm
10301029
if !locator.crate_rejections.via_filename.is_empty() {
10311030
let mismatches = locator.crate_rejections.via_filename.iter();
10321031
for CrateMismatch { path, .. } in mismatches {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// compile-flags: --extern foo={{src-base}}/errors/issue-104621-extern-bad-file.rs
2+
// only-linux
3+
4+
extern crate foo;
5+
//~^ ERROR extern location for foo is of an unknown type
6+
//~| ERROR file name should be lib*.rlib or lib*.so
7+
//~| ERROR can't find crate for `foo` [E0463]
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: extern location for foo is of an unknown type: $DIR/issue-104621-extern-bad-file.rs
2+
--> $DIR/issue-104621-extern-bad-file.rs:4:1
3+
|
4+
LL | extern crate foo;
5+
| ^^^^^^^^^^^^^^^^^
6+
7+
error: file name should be lib*.rlib or lib*.so
8+
--> $DIR/issue-104621-extern-bad-file.rs:4:1
9+
|
10+
LL | extern crate foo;
11+
| ^^^^^^^^^^^^^^^^^
12+
13+
error[E0463]: can't find crate for `foo`
14+
--> $DIR/issue-104621-extern-bad-file.rs:4:1
15+
|
16+
LL | extern crate foo;
17+
| ^^^^^^^^^^^^^^^^^ can't find crate
18+
19+
error: aborting due to 3 previous errors
20+
21+
For more information about this error, try `rustc --explain E0463`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// compile-flags: --extern foo=.
2+
3+
extern crate foo; //~ ERROR extern location for foo is not a file: .
4+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: extern location for foo is not a file: .
2+
--> $DIR/issue-104621-extern-not-file.rs:3:1
3+
|
4+
LL | extern crate foo;
5+
| ^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)