1
Fork 0

Move FnPtrAddr error to SessionDiagnostic

This commit is contained in:
Matthew Jasper 2023-04-07 19:45:17 +01:00
parent 94524020ea
commit f7f2eb3e41
3 changed files with 14 additions and 4 deletions

View file

@ -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_inline_asm_not_supported = assembly is not supported in generic constants
ty_utils_operation_not_supported = unsupported operation 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

View file

@ -67,3 +67,10 @@ pub enum GenericConstantTooComplexSub {
#[label(ty_utils_operation_not_supported)] #[label(ty_utils_operation_not_supported)]
OperationNotSupported(#[primary_span] Span), OperationNotSupported(#[primary_span] Span),
} }
#[derive(Diagnostic)]
#[diag(ty_utils_unexpected_fnptr_associated_item)]
pub struct UnexpectedFnPtrAssociatedItem {
#[primary_span]
pub span: Span,
}

View file

@ -8,6 +8,8 @@ use rustc_span::sym;
use rustc_trait_selection::traits; use rustc_trait_selection::traits;
use traits::{translate_substs, Reveal}; use traits::{translate_substs, Reveal};
use crate::errors::UnexpectedFnPtrAssociatedItem;
fn resolve_instance<'tcx>( fn resolve_instance<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>, key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>,
@ -282,10 +284,9 @@ fn resolve_associated_item<'tcx>(
substs: rcvr_substs, substs: rcvr_substs,
}) })
} else { } else {
tcx.sess.span_fatal( tcx.sess.emit_fatal(UnexpectedFnPtrAssociatedItem {
tcx.def_span(trait_item_id), span: tcx.def_span(trait_item_id),
"`FnPtrAddr` trait with unexpected assoc item", })
)
} }
} else { } else {
None None