Skip to content

Commit 054a2bd

Browse files
Dylan-DPCehuss
authored andcommittedJun 1, 2022
Rollup merge of #97328 - petrochenkov:nativice, r=michaelwoerister
rustc: Fix ICE in native library error reporting Fixes #97299
1 parent 0a2d181 commit 054a2bd

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed
 

Diff for: ‎compiler/rustc_metadata/src/native_libs.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,11 @@ impl<'tcx> Collector<'tcx> {
383383
// involved or not, library reordering and kind overriding without
384384
// explicit `:rename` in particular.
385385
if lib.has_modifiers() || passed_lib.has_modifiers() {
386-
self.tcx.sess.span_err(
387-
self.tcx.def_span(lib.foreign_module.unwrap()),
388-
"overriding linking modifiers from command line is not supported"
389-
);
386+
let msg = "overriding linking modifiers from command line is not supported";
387+
match lib.foreign_module {
388+
Some(def_id) => self.tcx.sess.span_err(self.tcx.def_span(def_id), msg),
389+
None => self.tcx.sess.err(msg),
390+
};
390391
}
391392
if passed_lib.kind != NativeLibKind::Unspecified {
392393
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)