11use super :: operand:: { OperandRef , OperandValue } ;
22use super :: place:: PlaceRef ;
33use super :: FunctionCx ;
4- use crate :: common:: { span_invalid_monomorphization_error, IntPredicate } ;
4+ use crate :: common:: IntPredicate ;
5+ use crate :: errors;
6+ use crate :: errors:: InvalidMonomorphization ;
57use crate :: glue;
68use crate :: meth;
79use crate :: traits:: * ;
@@ -299,15 +301,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
299301 _ => bug ! ( ) ,
300302 } ,
301303 None => {
302- span_invalid_monomorphization_error (
303- bx. tcx ( ) . sess ,
304- span,
305- & format ! (
306- "invalid monomorphization of `{}` intrinsic: \
307- expected basic integer type, found `{}`",
308- name, ty
309- ) ,
310- ) ;
304+ bx. tcx ( ) . sess . emit_err ( InvalidMonomorphization :: BasicIntegerType { span, name, ty } ) ;
311305 return ;
312306 }
313307 }
@@ -323,45 +317,19 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
323317 _ => bug ! ( ) ,
324318 } ,
325319 None => {
326- span_invalid_monomorphization_error (
327- bx. tcx ( ) . sess ,
328- span,
329- & format ! (
330- "invalid monomorphization of `{}` intrinsic: \
331- expected basic float type, found `{}`",
332- name, arg_tys[ 0 ]
333- ) ,
334- ) ;
320+ bx. tcx ( ) . sess . emit_err ( InvalidMonomorphization :: BasicFloatType { span, name, ty : arg_tys[ 0 ] } ) ;
335321 return ;
336322 }
337323 }
338324 }
339325
340326 sym:: float_to_int_unchecked => {
341327 if float_type_width ( arg_tys[ 0 ] ) . is_none ( ) {
342- span_invalid_monomorphization_error (
343- bx. tcx ( ) . sess ,
344- span,
345- & format ! (
346- "invalid monomorphization of `float_to_int_unchecked` \
347- intrinsic: expected basic float type, \
348- found `{}`",
349- arg_tys[ 0 ]
350- ) ,
351- ) ;
328+ bx. tcx ( ) . sess . emit_err ( InvalidMonomorphization :: FloatToIntUnchecked { span, ty : arg_tys[ 0 ] } ) ;
352329 return ;
353330 }
354331 let Some ( ( _width, signed) ) = int_type_width_signed ( ret_ty, bx. tcx ( ) ) else {
355- span_invalid_monomorphization_error (
356- bx. tcx ( ) . sess ,
357- span,
358- & format ! (
359- "invalid monomorphization of `float_to_int_unchecked` \
360- intrinsic: expected basic integer type, \
361- found `{}`",
362- ret_ty
363- ) ,
364- ) ;
332+ bx. tcx ( ) . sess . emit_err ( InvalidMonomorphization :: FloatToIntUnchecked { span, ty : ret_ty } ) ;
365333 return ;
366334 } ;
367335 if signed {
@@ -396,7 +364,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
396364 use crate :: common:: { AtomicRmwBinOp , SynchronizationScope } ;
397365
398366 let Some ( ( instruction, ordering) ) = atomic. split_once ( '_' ) else {
399- bx. sess ( ) . fatal ( "Atomic intrinsic missing memory ordering" ) ;
367+ bx. sess ( ) . emit_fatal ( errors :: MissingMemoryOrdering ) ;
400368 } ;
401369
402370 let parse_ordering = |bx : & Bx , s| match s {
@@ -406,25 +374,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
406374 "release" => Release ,
407375 "acqrel" => AcquireRelease ,
408376 "seqcst" => SequentiallyConsistent ,
409- _ => bx. sess ( ) . fatal ( "unknown ordering in atomic intrinsic" ) ,
377+ _ => bx. sess ( ) . emit_fatal ( errors :: UnknownAtomicOrdering ) ,
410378 } ;
411379
412380 let invalid_monomorphization = |ty| {
413- span_invalid_monomorphization_error (
414- bx. tcx ( ) . sess ,
415- span,
416- & format ! (
417- "invalid monomorphization of `{}` intrinsic: \
418- expected basic integer type, found `{}`",
419- name, ty
420- ) ,
421- ) ;
381+ bx. tcx ( ) . sess . emit_err ( InvalidMonomorphization :: BasicIntegerType { span, name, ty } ) ;
422382 } ;
423383
424384 match instruction {
425385 "cxchg" | "cxchgweak" => {
426386 let Some ( ( success, failure) ) = ordering. split_once ( '_' ) else {
427- bx. sess ( ) . fatal ( "Atomic compare-exchange intrinsic missing failure memory ordering" ) ;
387+ bx. sess ( ) . emit_fatal ( errors :: AtomicCompareExchange ) ;
428388 } ;
429389 let ty = substs. type_at ( 0 ) ;
430390 if int_type_width_signed ( ty, bx. tcx ( ) ) . is_some ( ) || ty. is_unsafe_ptr ( ) {
@@ -523,7 +483,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
523483 "min" => AtomicRmwBinOp :: AtomicMin ,
524484 "umax" => AtomicRmwBinOp :: AtomicUMax ,
525485 "umin" => AtomicRmwBinOp :: AtomicUMin ,
526- _ => bx. sess ( ) . fatal ( "unknown atomic operation" ) ,
486+ _ => bx. sess ( ) . emit_fatal ( errors :: UnknownAtomicOperation ) ,
527487 } ;
528488
529489 let ty = substs. type_at ( 0 ) ;
0 commit comments