[m-rev.] for review: make --warn-unused-imports more effective

Julien Fischer jfischer at opturion.com
Thu Nov 27 16:59:52 AEDT 2025


On Thu, 27 Nov 2025 at 00:13, Zoltan Somogyi <zoltan.somogyi at runbox.com>
wrote:

 > Make --warn-unused-imports more effective.
>
> Specifically, make it warn about interface imports that are not used
> in the initial HLDS, even if they *are* used after the expansion of
> type-, inst- and mode-equivalences.
>
> compiler/hlds_module.m:
>     Add a slot to the HLDS to store the set of modules that are
>     imported in the interface but are unused there when the HLDS
>     is first constructed.
>
> compiler/module_qual.qualify_items.m:
>     Compute this set, and return it to mercury_compile_make_hlds.m.
>
>     Make the code module qualifying aug_compilation_units warn about
>     unused interface imports only if unused_imports.m won't do the same
later.
>
> compiler/mercury_compile_make_hlds.m:
>     Pass the set to make_hlds_passes.m.
>
> compiler/make_hlds_passes.m:
>     Store the set in the initial HLDS.
>
> compiler/prog_data_used_modules.m:
>     Replace set_ordlists with set_tree234s.
>
> compiler/unused_imports.m:
>     Consider an interface-imported module unused in the interface
>     if module_qual.qualify_items.m considered it unused, even if
>     changes made by equiv_type.m has added uses of it later.
>
> compiler/handle_options.m:
>     Stop making --warn-unused-imports imply
--no-warn-unused-interface-imports,
>     since new logic in module_qual.qualify_items.m makes this unnecessary.
>
> compiler/make_module_file_names.m:
> compiler/type_inst_mode_map.m:
> compiler/write_deps_file.m:
>     Move imports from the interface section to the implementation section,
>     in response to the new, more thorough warnings.

That's fine.

Julien.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20251127/8ec51638/attachment.html>


More information about the reviews mailing list