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:: * ;
@@ -299,15 +301,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
299
301
_ => bug ! ( ) ,
300
302
} ,
301
303
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 } ) ;
311
305
return ;
312
306
}
313
307
}
@@ -323,45 +317,19 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
323
317
_ => bug ! ( ) ,
324
318
} ,
325
319
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 ] } ) ;
335
321
return ;
336
322
}
337
323
}
338
324
}
339
325
340
326
sym:: float_to_int_unchecked => {
341
327
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 ] } ) ;
352
329
return ;
353
330
}
354
331
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 } ) ;
365
333
return ;
366
334
} ;
367
335
if signed {
@@ -396,7 +364,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
396
364
use crate :: common:: { AtomicRmwBinOp , SynchronizationScope } ;
397
365
398
366
let Some ( ( instruction, ordering) ) = atomic. split_once ( '_' ) else {
399
- bx. sess ( ) . fatal ( "Atomic intrinsic missing memory ordering" ) ;
367
+ bx. sess ( ) . emit_fatal ( errors :: MissingMemoryOrdering ) ;
400
368
} ;
401
369
402
370
let parse_ordering = |bx : & Bx , s| match s {
@@ -406,25 +374,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
406
374
"release" => Release ,
407
375
"acqrel" => AcquireRelease ,
408
376
"seqcst" => SequentiallyConsistent ,
409
- _ => bx. sess ( ) . fatal ( "unknown ordering in atomic intrinsic" ) ,
377
+ _ => bx. sess ( ) . emit_fatal ( errors :: UnknownAtomicOrdering ) ,
410
378
} ;
411
379
412
380
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 } ) ;
422
382
} ;
423
383
424
384
match instruction {
425
385
"cxchg" | "cxchgweak" => {
426
386
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 ) ;
428
388
} ;
429
389
let ty = substs. type_at ( 0 ) ;
430
390
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> {
523
483
"min" => AtomicRmwBinOp :: AtomicMin ,
524
484
"umax" => AtomicRmwBinOp :: AtomicUMax ,
525
485
"umin" => AtomicRmwBinOp :: AtomicUMin ,
526
- _ => bx. sess ( ) . fatal ( "unknown atomic operation" ) ,
486
+ _ => bx. sess ( ) . emit_fatal ( errors :: UnknownAtomicOperation ) ,
527
487
} ;
528
488
529
489
let ty = substs. type_at ( 0 ) ;
0 commit comments