Skip to content

Commit f7f2eb3

Browse files
committed
Move FnPtrAddr error to SessionDiagnostic
1 parent 9452402 commit f7f2eb3

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

compiler/rustc_ty_utils/messages.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ ty_utils_control_flow_not_supported = control flow is not supported in generic c
4545
ty_utils_inline_asm_not_supported = assembly is not supported in generic constants
4646
4747
ty_utils_operation_not_supported = unsupported operation in generic constants
48+
49+
ty_utils_unexpected_fnptr_associated_item = `FnPtr` trait with unexpected associated item

compiler/rustc_ty_utils/src/errors.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,10 @@ pub enum GenericConstantTooComplexSub {
6767
#[label(ty_utils_operation_not_supported)]
6868
OperationNotSupported(#[primary_span] Span),
6969
}
70+
71+
#[derive(Diagnostic)]
72+
#[diag(ty_utils_unexpected_fnptr_associated_item)]
73+
pub struct UnexpectedFnPtrAssociatedItem {
74+
#[primary_span]
75+
pub span: Span,
76+
}

compiler/rustc_ty_utils/src/instance.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use rustc_span::sym;
88
use rustc_trait_selection::traits;
99
use traits::{translate_substs, Reveal};
1010

11+
use crate::errors::UnexpectedFnPtrAssociatedItem;
12+
1113
fn resolve_instance<'tcx>(
1214
tcx: TyCtxt<'tcx>,
1315
key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>,
@@ -282,10 +284,9 @@ fn resolve_associated_item<'tcx>(
282284
substs: rcvr_substs,
283285
})
284286
} else {
285-
tcx.sess.span_fatal(
286-
tcx.def_span(trait_item_id),
287-
"`FnPtrAddr` trait with unexpected assoc item",
288-
)
287+
tcx.sess.emit_fatal(UnexpectedFnPtrAssociatedItem {
288+
span: tcx.def_span(trait_item_id),
289+
})
289290
}
290291
} else {
291292
None

0 commit comments

Comments
 (0)