Auto merge of #124683 - estebank:issue-124651, r=compiler-errors

Do not ICE on foreign malformed `diagnostic::on_unimplemented`

Fix #124651.
This commit is contained in:
bors 2024-05-08 00:54:38 +00:00
commit a60f077c38
4 changed files with 44 additions and 6 deletions

View file

@ -499,12 +499,14 @@ impl<'tcx> OnUnimplementedDirective {
}
if is_diagnostic_namespace_variant {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(item_def_id.expect_local()),
vec![item.span()],
MalformedOnUnimplementedAttrLint::new(item.span()),
);
if let Some(def_id) = item_def_id.as_local() {
tcx.emit_node_span_lint(
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
tcx.local_def_id_to_hir_id(def_id),
vec![item.span()],
MalformedOnUnimplementedAttrLint::new(item.span()),
);
}
} else {
// nothing found
tcx.dcx().emit_err(NoValueInOnUnimplemented { span: item.span() });