@@ -573,39 +573,36 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
573
573
:: structure_mapper ~await_context self rest
574
574
| Pstr_value (_ , vbs ) ->
575
575
let item = self.structure_item self item in
576
- let module_exprs =
576
+ (* [ module __Belt_List__ = module type of Belt.List ] *)
577
+ let module_type_decls =
577
578
vbs
578
579
|> List. filter_map (fun ({pvb_expr} : Parsetree.value_binding ) ->
579
580
match pvb_expr.pexp_desc with
580
581
| Pexp_letmodule (_, ({pmod_attributes} as me), _)
581
- when Res_parsetree_viewer. hasAwaitAttribute pmod_attributes ->
582
- Some me
583
- | _ -> None )
584
- in
585
- (* [ module __Belt_List__ = module type of Belt.List ] *)
586
- let module_type_decls =
587
- module_exprs
588
- |> List. filter_map (fun ({pmod_desc} as me : Parsetree.module_expr ) ->
589
- match pmod_desc with
590
- | Pmod_ident {txt; loc} -> (
591
- let safe_module_type_name = local_module_type_name txt in
592
- let has_local_module_name =
593
- Hashtbl. find_opt ! await_context safe_module_type_name
594
- in
582
+ when Res_parsetree_viewer. hasAwaitAttribute pmod_attributes
583
+ -> (
584
+ match me.pmod_desc with
585
+ | Pmod_ident {txt; loc} -> (
586
+ let safe_module_type_name = local_module_type_name txt in
587
+ let has_local_module_name =
588
+ Hashtbl. find_opt ! await_context safe_module_type_name
589
+ in
595
590
596
- match has_local_module_name with
597
- | Some _ -> None
598
- | None ->
599
- Hashtbl. add ! await_context safe_module_type_name
600
- safe_module_type_name;
601
- Some
602
- Ast_helper. (
603
- Str. modtype ~loc
604
- (Mtd. mk ~loc
605
- {txt = safe_module_type_name; loc}
606
- ~typ: (Mty. typeof_ ~loc me))))
591
+ match has_local_module_name with
592
+ | Some _ -> None
593
+ | None ->
594
+ Hashtbl. add ! await_context safe_module_type_name
595
+ safe_module_type_name;
596
+ Some
597
+ Ast_helper. (
598
+ Str. modtype ~loc
599
+ (Mtd. mk ~loc
600
+ {txt = safe_module_type_name; loc}
601
+ ~typ: (Mty. typeof_ ~loc me))))
602
+ | _ -> None )
607
603
| _ -> None )
608
604
in
605
+
609
606
module_type_decls @ (item :: structure_mapper ~await_context self rest)
610
607
| _ ->
611
608
self.structure_item self item :: structure_mapper ~await_context self rest
0 commit comments