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:: * ;
@@ -305,15 +307,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
305307 _ => bug ! ( ) ,
306308 } ,
307309 None => {
308- span_invalid_monomorphization_error (
309- bx. tcx ( ) . sess ,
310- span,
311- & format ! (
312- "invalid monomorphization of `{}` intrinsic: \
313- expected basic integer type, found `{}`",
314- name, ty
315- ) ,
316- ) ;
310+ bx. tcx ( ) . sess . emit_err ( InvalidMonomorphization :: BasicIntegerType { span, name, ty } ) ;
317311 return ;
318312 }
319313 }
@@ -329,45 +323,19 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
329323 _ => bug ! ( ) ,
330324 } ,
331325 None => {
332- span_invalid_monomorphization_error (
333- bx. tcx ( ) . sess ,
334- span,
335- & format ! (
336- "invalid monomorphization of `{}` intrinsic: \
337- expected basic float type, found `{}`",
338- name, arg_tys[ 0 ]
339- ) ,
340- ) ;
326+ bx. tcx ( ) . sess . emit_err ( InvalidMonomorphization :: BasicFloatType { span, name, ty : arg_tys[ 0 ] } ) ;
341327 return ;
342328 }
343329 }
344330 }
345331
346332 sym:: float_to_int_unchecked => {
347333 if float_type_width ( arg_tys[ 0 ] ) . is_none ( ) {
348- span_invalid_monomorphization_error (
349- bx. tcx ( ) . sess ,
350- span,
351- & format ! (
352- "invalid monomorphization of `float_to_int_unchecked` \
353- intrinsic: expected basic float type, \
354- found `{}`",
355- arg_tys[ 0 ]
356- ) ,
357- ) ;
334+ bx. tcx ( ) . sess . emit_err ( InvalidMonomorphization :: FloatToIntUnchecked { span, ty : arg_tys[ 0 ] } ) ;
358335 return ;
359336 }
360337 let Some ( ( _width, signed) ) = int_type_width_signed ( ret_ty, bx. tcx ( ) ) else {
361- span_invalid_monomorphization_error (
362- bx. tcx ( ) . sess ,
363- span,
364- & format ! (
365- "invalid monomorphization of `float_to_int_unchecked` \
366- intrinsic: expected basic integer type, \
367- found `{}`",
368- ret_ty
369- ) ,
370- ) ;
338+ bx. tcx ( ) . sess . emit_err ( InvalidMonomorphization :: FloatToIntUnchecked { span, ty : ret_ty } ) ;
371339 return ;
372340 } ;
373341 if signed {
@@ -402,7 +370,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
402370 use crate :: common:: { AtomicRmwBinOp , SynchronizationScope } ;
403371
404372 let Some ( ( instruction, ordering) ) = atomic. split_once ( '_' ) else {
405- bx. sess ( ) . fatal ( "Atomic intrinsic missing memory ordering" ) ;
373+ bx. sess ( ) . emit_fatal ( errors :: MissingMemoryOrdering ) ;
406374 } ;
407375
408376 let parse_ordering = |bx : & Bx , s| match s {
@@ -412,25 +380,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
412380 "release" => Release ,
413381 "acqrel" => AcquireRelease ,
414382 "seqcst" => SequentiallyConsistent ,
415- _ => bx. sess ( ) . fatal ( "unknown ordering in atomic intrinsic" ) ,
383+ _ => bx. sess ( ) . emit_fatal ( errors :: UnknownAtomicOrdering ) ,
416384 } ;
417385
418386 let invalid_monomorphization = |ty| {
419- span_invalid_monomorphization_error (
420- bx. tcx ( ) . sess ,
421- span,
422- & format ! (
423- "invalid monomorphization of `{}` intrinsic: \
424- expected basic integer type, found `{}`",
425- name, ty
426- ) ,
427- ) ;
387+ bx. tcx ( ) . sess . emit_err ( InvalidMonomorphization :: BasicIntegerType { span, name, ty } ) ;
428388 } ;
429389
430390 match instruction {
431391 "cxchg" | "cxchgweak" => {
432392 let Some ( ( success, failure) ) = ordering. split_once ( '_' ) else {
433- bx. sess ( ) . fatal ( "Atomic compare-exchange intrinsic missing failure memory ordering" ) ;
393+ bx. sess ( ) . emit_fatal ( errors :: AtomicCompareExchange ) ;
434394 } ;
435395 let ty = substs. type_at ( 0 ) ;
436396 if int_type_width_signed ( ty, bx. tcx ( ) ) . is_some ( ) || ty. is_unsafe_ptr ( ) {
@@ -529,7 +489,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
529489 "min" => AtomicRmwBinOp :: AtomicMin ,
530490 "umax" => AtomicRmwBinOp :: AtomicUMax ,
531491 "umin" => AtomicRmwBinOp :: AtomicUMin ,
532- _ => bx. sess ( ) . fatal ( "unknown atomic operation" ) ,
492+ _ => bx. sess ( ) . emit_fatal ( errors :: UnknownAtomicOperation ) ,
533493 } ;
534494
535495 let ty = substs. type_at ( 0 ) ;
0 commit comments