diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-10-14 00:45:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-14 00:45:17 +0200 |
| commit | c7f048ea00c35dc6d30ba8e63ace96bbc65cc153 (patch) | |
| tree | 05d11b6549672b176fd0bafbc79b808ec50c7445 /src/test | |
| parent | 6b3ede3f7bc502eba7bbd202b4b9312d812adcd7 (diff) | |
| parent | 097b6d3bafb1d61bfe8fd3f5e9d9acfd9ee2c702 (diff) | |
| download | rust-c7f048ea00c35dc6d30ba8e63ace96bbc65cc153.tar.gz rust-c7f048ea00c35dc6d30ba8e63ace96bbc65cc153.zip | |
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.
Diffstat (limited to 'src/test')
4 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/native-library-link-flags/suggest-libname-only-1.rs b/src/test/ui/native-library-link-flags/suggest-libname-only-1.rs new file mode 100644 index 00000000000..abf988a7c1e --- /dev/null +++ b/src/test/ui/native-library-link-flags/suggest-libname-only-1.rs @@ -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() { } diff --git a/src/test/ui/native-library-link-flags/suggest-libname-only-1.stderr b/src/test/ui/native-library-link-flags/suggest-libname-only-1.stderr new file mode 100644 index 00000000000..64d0a9077ed --- /dev/null +++ b/src/test/ui/native-library-link-flags/suggest-libname-only-1.stderr @@ -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 + diff --git a/src/test/ui/native-library-link-flags/suggest-libname-only-2.rs b/src/test/ui/native-library-link-flags/suggest-libname-only-2.rs new file mode 100644 index 00000000000..dfa70e56db7 --- /dev/null +++ b/src/test/ui/native-library-link-flags/suggest-libname-only-2.rs @@ -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() { } diff --git a/src/test/ui/native-library-link-flags/suggest-libname-only-2.stderr b/src/test/ui/native-library-link-flags/suggest-libname-only-2.stderr new file mode 100644 index 00000000000..e166af9ed8f --- /dev/null +++ b/src/test/ui/native-library-link-flags/suggest-libname-only-2.stderr @@ -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 + |
