Skip to content

Commit 4847f22

Browse files
committed
Do not ICE on foreign malformed diagnostic::on_unimplemented
Fix #124651.
1 parent 0d7b2fb commit 4847f22

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Diff for: compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,14 @@ impl<'tcx> OnUnimplementedDirective {
499499
}
500500

501501
if is_diagnostic_namespace_variant {
502-
tcx.emit_node_span_lint(
503-
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
504-
tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
505-
vec![item.span()],
506-
MalformedOnUnimplementedAttrLint::new(item.span()),
507-
);
502+
if let Some(def_id) = item_def_id.as_local() {
503+
tcx.emit_node_span_lint(
504+
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
505+
tcx.local_def_id_to_hir_id(def_id),
506+
vec![item.span()],
507+
MalformedOnUnimplementedAttrLint::new(item.span()),
508+
);
509+
}
508510
} else {
509511
// nothing found
510512
tcx.dcx().emit_err(NoValueInOnUnimplemented { span: item.span() });

0 commit comments

Comments
 (0)