Skip to content

Commit c97ec14

Browse files
Replace Misc.try_finally with Fun.protect
Since OCaml 4.08 comes with this in the standard library this is a much superior functionality that does not depend on `compiler-libs`. Thanks @emillon for pointing this out.
1 parent 35f6246 commit c97ec14

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/top/mdx_top.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ let redirect ~f =
3838
read_up_to := pos;
3939
Buffer.add_channel buf ic len
4040
in
41-
Misc.try_finally
41+
Fun.protect
4242
(fun () -> f ~capture)
43-
~always:(fun () ->
43+
~finally:(fun () ->
4444
close_in_noerr ic;
4545
Unix.close fd_out;
4646
Unix.dup2 stdout_backup Unix.stdout;
@@ -366,7 +366,7 @@ let protect_vars =
366366
fun vars ~f ->
367367
let backup = List.map (fun (V (r, _)) -> V (r, !r)) vars in
368368
set_vars vars;
369-
Misc.try_finally f ~always:(fun () -> set_vars backup)
369+
Fun.protect f ~finally:(fun () -> set_vars backup)
370370

371371
let capture_compiler_stuff ppf ~f =
372372
protect_vars [ V (Location.formatter_for_warnings, ppf) ] ~f

0 commit comments

Comments
 (0)