@@ -587,12 +587,6 @@ let rec fmt_extension_aux c ctx ~key (ext, pld) =
587587 assert (not (Cmts. has_before c.cmts pstr_loc)) ;
588588 assert (not (Cmts. has_after c.cmts pstr_loc)) ;
589589 hvbox 0 (fmt_quoted_string (Ext.Key. to_string key) ext str delim)
590- | _, PStr [({pstr_loc; _} as si)], (Pld _ | Str _ | Top )
591- when Source. extension_using_sugar ~name: ext ~payload: pstr_loc ->
592- fmt_structure_item c ~last: true ~ext ~semisemi: false (sub_str ~ctx si)
593- | _, PSig [({psig_loc; _} as si)], (Pld _ | Sig _ | Top )
594- when Source. extension_using_sugar ~name: ext ~payload: psig_loc ->
595- fmt_signature_item c ~ext (sub_sig ~ctx si)
596590 | _, PPat (({ppat_loc; _} as pat), _), (Pld _ | Top )
597591 when Source. extension_using_sugar ~name: ext ~payload: ppat_loc ->
598592 fmt_pattern c ~ext (sub_pat ~ctx pat)
@@ -3328,7 +3322,9 @@ and fmt_type_extension c ctx
33283322 ; ptyext_loc } =
33293323 let c = update_config_attrs c ptyext_attributes in
33303324 let ext = ptyext_attributes.attrs_extension in
3331- let doc, _doc_after, attrs_before, attrs_after = fmt_docstring_around_item_attrs ~force_before: true c ptyext_attributes in
3325+ let doc, _doc_after, attrs_before, attrs_after =
3326+ fmt_docstring_around_item_attrs ~force_before: true c ptyext_attributes
3327+ in
33323328 let fmt_ctor ctor = hvbox 0 (fmt_extension_constructor c ctx ctor) in
33333329 Cmts. fmt c ptyext_loc
33343330 @@ hvbox 2
@@ -3354,17 +3350,24 @@ and fmt_type_extension c ctx
33543350and fmt_type_exception ~pre c ctx
33553351 {ptyexn_attributes = item_attrs ; ptyexn_constructor; ptyexn_loc} =
33563352 let {pext_attributes= cons_attrs; _} = ptyexn_constructor in
3357- let docs, item_attrs = extract_doc_attrs [] item_attrs in
3353+ let docs, attrs_before = extract_doc_attrs [] item_attrs.attrs_before in
3354+ let docs, attrs_after = extract_doc_attrs docs item_attrs.attrs_after in
33583355 let docs, cons_attrs = extract_doc_attrs docs cons_attrs in
33593356 let doc_before, doc_after = fmt_docstring_around_item' c docs in
33603357 let ptyexn_constructor =
33613358 {ptyexn_constructor with pext_attributes= cons_attrs}
33623359 in
3360+ let ext = item_attrs.attrs_extension in
33633361 Cmts. fmt c ptyexn_loc
33643362 (hvbox 0
33653363 ( doc_before
3366- $ hvbox 2 (pre $ fmt_extension_constructor c ctx ptyexn_constructor)
3367- $ fmt_item_attributes c ~pre: (Break (1 , 0 )) item_attrs
3364+ $ hvbox 2
3365+ ( pre
3366+ $ fmt_extension_suffix c ext
3367+ $ fmt_attributes c ~pre: (Break (1 , 0 )) attrs_before
3368+ $ fmt " @ "
3369+ $ fmt_extension_constructor c ctx ptyexn_constructor )
3370+ $ fmt_item_attributes c ~pre: (Break (1 , 0 )) attrs_after
33683371 $ doc_after ) )
33693372
33703373and fmt_extension_constructor c ctx ec =
@@ -3514,7 +3517,7 @@ and fmt_signature c ctx itms =
35143517 let ast x = Sig x in
35153518 fmt_item_list c ctx update_config ast fmt_item itms
35163519
3517- and fmt_signature_item c ? ext {ast = si ; _} =
3520+ and fmt_signature_item c {ast = si ; _} =
35183521 protect c (Sig si)
35193522 @@
35203523 let fmt_cmts_before = Cmts.Toplevel. fmt_before c si.psig_loc in
@@ -3525,7 +3528,7 @@ and fmt_signature_item c ?ext {ast= si; _} =
35253528 match si.psig_desc with
35263529 | Psig_attribute attr -> fmt_floating_attributes_and_docstrings c [attr]
35273530 | Psig_exception exc ->
3528- let pre = str " exception" $ fmt_extension_suffix c ext $ fmt " @ " in
3531+ let pre = str " exception" in
35293532 hvbox 2 (fmt_type_exception ~pre c ctx exc)
35303533 | Psig_extension (ext , atrs ) ->
35313534 let doc_before, doc_after, atrs = fmt_docstring_around_item c atrs in
@@ -4095,8 +4098,8 @@ and fmt_type c ?eq rec_flag decls ctx =
40954098 let ast x = Td x in
40964099 fmt_item_list c ctx update_config ast fmt_decl decls
40974100
4098- and fmt_structure_item c ~last :last_item ? ext ~semisemi
4099- { ctx = parent_ctx ; ast = si } =
4101+ and fmt_structure_item c ~last :last_item ~semisemi { ctx = parent_ctx ; ast = si }
4102+ =
41004103 protect c (Str si)
41014104 @@
41024105 let ctx = Str si in
@@ -4115,7 +4118,7 @@ and fmt_structure_item c ~last:last_item ?ext ~semisemi
41154118 $ cbox 0 ~name: " eval" (fmt_expression c (sub_exp ~ctx exp))
41164119 $ fmt_item_attributes c ~pre: Space atrs
41174120 | Pstr_exception extn_constr ->
4118- let pre = str " exception" $ fmt_extension_suffix c ext $ fmt " @ " in
4121+ let pre = str " exception" in
41194122 hvbox 2 ~name: " exn" (fmt_type_exception ~pre c ctx extn_constr)
41204123 | Pstr_include {pincl_mod; pincl_attributes = attributes ; pincl_loc} ->
41214124 update_config_maybe_disabled_attrs c pincl_loc attributes
@@ -4133,9 +4136,8 @@ and fmt_structure_item c ~last:last_item ?ext ~semisemi
41334136 fmt_or_k
41344137 (is_override popen_override)
41354138 ( str " open!"
4136- $ fmt_if (Option. is_some attributes.attrs_extension) " @ "
4137- $ opt ext (fun _ -> str " " $ fmt_extension_suffix c ext) )
4138- (str " open" $ fmt_extension_suffix c ext)
4139+ $ fmt_if (Option. is_some attributes.attrs_extension) " @ " )
4140+ (str " open" )
41394141 in
41404142 fmt_module_statement c ~attributes ~keyword (sub_mod ~ctx popen_expr)
41414143 | Pstr_primitive vd -> fmt_value_description c ctx vd
0 commit comments