Skip to content

Commit dd96f16

Browse files
revert changes
1 parent 50e9b7a commit dd96f16

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

lib/Fmt_ast.ml

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -404,23 +404,20 @@ let docstring_epi ~standalone ~next ~epi ~floating =
404404
str "\n" $ epi
405405
| _ -> epi
406406

407-
let fmt_docstring' c ?(standalone = false) ?pro ?epi doc =
408-
list_pn doc (fun ~prev:_ ({txt; loc}, floating) ~next ->
407+
let fmt_docstring c ?(standalone = false) ?pro ?epi doc =
408+
list_pn (Option.value ~default:[] doc)
409+
(fun ~prev:_ ({txt; loc}, floating) ~next ->
409410
let epi = docstring_epi ~standalone ~next ~epi ~floating in
410411
fmt_parsed_docstring c ~loc ?pro ~epi txt (Docstring.parse ~loc txt) )
411412

412-
let fmt_docstring c ?standalone ?pro ?epi doc =
413-
fmt_docstring' c ?standalone ?pro ?epi (Option.value ~default:[] doc)
414-
415-
(** Accept up to two docstrings, in reverse order of appearance. *)
416413
let fmt_docstring_around_item' ?(is_val = false) ?(force_before = false)
417-
?(fit = false) c docs =
418-
match docs with
419-
| doc2 :: doc1 :: _ ->
420-
( fmt_docstring' c ~epi:(fmt "@\n") doc1
421-
, fmt_docstring' c ~pro:(fmt "@\n") doc2 )
422-
| [] -> (noop, noop)
423-
| [doc] -> (
414+
?(fit = false) c doc1 doc2 =
415+
match (doc1, doc2) with
416+
| Some _, Some _ ->
417+
( fmt_docstring c ~epi:(fmt "@\n") doc1
418+
, fmt_docstring c ~pro:(fmt "@\n") doc2 )
419+
| None, None -> (noop, noop)
420+
| None, Some doc | Some doc, None -> (
424421
let is_tag_only =
425422
List.for_all ~f:(function
426423
| Ok es, _ -> Docstring.is_tag_only es
@@ -789,8 +786,9 @@ and fmt_core_type c ?(box = true) ?pro ?(pro_space = true) ?constraint_ctx
789786
Cmts.fmt c ptyp_loc
790787
@@ (fun k -> k $ fmt_docstring c ~pro:(fmt "@ ") doc)
791788
@@ ( if List.is_empty atrs then Fn.id
792-
else fun k ->
793-
hvbox 0 (Params.parens c.conf (k $ fmt_attributes c ~pre:Cut atrs)) )
789+
else fun k ->
790+
hvbox 0 (Params.parens c.conf (k $ fmt_attributes c ~pre:Cut atrs))
791+
)
794792
@@
795793
let parens = parenze_typ xtyp in
796794
hvbox_if box 0
@@ -874,10 +872,10 @@ and fmt_core_type c ?(box = true) ?pro ?(pro_space = true) ?constraint_ctx
874872
| _ ->
875873
list rfs
876874
( if
877-
in_type_declaration
878-
&& Poly.(c.conf.fmt_opts.type_decl.v = `Sparse)
879-
then "@;<1000 0>| "
880-
else "@ | " )
875+
in_type_declaration
876+
&& Poly.(c.conf.fmt_opts.type_decl.v = `Sparse)
877+
then "@;<1000 0>| "
878+
else "@ | " )
881879
(fmt_row_field c ctx)
882880
in
883881
let protect_token = Exposed.Right.(list ~elt:row_field) rfs in
@@ -2265,13 +2263,13 @@ and fmt_expression c ?(box = true) ?pro ?epi ?eol ?parens ?(indent_wrap = 0)
22652263
Sugar.Let_binding.of_let_bindings c.cmts ~ctx lbs.pvbs_bindings
22662264
in
22672265
let fmt_expr = fmt_expression c (sub_exp ~ctx body) in
2268-
fmt_let_bindings c ~parens ~fmt_atrs ~fmt_expr ~has_attr
2269-
lbs.pvbs_rec bindings body
2266+
fmt_let_bindings c ~parens ~fmt_atrs ~fmt_expr ~has_attr lbs.pvbs_rec
2267+
bindings body
22702268
| Pexp_letop {let_; ands; body} ->
22712269
let bd = Sugar.Let_binding.of_binding_ops c.cmts ~ctx (let_ :: ands) in
22722270
let fmt_expr = fmt_expression c (sub_exp ~ctx body) in
2273-
fmt_let_bindings c ~parens ~fmt_atrs ~fmt_expr ~has_attr
2274-
Nonrecursive bd body
2271+
fmt_let_bindings c ~parens ~fmt_atrs ~fmt_expr ~has_attr Nonrecursive
2272+
bd body
22752273
| Pexp_letexception (ext_cstr, exp) ->
22762274
let pre =
22772275
str "let exception" $ fmt_extension_suffix c ext $ fmt "@ "
@@ -2482,7 +2480,7 @@ and fmt_expression c ?(box = true) ?pro ?epi ?eol ?parens ?(indent_wrap = 0)
24822480
[ { pstr_desc=
24832481
Pstr_eval
24842482
( ( {pexp_desc= Pexp_sequence _; pexp_attributes= []; _} as
2485-
e1 )
2483+
e1 )
24862484
, _ )
24872485
; pstr_loc= _ } ] )
24882486
when Source.extension_using_sugar ~name:ext ~payload:e1.pexp_loc
@@ -2568,7 +2566,7 @@ and fmt_expression c ?(box = true) ?pro ?epi ?eol ?parens ?(indent_wrap = 0)
25682566
[ ( { pstr_desc=
25692567
Pstr_eval
25702568
( ( {pexp_desc= Pexp_infix _; pexp_attributes= []; _} as
2571-
e1 )
2569+
e1 )
25722570
, _ )
25732571
; pstr_loc= _ } as str ) ] )
25742572
when List.is_empty pexp_attributes
@@ -2885,8 +2883,8 @@ and fmt_class_expr c ({ast= exp; ctx= ctx0} as xexp) =
28852883
in
28862884
let fmt_expr = fmt_class_expr c (sub_cl ~ctx body) in
28872885
let has_attr = not (List.is_empty pcl_attributes) in
2888-
fmt_let c ~rec_flag:lbs.pvbs_rec ~bindings ~parens ~has_attr
2889-
~fmt_atrs ~fmt_expr ~body_loc:body.pcl_loc ~indent_after_in
2886+
fmt_let c ~rec_flag:lbs.pvbs_rec ~bindings ~parens ~has_attr ~fmt_atrs
2887+
~fmt_expr ~body_loc:body.pcl_loc ~indent_after_in
28902888
| Pcl_constraint (e, t) ->
28912889
hvbox 2
28922890
(wrap_fits_breaks ~space:false c.conf "(" ")"
@@ -3177,8 +3175,7 @@ and fmt_class_params c ctx params =
31773175
(hvbox 0
31783176
(wrap_fits_breaks c.conf "[" "]" (list_fl params fmt_param) $ fmt "@ ") )
31793177

3180-
and fmt_type_declaration c ?(pre = "") ?name ?(eq = "=") {ast= decl; _}
3181-
=
3178+
and fmt_type_declaration c ?(pre = "") ?name ?(eq = "=") {ast= decl; _} =
31823179
protect c (Td decl)
31833180
@@
31843181
let { ptype_name= {txt; loc}
@@ -4320,12 +4317,13 @@ and fmt_let c ~rec_flag ~bindings ~parens ~fmt_atrs ~fmt_expr ~body_loc
43204317
(vbox 0
43214318
( hvbox 0 (list_fl bindings fmt_binding)
43224319
$ ( if blank_line_after_in then fmt "\n@,"
4323-
else break 1000 indent_after_in )
4320+
else break 1000 indent_after_in )
43244321
$ hvbox 0 fmt_expr ) )
43254322
$ fmt_atrs
43264323

43274324
and fmt_value_binding c ~rec_flag ?in_ ?epi
4328-
{lb_op; lb_pat; lb_args; lb_typ; lb_exp; lb_attrs; lb_loc; lb_pun} :Fmt.t =
4325+
{lb_op; lb_pat; lb_args; lb_typ; lb_exp; lb_attrs; lb_loc; lb_pun} :
4326+
Fmt.t =
43294327
update_config_maybe_disabled_attrs c lb_loc lb_attrs
43304328
@@ fun c ->
43314329
let lb_pun =

0 commit comments

Comments
 (0)