[m-rev.] diff: Delete unused imports.

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed Mar 30 12:41:29 AEDT 2022



On Wed, 30 Mar 2022 11:57:23 +1100, Peter Wang <novalazy at gmail.com> wrote:
> > +                % The add_item_avails predicate in make_hlds_passes.m fills
> > +                % this field with information about all the nonabstract
> > +                % import_module and use_module declarations in the module
> > +                % being compiled, and in the .in0 interface files of its
> > +                % ancestors.
> 
> What do you mean by "nonabstract" import_module and use_module
> declarations?

I meant those whose import status is item_import_int_concrete.
However, after your reading your email, I realized that every import-
and use_module declaration read in from the module and from its
ancestors' .int0 files has this status, so the qualifier is unnecessary. I deleted it.

> > --- a/compiler/unused_imports.m
> > +++ b/compiler/unused_imports.m
> > @@ -173,17 +184,26 @@ get_avail_modules_anywhere_interface([ModuleEntry | ModuleEntries],
> >  maybe_warn_about_avail(TopModuleName,
> >          UnusedAnywhereImports, UnusedInterfaceImports,
> >          ModuleName, AvailEntry, !Specs) :-
> > -    AvailEntry = avail_module_entry(Section, ImportOrUse, Avails),
> > +    AvailEntry = avail_module_entry(_Section, _ImportOrUse, Avails),
> >      list.sort(compare_avails, Avails, SortedAvails),
> >      (
> >          SortedAvails = []
> >      ;
> >          SortedAvails = [HeadAvail | _],
> > -        HeadAvail = avail_module(_, _, HeadContext),
> > +        % NOTE: We *must* get Section and ImportOrUse from one of the elements
> > +        % of Avail, and *not* from AvailEntry. This is because the first two
> 
> Avail -> HeadAvail

No: "one of the elements of Avail" is correct. HeadAvail happens to be
the picked element, but in the presence of duplicate import- or use_module
declarations, any one of them would do.

> That seems fine otherwise.

Thank you. I followed all your other suggestions.

One question I forgot earlier: does this change warrant an entry in NEWS?
I think it is on the borderline.

Zoltan.




More information about the reviews mailing list