File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -849,11 +849,8 @@ let structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t) =
849849 shapes specially, e.g. a module path in [module type of] or [()] as the
850850 argument of a generative functor. *)
851851let module_expr_mapper (self : mapper ) (me : Parsetree.module_expr ) =
852- match me.pmod_desc with
853- | Pmod_await inner ->
854- self.module_expr self
855- {inner with pmod_attributes = me.pmod_attributes @ inner.pmod_attributes}
856- | _ -> default_mapper.module_expr self me
852+ let _, me = Ast_await. remove_awaits false me in
853+ default_mapper.module_expr self me
857854
858855let mapper : mapper =
859856 {
Original file line number Diff line number Diff line change @@ -25,20 +25,23 @@ let is_await_expr (e : Parsetree.expression) =
2525 true
2626 | _ -> false
2727
28+ (* [m] without its outer awaits, e.g. [await (await M)], whose attributes
29+ (e.g. [@warning]) stay on the module they wrap, and whether it had any
30+ ([awaited] for the awaits already removed) *)
31+ let rec remove_awaits awaited (m : Parsetree.module_expr ) =
32+ match m.pmod_desc with
33+ | Pmod_await inner ->
34+ remove_awaits true
35+ {inner with pmod_attributes = m.pmod_attributes @ inner.pmod_attributes}
36+ | _ -> (awaited, m)
37+
2838(* An awaited module path: [await M], and [await (M: S)] or [(await M: S)],
2939 where [await] may be repeated, e.g. [await (await M)]. Returns the path of
3040 [M]; the module to import, which is [e] without its awaits, whose
3141 attributes (e.g. [@warning]) stay on the module they wrap; and [S] for the
3242 constrained forms. It is a dynamic import when [S] is absent or a module
3343 type path. *)
3444let awaited_module_path (e : Parsetree.module_expr ) =
35- let rec remove_awaits awaited (m : Parsetree.module_expr ) =
36- match m.pmod_desc with
37- | Pmod_await inner ->
38- remove_awaits true
39- {inner with pmod_attributes = m.pmod_attributes @ inner.pmod_attributes}
40- | _ -> (awaited, m)
41- in
4245 match remove_awaits false e with
4346 | true , ({pmod_desc = Pmod_ident lid } as imported ) ->
4447 Some (lid, imported, None )
You can’t perform that action at this time.
0 commit comments