Skip to content

Commit 6af338d

Browse files
estebankcuviper
authored andcommitted
Do not ICE on foreign malformed diagnostic::on_unimplemented
Fix rust-lang#124651. (cherry picked from commit 4847f22)
1 parent a269819 commit 6af338d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs

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

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

0 commit comments

Comments
 (0)