diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2021-08-26 18:37:44 +0000 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2021-11-07 15:03:40 +0000 |
| commit | 257ac1b4984f261dfe4572907955a24f43eee209 (patch) | |
| tree | 1d34fc788831e9b5b63a2a5020d29a06935a1094 /compiler/rustc_error_codes/src | |
| parent | 90a273b785b3bc482b82c4896ba1bdea68745e46 (diff) | |
| download | rust-257ac1b4984f261dfe4572907955a24f43eee209.tar.gz rust-257ac1b4984f261dfe4572907955a24f43eee209.zip | |
Improve error when an .rlib can't be parsed
This usually describes either an error in the compiler itself or some
sort of IO error. Either way, we should report it to the user rather
than just saying "crate not found".
This only gives an error if the crate couldn't be loaded at all - if the
compiler finds another .rlib or .rmeta file which was valid, it will
continue to compile the crate.
Example output:
```
error[E0785]: found invalid metadata files for crate `foo`
--> bar.rs:3:24
|
3 | println!("{}", foo::FOO_11_49[0]);
| ^^^
|
= warning: failed to parse rlib '/home/joshua/test-rustdoc/libfoo.rlib': Invalid archive extended name offset
```
Diffstat (limited to 'compiler/rustc_error_codes/src')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0786.md | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 42ce849c64d..ce26ff62235 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -484,6 +484,7 @@ E0782: include_str!("./error_codes/E0782.md"), E0783: include_str!("./error_codes/E0783.md"), E0784: include_str!("./error_codes/E0784.md"), E0785: include_str!("./error_codes/E0785.md"), +E0786: include_str!("./error_codes/E0786.md"), ; // E0006, // merged with E0005 // E0008, // cannot bind by-move into a pattern guard diff --git a/compiler/rustc_error_codes/src/error_codes/E0786.md b/compiler/rustc_error_codes/src/error_codes/E0786.md new file mode 100644 index 00000000000..4a9635bf516 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0786.md @@ -0,0 +1,14 @@ +A metadata file was invalid. + +Erroneous code example: + +```ignore (needs extern files) +use ::foo; // error: found invalid metadata files for crate `foo` +``` + +When loading crates, each crate must have a valid metadata file. +Invalid files could be caused by filesystem corruption, +an IO error while reading the file, or (rarely) a bug in the compiler itself. + +Consider deleting the file and recreating it, +or reporting a bug against the compiler. |
