diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-05-03 21:53:19 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-05-03 21:53:19 +0000 |
| commit | 4847f2249f03b249956d2daa90a12f4ee66543a8 (patch) | |
| tree | 59ce720a84f2bb0a407386f864891a3d90a8ab67 | |
| parent | 0d7b2fb797f214ea7514cfeaf2caef8178d8e3fc (diff) | |
| download | rust-4847f2249f03b249956d2daa90a12f4ee66543a8.tar.gz rust-4847f2249f03b249956d2daa90a12f4ee66543a8.zip | |
Do not ICE on foreign malformed `diagnostic::on_unimplemented`
Fix #124651.
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index 07bd209e623..f1eb5b7e826 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -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() }); |
