diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2023-04-07 19:45:17 +0100 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2023-04-07 19:48:27 +0100 |
| commit | f7f2eb3e4171e4b87dbcab3a9a6709d5d084c54f (patch) | |
| tree | 8e3275eb19094bddb404884826d6cbcec8e06f26 | |
| parent | 94524020ea12f7947275063b65f8b7d705be073e (diff) | |
| download | rust-f7f2eb3e4171e4b87dbcab3a9a6709d5d084c54f.tar.gz rust-f7f2eb3e4171e4b87dbcab3a9a6709d5d084c54f.zip | |
Move `FnPtrAddr` error to `SessionDiagnostic`
| -rw-r--r-- | compiler/rustc_ty_utils/messages.ftl | 2 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/errors.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/instance.rs | 9 |
3 files changed, 14 insertions, 4 deletions
diff --git a/compiler/rustc_ty_utils/messages.ftl b/compiler/rustc_ty_utils/messages.ftl index abe65a0e3fe..e0aa27b73f6 100644 --- a/compiler/rustc_ty_utils/messages.ftl +++ b/compiler/rustc_ty_utils/messages.ftl @@ -45,3 +45,5 @@ ty_utils_control_flow_not_supported = control flow is not supported in generic c ty_utils_inline_asm_not_supported = assembly is not supported in generic constants ty_utils_operation_not_supported = unsupported operation in generic constants + +ty_utils_unexpected_fnptr_associated_item = `FnPtr` trait with unexpected associated item diff --git a/compiler/rustc_ty_utils/src/errors.rs b/compiler/rustc_ty_utils/src/errors.rs index ab3e62f0484..c05815d510a 100644 --- a/compiler/rustc_ty_utils/src/errors.rs +++ b/compiler/rustc_ty_utils/src/errors.rs @@ -67,3 +67,10 @@ pub enum GenericConstantTooComplexSub { #[label(ty_utils_operation_not_supported)] OperationNotSupported(#[primary_span] Span), } + +#[derive(Diagnostic)] +#[diag(ty_utils_unexpected_fnptr_associated_item)] +pub struct UnexpectedFnPtrAssociatedItem { + #[primary_span] + pub span: Span, +} diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index ad70154c98e..0a6c118093e 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -8,6 +8,8 @@ use rustc_span::sym; use rustc_trait_selection::traits; use traits::{translate_substs, Reveal}; +use crate::errors::UnexpectedFnPtrAssociatedItem; + fn resolve_instance<'tcx>( tcx: TyCtxt<'tcx>, key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>, @@ -282,10 +284,9 @@ fn resolve_associated_item<'tcx>( substs: rcvr_substs, }) } else { - tcx.sess.span_fatal( - tcx.def_span(trait_item_id), - "`FnPtrAddr` trait with unexpected assoc item", - ) + tcx.sess.emit_fatal(UnexpectedFnPtrAssociatedItem { + span: tcx.def_span(trait_item_id), + }) } } else { None |
