Skip to content

Skip modules without priv uses when computing unused imports diagnostics#9829

Open
integraledelebesgue wants to merge 2 commits intooptimization/diagnostic-materializationfrom
optimization/unused-imports
Open

Skip modules without priv uses when computing unused imports diagnostics#9829
integraledelebesgue wants to merge 2 commits intooptimization/diagnostic-materializationfrom
optimization/unused-imports

Conversation

@integraledelebesgue
Copy link
Copy Markdown
Collaborator

@integraledelebesgue integraledelebesgue commented Apr 9, 2026

Summary

A little optimization for further gain of diagnostic performance in CairoLS


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

@integraledelebesgue
Copy link
Copy Markdown
Collaborator Author

integraledelebesgue commented Apr 9, 2026

@integraledelebesgue integraledelebesgue changed the title Skip the modules without priv uses when computing unused imports diagnostics Skip modules without priv uses when computing unused imports diagnostics Apr 9, 2026
@integraledelebesgue integraledelebesgue marked this pull request as ready for review April 9, 2026 11:06
@integraledelebesgue integraledelebesgue force-pushed the optimization/diagnostic-materialization branch from 37603a6 to 31b692a Compare April 10, 2026 11:12
@integraledelebesgue integraledelebesgue force-pushed the optimization/unused-imports branch from 2e764f4 to 73591db Compare April 10, 2026 11:13
@integraledelebesgue integraledelebesgue force-pushed the optimization/diagnostic-materialization branch from 31b692a to a2586c5 Compare April 10, 2026 13:01
@integraledelebesgue integraledelebesgue force-pushed the optimization/unused-imports branch from 73591db to 1dd5d57 Compare April 10, 2026 13:02
Copy link
Copy Markdown
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi reviewed 1 file and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on integraledelebesgue).


crates/cairo-lang-semantic/src/db.rs line 378 at r1 (raw file):

            ModuleItemId::Use(use_id) => Some(use_id),
            _ => None,
        })

Suggestion:

        .filter_map(|info| try_extract_matches!(info.item_id, ModuleItemId::Use))

crates/cairo-lang-semantic/src/db.rs line 389 at r1 (raw file):

        add_unused_import_diagnostics(db, all_used_uses, use_id, diagnostics);
    }
}

Suggestion:

        })
        .peekable();
    if private_uses.peek().is_none() {
        return;
    }
    let Ok(all_used_uses) = db.module_all_used_uses(module_id) else {
        return;
    };
    for use_id in private_uses {
        add_unused_import_diagnostics(db, all_used_uses, use_id, diagnostics);
    }
}

Copy link
Copy Markdown
Collaborator

@piotmag769 piotmag769 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@piotmag769 reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on integraledelebesgue).

Copy link
Copy Markdown
Collaborator

@Arcticae Arcticae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@Arcticae reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on integraledelebesgue).

Copy link
Copy Markdown
Collaborator

@piotmag769 piotmag769 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piotmag769 reviewed 1 file and all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on integraledelebesgue).

Copy link
Copy Markdown
Contributor

@wawel37 wawel37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wawel37 made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on orizi).


crates/cairo-lang-semantic/src/db.rs line 378 at r1 (raw file):

            ModuleItemId::Use(use_id) => Some(use_id),
            _ => None,
        })

Done


crates/cairo-lang-semantic/src/db.rs line 389 at r1 (raw file):

        add_unused_import_diagnostics(db, all_used_uses, use_id, diagnostics);
    }
}

Done

@wawel37 wawel37 requested a review from orizi April 15, 2026 13:01
Copy link
Copy Markdown
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@orizi made 1 comment and resolved 2 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on integraledelebesgue).

Copy link
Copy Markdown
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi reviewed 1 file and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on integraledelebesgue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants