Sitelet https://github.com/starkware-libs/cairo/pull/10217
Skip to content

fix(semantic): apply feature/visibility gating to glob re-exports of generic items - #10217

Merged
orizi merged 1 commit into
mainfrom
orizi/07-20-fix_semantic_apply_feature_visibility_gating_to_glob_re-exports_of_generic_items
Jul 20, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/07-20-fix_semantic_apply_feature_visibility_gating_to_glob_re-exports_of_generic_items

Conversation

@orizi

@orizi orizi commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Consolidates the three separate call sites that convert an imported module item into a ResolvedGenericItem into a single method, resolve_module_item_as_generic. This method combines the visibility check (validate_module_item_usability), the feature-gate check (validate_feature_constraints), the used-import recording (insert_used_use), and the conversion (ResolvedGenericItem::from_module_item) into one place, ensuring none of these steps can be accidentally omitted.

A new diagnostic test is added covering the case where an unstable item is re-exported through a glob use * — previously, the feature-gate warning was not emitted in that path because the FoundThroughGlobalUse branches were not calling validate_feature_constraints.


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

Why is this change needed?

The FoundThroughGlobalUse resolution branches were calling insert_used_use and ResolvedGenericItem::from_module_item directly, bypassing validate_module_item_usability (which includes the feature-gate check). This meant that accessing an unstable item via a glob re-export (use inner::*; pub use unstable as renamed;) would not produce the expected #[unstable] warning.


What was the behavior or documentation before?

Accessing an unstable item through a glob re-export silently skipped the unstable-feature diagnostic. The visibility and feature checks were only reliably applied on the direct-import code path.


What is the behavior or documentation after?

All paths that resolve an imported item — direct imports and glob use * — go through resolve_module_item_as_generic, which unconditionally applies visibility checks, feature-gate checks, and used-import recording. A new test confirms that the unstable-feature warning is now emitted when an unstable item is re-exported via a glob import.


Related issue or discussion (if any)


Additional context

The refactor is purely mechanical: no logic was changed, only consolidated. The new method is documented with a note that every import-to-generic-item conversion must go through it so these checks are never skipped in the future.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

orizi commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@orizi
orizi force-pushed the orizi/07-20-fix_semantic_apply_feature_visibility_gating_to_glob_re-exports_of_generic_items branch from a3f9afd to 5b8d3d4 Compare July 20, 2026 05:07
@orizi
orizi marked this pull request as ready for review July 20, 2026 05:07
@cursor

cursor Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches central path resolution for all imported items; behavior change is intentional for glob re-exports but could surface new warnings in edge cases.

Overview
Imported module items are now turned into generic resolution results through a single resolve_module_item_as_generic helper instead of scattered validate_module_item_usability + conversion calls. That path always runs visibility, #[unstable] / feature-gate checks, used-import recording, and ResolvedGenericItem::from_module_item.

Glob use * resolution (FoundThroughGlobalUse) previously skipped feature validation when re-exporting; it now uses the same helper with the containing module, so pub use unstable as renamed after use inner::* emits E2065 like direct imports. Diagnostic tests cover one-hop and chained glob re-exports.

Reviewed by Cursor Bugbot for commit aa086c9. Bugbot is set up for automated code reviews on this repo. Configure here.

@eytan-starkware eytan-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@eytan-starkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on orizi and TomerStarkware).


crates/cairo-lang-semantic/src/resolve/mod.rs line 2036 at r1 (raw file):

                    ResolvedBase::FoundThroughGlobalUse {
                        item_info: inner_module_item,
                        containing_module,

What happens when it is deeply nested? It still brings the correct module?

…generic items

`first_generic`'s `FoundThroughGlobalUse` arms resolved an item pulled in via
`use *` without running the usability checks the concrete path performs. So
re-exporting an `#[unstable]` (or otherwise gated) item through a glob
(`use inner::*; use item as alias;`) skipped the E2065 warning that a direct
`use inner::item as alias;` emits.

Extract the shared "validate usability, record the use, resolve to a generic
item" step into `resolve_module_item_as_generic` (subsuming the former
`validate_module_item_usability`) and route every import→generic resolution
through it — direct, glob, and `next_generic` — so the checks can't be skipped
at a new site.
@orizi
orizi force-pushed the orizi/07-20-fix_semantic_apply_feature_visibility_gating_to_glob_re-exports_of_generic_items branch from 5b8d3d4 to aa086c9 Compare July 20, 2026 07:33

@orizi orizi left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@orizi made 1 comment.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on eytan-starkware and TomerStarkware).


crates/cairo-lang-semantic/src/resolve/mod.rs line 2036 at r1 (raw file):

Previously, eytan-starkware wrote…

What happens when it is deeply nested? It still brings the correct module?

Done.

@eytan-starkware eytan-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:lgtm:

@eytan-starkware reviewed 1 file and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).

@orizi
orizi added this pull request to the merge queue Jul 20, 2026
Merged via the queue into main with commit 60d6600 Jul 20, 2026
55 checks passed
@orizi
orizi deleted the orizi/07-20-fix_semantic_apply_feature_visibility_gating_to_glob_re-exports_of_generic_items branch July 20, 2026 10:58
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.

3 participants