@@ -73,6 +73,8 @@ type 'a loc = {
7373let mkloc txt loc = { txt ; loc }
7474let mknoloc txt = mkloc txt none
7575
76+ let map f x = { x with txt = f x.txt }
77+
7678(* *****************************************************************************)
7779(* Input info *)
7880
@@ -749,22 +751,15 @@ let batch_mode_printer : report_printer =
749751 | Misc.Error_style. Short ->
750752 ()
751753 in
752- Format. fprintf ppf " @[<v> %a:@ %a@] " print_loc loc
754+ Format. fprintf ppf " %a:@ %a" print_loc loc
753755 (Fmt. compat highlight) loc
754756 in
755- let pp_txt ppf txt = Format. fprintf ppf " @[%a@] " Fmt.Doc. format txt in
757+ let pp_txt ppf txt = Format. fprintf ppf " %a " Fmt.Doc. format txt in
756758 let pp_footnote ppf f =
757759 Option. iter (Format. fprintf ppf " @,%a" pp_txt) f
758760 in
759- let pp self ppf report =
760- setup_tags () ;
761- separate_new_message ppf;
762- (* Make sure we keep [num_loc_lines] updated.
763- The tabulation box is here to give submessage the option
764- to be aligned with the main message box
765- *)
766- print_updating_num_loc_lines ppf (fun ppf () ->
767- Format. fprintf ppf " @[<v>%a%a%a: %a%a%a%a%a@]@."
761+ let error_format self ppf report =
762+ Format. fprintf ppf " @[<v>%a%a%a: %a@[%a@]%a%a%a@]@."
768763 Format. pp_open_tbox ()
769764 (self.pp_main_loc self report) report.main.loc
770765 (self.pp_report_kind self report) report.kind
@@ -773,7 +768,30 @@ let batch_mode_printer : report_printer =
773768 (self.pp_submsgs self report) report.sub
774769 pp_footnote report.footnote
775770 Format. pp_close_tbox ()
776- ) ()
771+ in
772+ let warning_format self ppf report =
773+ Format. fprintf ppf " @[<v>%a@[<b 2>%a: %a@]%a%a@]@."
774+ (self.pp_main_loc self report) report.main.loc
775+ (self.pp_report_kind self report) report.kind
776+ (self.pp_main_txt self report) report.main.txt
777+ (self.pp_submsgs self report) report.sub
778+ pp_footnote report.footnote
779+ in
780+ let pp self ppf report =
781+ setup_tags () ;
782+ separate_new_message ppf;
783+ let printer ppf () = match report.kind with
784+ | Report_warning _
785+ | Report_warning_as_error _
786+ | Report_alert _ | Report_alert_as_error _ ->
787+ warning_format self ppf report
788+ | Report_error -> error_format self ppf report
789+ in
790+ (* Make sure we keep [num_loc_lines] updated.
791+ The tabulation box is here to give submessage the option
792+ to be aligned with the main message box
793+ *)
794+ print_updating_num_loc_lines ppf printer ()
777795 in
778796 let pp_report_kind _self _ ppf = function
779797 | Report_error -> Format. fprintf ppf " @{<error>Error@}"
@@ -796,9 +814,12 @@ let batch_mode_printer : report_printer =
796814 ) msgs
797815 in
798816 let pp_submsg self report ppf { loc; txt } =
799- Format. fprintf ppf " @[%a %a@]"
800- (self.pp_submsg_loc self report) loc
801- (self.pp_submsg_txt self report) txt
817+ if loc.loc_ghost then
818+ Format. fprintf ppf " @[%a@]" (self.pp_submsg_txt self report) txt
819+ else
820+ Format. fprintf ppf " %a @[%a@]"
821+ (self.pp_submsg_loc self report) loc
822+ (self.pp_submsg_txt self report) txt
802823 in
803824 let pp_submsg_loc self report ppf loc =
804825 if not loc.loc_ghost then
@@ -864,6 +885,18 @@ let mkerror loc sub footnote txt =
864885let errorf ?(loc = none) ?(sub = [] ) ?(footnote =Fun. const None ) =
865886 Fmt. kdoc_printf (mkerror loc sub footnote)
866887
888+ (* Removed because it's unused and pulls more dependencies.
889+ let aligned_error_hint
890+ ?(loc = none) ?(sub = []) ?(footnote=Fun.const None) fmt =
891+ Fmt.kdoc_printf (fun main hint ->
892+ match hint with
893+ | None -> mkerror loc sub footnote main
894+ | Some hint ->
895+ let main, hint = Misc.align_error_hint ~main ~hint in
896+ mkerror loc (mknoloc hint :: sub) footnote main
897+ ) fmt
898+ *)
899+
867900let error ?(loc = none) ?(sub = [] ) ?(footnote =Fun. const None ) msg_str =
868901 mkerror loc sub footnote Fmt.Doc. (string msg_str empty)
869902
@@ -881,11 +914,10 @@ let default_warning_alert_reporter report mk (loc: t) w : report option =
881914 match report w with
882915 | `Inactive -> None
883916 | `Active { Warnings. id; message; is_error; sub_locs } ->
884- let msg_of_str str = Format_doc.Doc. (empty |> string str) in
885917 let kind = mk is_error id in
886- let main = { loc; txt = msg_of_str message } in
918+ let main = { loc; txt = message } in
887919 let sub = List. map (fun (loc , sub_message ) ->
888- { loc; txt = msg_of_str sub_message }
920+ { loc; txt = sub_message }
889921 ) sub_locs in
890922 Some { kind; main; sub; footnote= None }
891923
@@ -953,7 +985,7 @@ let auto_include_alert lib =
953985 {Warnings. kind= " ocaml_deprecated_auto_include" ; use= none; def= none;
954986 message = Format. asprintf " @[@\n %a@]" Format. pp_print_text message}
955987 in
956- prerr_alert none alert
988+ prerr_alert (in_file ! input_name) alert
957989
958990let deprecated_script_alert program =
959991 let message = Fmt. asprintf " \
0 commit comments