@@ -1316,6 +1316,31 @@ module Actions = struct
13161316 match remove_open_action with
13171317 | Some _ -> None
13181318 | None -> Some str_item)
1319+ | Pstr_type (_ , _type_declarations ) -> (
1320+ let remove_unused_type_action =
1321+ actions
1322+ |> List. find_opt
1323+ (fun (action : Cmt_utils.cmt_action ) ->
1324+ match action.action with
1325+ | RemoveUnusedType ->
1326+ action.loc = str_item.pstr_loc
1327+ | _ -> false )
1328+ in
1329+ match remove_unused_type_action with
1330+ | Some _ -> None
1331+ | None -> Some str_item)
1332+ | Pstr_module {pmb_loc} ->
1333+ let remove_unused_module_action_locs =
1334+ List. filter_map
1335+ (fun (action : Cmt_utils.cmt_action ) ->
1336+ match action.action with
1337+ | RemoveUnusedModule -> Some action.loc
1338+ | _ -> None )
1339+ actions
1340+ in
1341+ if List. mem pmb_loc remove_unused_module_action_locs then
1342+ None
1343+ else Some str_item
13191344 | _ -> Some str_item)
13201345 in
13211346 let items = Ast_mapper. default_mapper.structure mapper items in
@@ -1606,7 +1631,9 @@ module Actions = struct
16061631 | PrefixVariableWithUnderscore ->
16071632 List. mem " PrefixVariableWithUnderscore" filter
16081633 | RemoveUnusedVariable ->
1609- List. mem " RemoveUnusedVariable" filter)
1634+ List. mem " RemoveUnusedVariable" filter
1635+ | RemoveUnusedType -> List. mem " RemoveUnusedType" filter
1636+ | RemoveUnusedModule -> List. mem " RemoveUnusedModule" filter)
16101637 in
16111638 match applyActionsToFile path possible_actions with
16121639 | Ok applied ->
0 commit comments