3
3
//! this module handles intrinsics
4
4
use super :: typ;
5
5
use super :: { bb_label, PropertyClass } ;
6
- use crate :: codegen_cprover_gotoc:: codegen:: ty_stable:: { pointee_type_stable, pretty_ty } ;
6
+ use crate :: codegen_cprover_gotoc:: codegen:: ty_stable:: pointee_type_stable;
7
7
use crate :: codegen_cprover_gotoc:: { utils, GotocCtx } ;
8
8
use crate :: unwrap_or_return_codegen_unimplemented_stmt;
9
9
use cbmc:: goto_program:: {
@@ -646,7 +646,7 @@ impl<'tcx> GotocCtx<'tcx> {
646
646
span,
647
647
format ! (
648
648
"Type check failed for intrinsic `{name}`: Expected {expected}, found {}" ,
649
- pretty_ty( actual)
649
+ self . pretty_ty( actual)
650
650
) ,
651
651
) ;
652
652
self . tcx . dcx ( ) . abort_if_errors ( ) ;
@@ -779,12 +779,16 @@ impl<'tcx> GotocCtx<'tcx> {
779
779
if layout. abi . is_uninhabited ( ) {
780
780
return self . codegen_fatal_error (
781
781
PropertyClass :: SafetyCheck ,
782
- & format ! ( "attempted to instantiate uninhabited type `{}`" , pretty_ty( * target_ty) ) ,
782
+ & format ! (
783
+ "attempted to instantiate uninhabited type `{}`" ,
784
+ self . pretty_ty( * target_ty)
785
+ ) ,
783
786
span,
784
787
) ;
785
788
}
786
789
787
- let param_env_and_type = ParamEnv :: reveal_all ( ) . and ( rustc_internal:: internal ( target_ty) ) ;
790
+ let param_env_and_type =
791
+ ParamEnv :: reveal_all ( ) . and ( rustc_internal:: internal ( self . tcx , target_ty) ) ;
788
792
789
793
// Then we check if the type allows "raw" initialization for the cases
790
794
// where memory is zero-initialized or entirely uninitialized
@@ -798,7 +802,7 @@ impl<'tcx> GotocCtx<'tcx> {
798
802
PropertyClass :: SafetyCheck ,
799
803
& format ! (
800
804
"attempted to zero-initialize type `{}`, which is invalid" ,
801
- pretty_ty( * target_ty)
805
+ self . pretty_ty( * target_ty)
802
806
) ,
803
807
span,
804
808
) ;
@@ -817,7 +821,7 @@ impl<'tcx> GotocCtx<'tcx> {
817
821
PropertyClass :: SafetyCheck ,
818
822
& format ! (
819
823
"attempted to leave type `{}` uninitialized, which is invalid" ,
820
- pretty_ty( * target_ty)
824
+ self . pretty_ty( * target_ty)
821
825
) ,
822
826
span,
823
827
) ;
@@ -1285,7 +1289,7 @@ impl<'tcx> GotocCtx<'tcx> {
1285
1289
_ => {
1286
1290
let err_msg = format ! (
1287
1291
"simd_shuffle index must be an array of `u32`, got `{}`" ,
1288
- pretty_ty( farg_types[ 2 ] )
1292
+ self . pretty_ty( farg_types[ 2 ] )
1289
1293
) ;
1290
1294
utils:: span_err ( self . tcx , span, err_msg) ;
1291
1295
// Return a dummy value
@@ -1378,7 +1382,7 @@ impl<'tcx> GotocCtx<'tcx> {
1378
1382
1379
1383
// Packed types ignore the alignment of their fields.
1380
1384
if let TyKind :: RigidTy ( RigidTy :: Adt ( def, _) ) = ty. kind ( ) {
1381
- if rustc_internal:: internal ( def) . repr ( ) . packed ( ) {
1385
+ if rustc_internal:: internal ( self . tcx , def) . repr ( ) . packed ( ) {
1382
1386
unsized_align = sized_align. clone ( ) ;
1383
1387
}
1384
1388
}
@@ -1426,9 +1430,9 @@ impl<'tcx> GotocCtx<'tcx> {
1426
1430
if rust_ret_type != vector_base_type {
1427
1431
let err_msg = format ! (
1428
1432
"expected return type `{}` (element of input `{}`), found `{}`" ,
1429
- pretty_ty( vector_base_type) ,
1430
- pretty_ty( rust_arg_types[ 0 ] ) ,
1431
- pretty_ty( rust_ret_type)
1433
+ self . pretty_ty( vector_base_type) ,
1434
+ self . pretty_ty( rust_arg_types[ 0 ] ) ,
1435
+ self . pretty_ty( rust_ret_type)
1432
1436
) ;
1433
1437
utils:: span_err ( self . tcx , span, err_msg) ;
1434
1438
}
@@ -1466,9 +1470,9 @@ impl<'tcx> GotocCtx<'tcx> {
1466
1470
if vector_base_type != rust_arg_types[ 2 ] {
1467
1471
let err_msg = format ! (
1468
1472
"expected inserted type `{}` (element of input `{}`), found `{}`" ,
1469
- pretty_ty( vector_base_type) ,
1470
- pretty_ty( rust_arg_types[ 0 ] ) ,
1471
- pretty_ty( rust_arg_types[ 2 ] ) ,
1473
+ self . pretty_ty( vector_base_type) ,
1474
+ self . pretty_ty( rust_arg_types[ 0 ] ) ,
1475
+ self . pretty_ty( rust_arg_types[ 2 ] ) ,
1472
1476
) ;
1473
1477
utils:: span_err ( self . tcx , span, err_msg) ;
1474
1478
}
@@ -1534,8 +1538,8 @@ impl<'tcx> GotocCtx<'tcx> {
1534
1538
"expected return type with length {} (same as input type `{}`), \
1535
1539
found `{}` with length {}",
1536
1540
arg1. typ( ) . len( ) . unwrap( ) ,
1537
- pretty_ty( rust_arg_types[ 0 ] ) ,
1538
- pretty_ty( rust_ret_type) ,
1541
+ self . pretty_ty( rust_arg_types[ 0 ] ) ,
1542
+ self . pretty_ty( rust_ret_type) ,
1539
1543
ret_typ. len( ) . unwrap( )
1540
1544
) ;
1541
1545
utils:: span_err ( self . tcx , span, err_msg) ;
@@ -1545,8 +1549,8 @@ impl<'tcx> GotocCtx<'tcx> {
1545
1549
let ( _, rust_base_type) = self . simd_size_and_type ( rust_ret_type) ;
1546
1550
let err_msg = format ! (
1547
1551
"expected return type with integer elements, found `{}` with non-integer `{}`" ,
1548
- pretty_ty( rust_ret_type) ,
1549
- pretty_ty( rust_base_type) ,
1552
+ self . pretty_ty( rust_ret_type) ,
1553
+ self . pretty_ty( rust_base_type) ,
1550
1554
) ;
1551
1555
utils:: span_err ( self . tcx , span, err_msg) ;
1552
1556
}
@@ -1740,18 +1744,18 @@ impl<'tcx> GotocCtx<'tcx> {
1740
1744
if ret_type_len != n {
1741
1745
let err_msg = format ! (
1742
1746
"expected return type of length {n}, found `{}` with length {ret_type_len}" ,
1743
- pretty_ty( rust_ret_type) ,
1747
+ self . pretty_ty( rust_ret_type) ,
1744
1748
) ;
1745
1749
utils:: span_err ( self . tcx , span, err_msg) ;
1746
1750
}
1747
1751
if vec_subtype != ret_type_subtype {
1748
1752
let err_msg = format ! (
1749
1753
"expected return element type `{}` (element of input `{}`), \
1750
1754
found `{}` with element type `{}`",
1751
- pretty_ty( vec_subtype) ,
1752
- pretty_ty( rust_arg_types[ 0 ] ) ,
1753
- pretty_ty( rust_ret_type) ,
1754
- pretty_ty( ret_type_subtype) ,
1755
+ self . pretty_ty( vec_subtype) ,
1756
+ self . pretty_ty( rust_arg_types[ 0 ] ) ,
1757
+ self . pretty_ty( rust_ret_type) ,
1758
+ self . pretty_ty( ret_type_subtype) ,
1755
1759
) ;
1756
1760
utils:: span_err ( self . tcx , span, err_msg) ;
1757
1761
}
0 commit comments