1
1
use super :: operand:: { OperandRef , OperandValue } ;
2
2
use super :: place:: PlaceRef ;
3
3
use 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 ;
5
7
use crate :: glue;
6
8
use crate :: meth;
7
9
use crate :: traits:: * ;
@@ -305,15 +307,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
305
307
_ => bug ! ( ) ,
306
308
} ,
307
309
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 } ) ;
317
311
return ;
318
312
}
319
313
}
@@ -329,45 +323,19 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
329
323
_ => bug ! ( ) ,
330
324
} ,
331
325
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 ] } ) ;
341
327
return ;
342
328
}
343
329
}
344
330
}
345
331
346
332
sym:: float_to_int_unchecked => {
347
333
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 ] } ) ;
358
335
return ;
359
336
}
360
337
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 } ) ;
371
339
return ;
372
340
} ;
373
341
if signed {
@@ -402,7 +370,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
402
370
use crate :: common:: { AtomicRmwBinOp , SynchronizationScope } ;
403
371
404
372
let Some ( ( instruction, ordering) ) = atomic. split_once ( '_' ) else {
405
- bx. sess ( ) . fatal ( "Atomic intrinsic missing memory ordering" ) ;
373
+ bx. sess ( ) . emit_fatal ( errors :: MissingMemoryOrdering ) ;
406
374
} ;
407
375
408
376
let parse_ordering = |bx : & Bx , s| match s {
@@ -412,25 +380,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
412
380
"release" => Release ,
413
381
"acqrel" => AcquireRelease ,
414
382
"seqcst" => SequentiallyConsistent ,
415
- _ => bx. sess ( ) . fatal ( "unknown ordering in atomic intrinsic" ) ,
383
+ _ => bx. sess ( ) . emit_fatal ( errors :: UnknownAtomicOrdering ) ,
416
384
} ;
417
385
418
386
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 } ) ;
428
388
} ;
429
389
430
390
match instruction {
431
391
"cxchg" | "cxchgweak" => {
432
392
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 ) ;
434
394
} ;
435
395
let ty = substs. type_at ( 0 ) ;
436
396
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> {
529
489
"min" => AtomicRmwBinOp :: AtomicMin ,
530
490
"umax" => AtomicRmwBinOp :: AtomicUMax ,
531
491
"umin" => AtomicRmwBinOp :: AtomicUMin ,
532
- _ => bx. sess ( ) . fatal ( "unknown atomic operation" ) ,
492
+ _ => bx. sess ( ) . emit_fatal ( errors :: UnknownAtomicOperation ) ,
533
493
} ;
534
494
535
495
let ty = substs. type_at ( 0 ) ;
0 commit comments