diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-05-25 17:37:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-25 17:37:20 +0200 |
| commit | 006707834fc1001631a1c3851f70e4793a9bb370 (patch) | |
| tree | 5fd6fe2f73dd37558e767d04fd3eefd31cd5fa28 | |
| parent | d858d280e4778e556e8b8595e20d36d229bda6e9 (diff) | |
| parent | c82a3706f7f4560ae0e742a19a854b3cf755fc62 (diff) | |
| download | rust-006707834fc1001631a1c3851f70e4793a9bb370.tar.gz rust-006707834fc1001631a1c3851f70e4793a9bb370.zip | |
Rollup merge of #97328 - petrochenkov:nativice, r=michaelwoerister
rustc: Fix ICE in native library error reporting Fixes https://github.com/rust-lang/rust/issues/97299
3 files changed, 16 insertions, 4 deletions
diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 8d044be195a..95892d83414 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -418,10 +418,11 @@ impl<'tcx> Collector<'tcx> { // involved or not, library reordering and kind overriding without // explicit `:rename` in particular. if lib.has_modifiers() || passed_lib.has_modifiers() { - self.tcx.sess.span_err( - self.tcx.def_span(lib.foreign_module.unwrap()), - "overriding linking modifiers from command line is not supported" - ); + let msg = "overriding linking modifiers from command line is not supported"; + match lib.foreign_module { + Some(def_id) => self.tcx.sess.span_err(self.tcx.def_span(def_id), msg), + None => self.tcx.sess.err(msg), + }; } if passed_lib.kind != NativeLibKind::Unspecified { lib.kind = passed_lib.kind; diff --git a/src/test/ui/native-library-link-flags/modifiers-override-3.rs b/src/test/ui/native-library-link-flags/modifiers-override-3.rs new file mode 100644 index 00000000000..b28c53c6b0a --- /dev/null +++ b/src/test/ui/native-library-link-flags/modifiers-override-3.rs @@ -0,0 +1,7 @@ +// Regression test for issue #97299, one command line library with modifiers +// overrides another command line library with modifiers. + +// compile-flags:-lstatic:+whole-archive=foo -lstatic:+whole-archive=foo +// error-pattern: overriding linking modifiers from command line is not supported + +fn main() {} diff --git a/src/test/ui/native-library-link-flags/modifiers-override-3.stderr b/src/test/ui/native-library-link-flags/modifiers-override-3.stderr new file mode 100644 index 00000000000..365e5618100 --- /dev/null +++ b/src/test/ui/native-library-link-flags/modifiers-override-3.stderr @@ -0,0 +1,4 @@ +error: overriding linking modifiers from command line is not supported + +error: aborting due to previous error + |
