@@ -11,6 +11,8 @@ module Thir = struct
11
11
type generic_param_kind = generic_param_kind_for__decorated_for__expr_kind
12
12
type trait_item = trait_item_for__decorated_for__expr_kind
13
13
type ty = node_for__ty_kind
14
+ type item_ref = node_for__item_ref_contents
15
+ type trait_ref = item_ref
14
16
end
15
17
16
18
open ! Prelude
@@ -244,16 +246,16 @@ end) : EXPR = struct
244
246
(typ : ty ) =
245
247
let overloaded_names_of_binop : Thir.bin_op -> Concrete_ident.name =
246
248
function
247
- | Add -> Core__ops__arith__Add__add
248
- | Sub -> Core__ops__arith__Sub__sub
249
- | Mul -> Core__ops__arith__Mul__mul
249
+ | Add | AddUnchecked -> Core__ops__arith__Add__add
250
+ | Sub | SubUnchecked -> Core__ops__arith__Sub__sub
251
+ | Mul | MulUnchecked -> Core__ops__arith__Mul__mul
250
252
| Div -> Core__ops__arith__Div__div
251
253
| Rem -> Core__ops__arith__Rem__rem
252
254
| BitXor -> Core__ops__bit__BitXor__bitxor
253
255
| BitAnd -> Core__ops__bit__BitAnd__bitand
254
256
| BitOr -> Core__ops__bit__BitOr__bitor
255
- | Shl -> Core__ops__bit__Shl__shl
256
- | Shr -> Core__ops__bit__Shr__shr
257
+ | Shl | ShlUnchecked -> Core__ops__bit__Shl__shl
258
+ | Shr | ShrUnchecked -> Core__ops__bit__Shr__shr
257
259
| Lt -> Core__cmp__PartialOrd__lt
258
260
| Le -> Core__cmp__PartialOrd__le
259
261
| Ne -> Core__cmp__PartialEq__ne
@@ -269,16 +271,16 @@ end) : EXPR = struct
269
271
| Offset -> Core__ptr__const_ptr__Impl__offset
270
272
in
271
273
let primitive_names_of_binop : Thir.bin_op -> Concrete_ident.name = function
272
- | Add -> Rust_primitives__u128__add
273
- | Sub -> Rust_primitives__u128__sub
274
- | Mul -> Rust_primitives__u128__mul
274
+ | Add | AddUnchecked -> Rust_primitives__u128__add
275
+ | Sub | SubUnchecked -> Rust_primitives__u128__sub
276
+ | Mul | MulUnchecked -> Rust_primitives__u128__mul
275
277
| Div -> Rust_primitives__u128__div
276
278
| Rem -> Rust_primitives__u128__rem
277
279
| BitXor -> Rust_primitives__u128__bit_xor
278
280
| BitAnd -> Rust_primitives__u128__bit_and
279
281
| BitOr -> Rust_primitives__u128__bit_or
280
- | Shl -> Rust_primitives__u128__shl
281
- | Shr -> Rust_primitives__u128__shr
282
+ | Shl | ShlUnchecked -> Rust_primitives__u128__shl
283
+ | Shr | ShrUnchecked -> Rust_primitives__u128__shr
282
284
| Lt -> Rust_primitives__u128__lt
283
285
| Le -> Rust_primitives__u128__le
284
286
| Ne -> Rust_primitives__u128__ne
@@ -330,11 +332,12 @@ end) : EXPR = struct
330
332
let expected, f =
331
333
match op with
332
334
| Add | Sub | Mul | AddWithOverflow | SubWithOverflow
333
- | MulWithOverflow | Div ->
335
+ | MulWithOverflow | AddUnchecked | SubUnchecked | MulUnchecked | Div
336
+ ->
334
337
both int < |> both float
335
338
| Rem | Cmp -> both int
336
339
| BitXor | BitAnd | BitOr -> both int < |> both bool
337
- | Shl | Shr -> int < *> int
340
+ | Shl | Shr | ShlUnchecked | ShrUnchecked -> int < *> int
338
341
| Lt | Le | Ne | Ge | Gt -> both int < |> both float
339
342
| Eq -> both int < |> both float < |> both bool
340
343
| Offset -> (" " , fun _ -> Some " " )
@@ -504,38 +507,35 @@ end) : EXPR = struct
504
507
let then_ = c_expr then ' in
505
508
let else_ = Option. map ~f: c_expr else_opt in
506
509
If { cond; else_; then_ }
507
- | Call
508
- {
509
- args;
510
- fn_span = _;
511
- trait;
512
- from_hir_call = _;
513
- fun';
514
- ty = _;
515
- generic_args;
516
- bounds_impls;
517
- } ->
518
- let args = List. map ~f: c_expr args in
519
- let bounds_impls = List. map ~f: (c_impl_expr e.span) bounds_impls in
520
- let c_generic_values = List. map ~f: (c_generic_value e.span) in
521
- let generic_args = c_generic_values generic_args in
522
- let f =
523
- let f = c_expr fun' in
524
- match (trait, fun'.contents) with
525
- | Some _ , GlobalName { id; _ } ->
526
- { f with e = GlobalVar (def_id ~value: true id) }
527
- | _ -> f
510
+ | Call { args; fn_span = _ ; from_hir_call = _ ; fun'; ty = _ } -> (
511
+ let args =
512
+ if List. is_empty args then [ unit_expr span ]
513
+ else List. map ~f: c_expr args
528
514
in
529
- let args = if List. is_empty args then [ unit_expr span ] else args in
530
- App
531
- {
532
- f;
533
- args;
534
- generic_args;
535
- bounds_impls;
536
- trait =
537
- Option. map ~f: (c_impl_expr e.span *** c_generic_values) trait;
538
- }
515
+ let f = c_expr fun' in
516
+ match fun'.contents with
517
+ | GlobalName
518
+ {
519
+ item =
520
+ {
521
+ value = { def_id = id; generic_args; impl_exprs; in_trait };
522
+ _;
523
+ };
524
+ _;
525
+ } ->
526
+ let f = { f with e = GlobalVar (def_id ~value: true id) } in
527
+ let bounds_impls = List. map ~f: (c_impl_expr e.span) impl_exprs in
528
+ let generic_args =
529
+ List. map ~f: (c_generic_value e.span) generic_args
530
+ in
531
+ let in_trait = Option. map ~f: (c_impl_expr e.span) in_trait in
532
+ let trait =
533
+ Option. map ~f: (fun ie -> (ie, ie.goal.args)) in_trait
534
+ in
535
+ App { f; args; generic_args; bounds_impls; trait }
536
+ | _ ->
537
+ App
538
+ { f; args; generic_args = [] ; bounds_impls = [] ; trait = None })
539
539
| Box { value } ->
540
540
(U. call Rust_primitives__hax__box_new [ c_expr value ] span typ).e
541
541
| Deref { arg } ->
@@ -644,7 +644,9 @@ end) : EXPR = struct
644
644
trait = None (* TODO: see issue #328 *) ;
645
645
bounds_impls = [] ;
646
646
}
647
- | GlobalName { id; constructor = _ } -> GlobalVar (def_id ~value: true id)
647
+ | GlobalName { item = { value = { def_id = id; _ }; _ }; constructor = _ }
648
+ ->
649
+ GlobalVar (def_id ~value: true id)
648
650
| UpvarRef { var_hir_id = id ; _ } -> LocalVar (local_ident Expr id)
649
651
| Borrow { arg; borrow_kind = kind } ->
650
652
let e' = c_expr arg in
@@ -731,9 +733,14 @@ end) : EXPR = struct
731
733
typ = TInt { size = S8 ; signedness = Unsigned };
732
734
})
733
735
l))
734
- | NamedConst { def_id = id ; impl; args; _ } ->
736
+ | NamedConst
737
+ {
738
+ item =
739
+ { value = { def_id = id; generic_args; in_trait = impl; _ }; _ };
740
+ _;
741
+ } ->
735
742
let f = GlobalVar (def_id ~value: true id) in
736
- let args = List. map ~f: (c_generic_value e.span) args in
743
+ let args = List. map ~f: (c_generic_value e.span) generic_args in
737
744
let const_args =
738
745
List. filter_map args ~f: (function GConst e -> Some e | _ -> None )
739
746
in
@@ -853,7 +860,7 @@ end) : EXPR = struct
853
860
Array { fields = List. map ~f: constant_expr_to_expr fields }
854
861
| Tuple { fields } ->
855
862
Tuple { fields = List. map ~f: constant_expr_to_expr fields }
856
- | GlobalName { id; _ } -> GlobalName { id ; constructor = None }
863
+ | GlobalName item -> GlobalName { item ; constructor = None }
857
864
| Borrow arg ->
858
865
Borrow { arg = constant_expr_to_expr arg; borrow_kind = Thir. Shared }
859
866
| ConstRef { id } -> ConstRef { id }
@@ -1023,16 +1030,14 @@ end) : EXPR = struct
1023
1030
| Float k ->
1024
1031
TFloat
1025
1032
(match k with F16 -> F16 | F32 -> F32 | F64 -> F64 | F128 -> F128 )
1026
- | Arrow signature
1027
- | Closure (_, { untupled_sig = signature; _ })
1028
- | FnDef { fn_sig = signature ; _ } ->
1029
- let ({ inputs; output; _ } : Thir.ty_fn_sig ) = signature.value in
1033
+ | Arrow fn_sig | Closure { fn_sig; _ } | FnDef { fn_sig; _ } ->
1034
+ let ({ inputs; output; _ } : Thir.ty_fn_sig ) = fn_sig.value in
1030
1035
let inputs =
1031
1036
if List. is_empty inputs then [ U. unit_typ ]
1032
1037
else List. map ~f: (c_ty span) inputs
1033
1038
in
1034
1039
TArrow (inputs, c_ty span output)
1035
- | Adt { def_id = id ; generic_args; _ } ->
1040
+ | Adt { value = { def_id = id ; generic_args; _ } ; _ } ->
1036
1041
let ident = def_id ~value: false id in
1037
1042
let args = List. map ~f: (c_generic_value span) generic_args in
1038
1043
TApp { ident; args }
@@ -1117,15 +1122,15 @@ end) : EXPR = struct
1117
1122
let goal = c_trait_ref span ie.trait.value in
1118
1123
let impl = { kind = c_impl_expr_atom span ie.impl; goal } in
1119
1124
match ie.impl with
1120
- | Concrete { impl_exprs = [] ; _ } -> impl
1121
- | Concrete { impl_exprs; _ } ->
1125
+ | Concrete { value = { impl_exprs = [] ; _ } ; _ } -> impl
1126
+ | Concrete { value = { impl_exprs; _ } ; _ } ->
1122
1127
let args = List. map ~f: (c_impl_expr span) impl_exprs in
1123
1128
{ kind = ImplApp { impl; args }; goal }
1124
1129
| _ -> impl
1125
1130
1126
1131
and c_trait_ref span (tr : Thir.trait_ref ) : trait_goal =
1127
- let trait = Concrete_ident. of_def_id ~value: false tr.def_id in
1128
- let args = List. map ~f: (c_generic_value span) tr.generic_args in
1132
+ let trait = Concrete_ident. of_def_id ~value: false tr.value. def_id in
1133
+ let args = List. map ~f: (c_generic_value span) tr.value. generic_args in
1129
1134
{ trait; args }
1130
1135
1131
1136
and c_impl_expr_atom (span : Thir.span ) (ie : Thir.impl_expr_atom ) :
@@ -1139,7 +1144,7 @@ end) : EXPR = struct
1139
1144
let ident =
1140
1145
{ goal = c_trait_ref span trait_ref; name = predicate_id }
1141
1146
in
1142
- let item = Concrete_ident. of_def_id ~value: false item.def_id in
1147
+ let item = Concrete_ident. of_def_id ~value: false item.value. def_id in
1143
1148
let trait_ref = c_trait_ref span trait_ref in
1144
1149
Projection
1145
1150
{ impl = { kind = item_kind; goal = trait_ref }; ident; item }
@@ -1152,9 +1157,9 @@ end) : EXPR = struct
1152
1157
Parent { impl = { kind = item_kind; goal = trait_ref }; ident }
1153
1158
in
1154
1159
match ie with
1155
- | Concrete { id; generics ; _ } ->
1156
- let trait = Concrete_ident. of_def_id ~value: false id in
1157
- let args = List. map ~f: (c_generic_value span) generics in
1160
+ | Concrete { value = { def_id; generic_args; _ } ; _ } ->
1161
+ let trait = Concrete_ident. of_def_id ~value: false def_id in
1162
+ let args = List. map ~f: (c_generic_value span) generic_args in
1158
1163
Concrete { trait; args }
1159
1164
| LocalBound { predicate_id; path; _ } ->
1160
1165
let init = LocalBound { id = predicate_id } in
@@ -1249,8 +1254,12 @@ end) : EXPR = struct
1249
1254
generic_constraint option =
1250
1255
match kind with
1251
1256
| Trait { is_positive = true ; trait_ref } ->
1252
- let args = List. map ~f: (c_generic_value span) trait_ref.generic_args in
1253
- let trait = Concrete_ident. of_def_id ~value: false trait_ref.def_id in
1257
+ let args =
1258
+ List. map ~f: (c_generic_value span) trait_ref.value.generic_args
1259
+ in
1260
+ let trait =
1261
+ Concrete_ident. of_def_id ~value: false trait_ref.value.def_id
1262
+ in
1254
1263
Some (GCType { goal = { trait; args }; name = id })
1255
1264
| Projection { impl_expr; assoc_item; ty } ->
1256
1265
let impl = c_impl_expr span impl_expr in
@@ -1329,7 +1338,7 @@ include struct
1329
1338
1330
1339
let import_ty : Types.span -> Types.node_for__ty_kind -> Ast.Rust.ty = c_ty
1331
1340
1332
- let import_trait_ref : Types.span -> Types .trait_ref -> Ast.Rust.trait_goal =
1341
+ let import_trait_ref : Types.span -> Thir .trait_ref -> Ast.Rust.trait_goal =
1333
1342
c_trait_ref
1334
1343
1335
1344
let import_clause :
@@ -1777,9 +1786,10 @@ and c_item_unwrapped ~ident ~type_only (item : Thir.item) : item list =
1777
1786
generics = c_generics generics;
1778
1787
self_ty = c_ty item.span self_ty;
1779
1788
of_trait =
1780
- ( Concrete_ident. of_def_id ~value: false of_trait.def_id,
1781
- List. map ~f: (c_generic_value item.span) of_trait.generic_args
1782
- );
1789
+ ( Concrete_ident. of_def_id ~value: false of_trait.value.def_id,
1790
+ List. map
1791
+ ~f: (c_generic_value item.span)
1792
+ of_trait.value.generic_args );
1783
1793
items;
1784
1794
parent_bounds =
1785
1795
List. filter_map
0 commit comments