Skip to content

Commit 0067078

Browse files
authored
Rollup merge of #97328 - petrochenkov:nativice, r=michaelwoerister
rustc: Fix ICE in native library error reporting Fixes #97299
2 parents d858d28 + c82a370 commit 0067078

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

compiler/rustc_metadata/src/native_libs.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,11 @@ impl<'tcx> Collector<'tcx> {
418418
// involved or not, library reordering and kind overriding without
419419
// explicit `:rename` in particular.
420420
if lib.has_modifiers() || passed_lib.has_modifiers() {
421-
self.tcx.sess.span_err(
422-
self.tcx.def_span(lib.foreign_module.unwrap()),
423-
"overriding linking modifiers from command line is not supported"
424-
);
421+
let msg = "overriding linking modifiers from command line is not supported";
422+
match lib.foreign_module {
423+
Some(def_id) => self.tcx.sess.span_err(self.tcx.def_span(def_id), msg),
424+
None => self.tcx.sess.err(msg),
425+
};
425426
}
426427
if passed_lib.kind != NativeLibKind::Unspecified {
427428
lib.kind = passed_lib.kind;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Regression test for issue #97299, one command line library with modifiers
2+
// overrides another command line library with modifiers.
3+
4+
// compile-flags:-lstatic:+whole-archive=foo -lstatic:+whole-archive=foo
5+
// error-pattern: overriding linking modifiers from command line is not supported
6+
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: overriding linking modifiers from command line is not supported
2+
3+
error: aborting due to previous error
4+

0 commit comments

Comments
 (0)