Rollup merge of #103000 - wesleywiser:suggest_libname, r=compiler-errors

Add suggestion to the "missing native library" error

If we fail to locate a native library that we are linking with, it could be the case the user entered a complete file name like `foo.lib` or `libfoo.a` when we expect them to simply provide `foo`.

In this situation, we now detect that case and suggest the user only provide the library name itself.
This commit is contained in:
Matthias Krüger 2022-10-14 00:45:17 +02:00 committed by GitHub
commit c7f048ea00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 2 deletions

View file

@ -0,0 +1,9 @@
// build-fail
// compile-flags: --crate-type rlib
// error-pattern: could not find native static library `libfoo.a`
// error-pattern: only provide the library name `foo`, not the full filename
#[link(name = "libfoo.a", kind = "static")]
extern { }
pub fn main() { }

View file

@ -0,0 +1,6 @@
error: could not find native static library `libfoo.a`, perhaps an -L flag is missing?
|
= help: only provide the library name `foo`, not the full filename
error: aborting due to previous error

View file

@ -0,0 +1,9 @@
// build-fail
// compile-flags: --crate-type rlib
// error-pattern: could not find native static library `bar.lib`
// error-pattern: only provide the library name `bar`, not the full filename
#[link(name = "bar.lib", kind = "static")]
extern { }
pub fn main() { }

View file

@ -0,0 +1,6 @@
error: could not find native static library `bar.lib`, perhaps an -L flag is missing?
|
= help: only provide the library name `bar`, not the full filename
error: aborting due to previous error