@@ -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 = unboxed_item_ref
15
+ type trait_ref = item_ref
14
16
end
15
17
16
18
open ! Prelude
@@ -504,38 +506,29 @@ end) : EXPR = struct
504
506
let then_ = c_expr then ' in
505
507
let else_ = Option. map ~f: c_expr else_opt in
506
508
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
509
+ | Call { args; fn_span = _ ; from_hir_call = _ ; fun'; ty = _ } -> (
510
+ let args =
511
+ if List. is_empty args then [ unit_expr span ]
512
+ else List. map ~f: c_expr args
528
513
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
- }
514
+ let f = c_expr fun' in
515
+ match fun'.contents with
516
+ | GlobalName
517
+ { item = { def_id = id; generic_args; impl_exprs; in_trait }; _ }
518
+ ->
519
+ let f = { f with e = GlobalVar (def_id ~value: true id) } in
520
+ let bounds_impls = List. map ~f: (c_impl_expr e.span) impl_exprs in
521
+ let generic_args =
522
+ List. map ~f: (c_generic_value e.span) generic_args
523
+ in
524
+ let in_trait = Option. map ~f: (c_impl_expr e.span) in_trait in
525
+ let trait =
526
+ Option. map ~f: (fun ie -> (ie, ie.goal.args)) in_trait
527
+ in
528
+ App { f; args; generic_args; bounds_impls; trait }
529
+ | _ ->
530
+ App
531
+ { f; args; generic_args = [] ; bounds_impls = [] ; trait = None })
539
532
| Box { value } ->
540
533
(U. call Rust_primitives__hax__box_new [ c_expr value ] span typ).e
541
534
| Deref { arg } ->
@@ -644,7 +637,8 @@ end) : EXPR = struct
644
637
trait = None (* TODO: see issue #328 *) ;
645
638
bounds_impls = [] ;
646
639
}
647
- | GlobalName { id; constructor = _ } -> GlobalVar (def_id ~value: true id)
640
+ | GlobalName { item = { def_id = id ; _ } ; constructor = _ } ->
641
+ GlobalVar (def_id ~value: true id)
648
642
| UpvarRef { var_hir_id = id ; _ } -> LocalVar (local_ident Expr id)
649
643
| Borrow { arg; borrow_kind = kind } ->
650
644
let e' = c_expr arg in
@@ -731,9 +725,10 @@ end) : EXPR = struct
731
725
typ = TInt { size = S8 ; signedness = Unsigned };
732
726
})
733
727
l))
734
- | NamedConst { def_id = id ; impl; args; _ } ->
728
+ | NamedConst
729
+ { item = { def_id = id; generic_args; in_trait = impl; _ }; _ } ->
735
730
let f = GlobalVar (def_id ~value: true id) in
736
- let args = List. map ~f: (c_generic_value e.span) args in
731
+ let args = List. map ~f: (c_generic_value e.span) generic_args in
737
732
let const_args =
738
733
List. filter_map args ~f: (function GConst e -> Some e | _ -> None )
739
734
in
@@ -853,7 +848,7 @@ end) : EXPR = struct
853
848
Array { fields = List. map ~f: constant_expr_to_expr fields }
854
849
| Tuple { fields } ->
855
850
Tuple { fields = List. map ~f: constant_expr_to_expr fields }
856
- | GlobalName { id; _ } -> GlobalName { id ; constructor = None }
851
+ | GlobalName item -> GlobalName { item ; constructor = None }
857
852
| Borrow arg ->
858
853
Borrow { arg = constant_expr_to_expr arg; borrow_kind = Thir. Shared }
859
854
| ConstRef { id } -> ConstRef { id }
@@ -1152,9 +1147,9 @@ end) : EXPR = struct
1152
1147
Parent { impl = { kind = item_kind; goal = trait_ref }; ident }
1153
1148
in
1154
1149
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
1150
+ | Concrete { def_id; generic_args ; _ } ->
1151
+ let trait = Concrete_ident. of_def_id ~value: false def_id in
1152
+ let args = List. map ~f: (c_generic_value span) generic_args in
1158
1153
Concrete { trait; args }
1159
1154
| LocalBound { predicate_id; path; _ } ->
1160
1155
let init = LocalBound { id = predicate_id } in
@@ -1329,7 +1324,7 @@ include struct
1329
1324
1330
1325
let import_ty : Types.span -> Types.node_for__ty_kind -> Ast.Rust.ty = c_ty
1331
1326
1332
- let import_trait_ref : Types.span -> Types .trait_ref -> Ast.Rust.trait_goal =
1327
+ let import_trait_ref : Types.span -> Thir .trait_ref -> Ast.Rust.trait_goal =
1333
1328
c_trait_ref
1334
1329
1335
1330
let import_clause :
0 commit comments