Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Star Edition filter #6742

Merged
merged 1 commit into from
Nov 26, 2024
Merged

Use Star Edition filter #6742

merged 1 commit into from
Nov 26, 2024

Conversation

Tomer-StarkWare
Copy link
Collaborator

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
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.

Reviewed 2 of 3 files at r1.
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @gilbens-starkware and @Tomer-StarkWare)


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

                format!(
                    "Global `use` item is not supported in {} edition.",
                    edition.prelude_submodule_name()

Suggestion:

                format!("Global `use` item is not supported in `{:edition?}` edition.")

crates/cairo-lang-semantic/src/items/module.rs line 132 at r1 (raw file):

                    SemanticDiagnosticKind::GlobalUsesNotSupportedInEdition(edition),
                );
            }

move the diagnostic to glob-use item.

Code quote:

    let edition = db
        .crate_config(module_id.owning_crate(db.upcast()))
        .map(|cfg| cfg.settings.edition)
        .unwrap_or_default();
    let allow_global_uses = !edition.ignore_visibility();
    let global_uses = db
        .module_global_uses(module_id)?
        .iter()
        .map(|(global_use_id, use_path_star)| {
            let item = ast::UsePath::Star(use_path_star.clone()).get_item(syntax_db);
            let visibility = item.visibility(syntax_db);
            if !allow_global_uses {
                diagnostics.report(
                    use_path_star,
                    SemanticDiagnosticKind::GlobalUsesNotSupportedInEdition(edition),
                );
            }

Copy link
Collaborator Author

@Tomer-StarkWare Tomer-StarkWare left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-semantic/src/items/module.rs line 132 at r1 (raw file):

Previously, orizi wrote…

move the diagnostic to glob-use item.

Done.


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

                format!(
                    "Global `use` item is not supported in {} edition.",
                    edition.prelude_submodule_name()

Done.

Copy link
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.

Reviewed 4 of 4 files at r2.
Reviewable status: 3 of 4 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @Tomer-StarkWare)


crates/cairo-lang-semantic/src/items/us.rs line 191 at r2 (raw file):

        ));
        return Ok(UseGlobalData { diagnostics: diagnostics.build(), imported_module });
    }

Suggestion:

    let star_ast = db.module_global_use_by_id(global_use_id)?.to_maybe()?;
    let mut resolver = Resolver::new(db, module_file_id, inference_id);
    let edition = resolver.settings.edition;
    if edition.ignore_visibility() {
        let imported_module = Err(diagnostics.report(
            &star_ast,
            SemanticDiagnosticKind::GlobalUsesNotSupportedInEdition(edition),
        ));
        return Ok(UseGlobalData { diagnostics: diagnostics.build(), imported_module });
    }

Copy link
Collaborator Author

@Tomer-StarkWare Tomer-StarkWare left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 of 4 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-semantic/src/items/us.rs line 191 at r2 (raw file):

        ));
        return Ok(UseGlobalData { diagnostics: diagnostics.build(), imported_module });
    }

Done.

Copy link
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.

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @Tomer-StarkWare)


crates/cairo-lang-semantic/src/items/us.rs line 188 at r4 (raw file):

            Err(diagnostics.report(&star_ast, GlobalUsesNotSupportedInEdition(edition)));
        return Ok(UseGlobalData { diagnostics: diagnostics.build(), imported_module });
    }

don't break everything in that case - just add to diagnostics.

Suggestion:

    if edition.ignore_visibility() {
        // We block support for global use where visibility is ignored.
        diagnostics.report(&star_ast, GlobalUsesNotSupportedInEdition(edition));
    }

Copy link
Collaborator Author

@Tomer-StarkWare Tomer-StarkWare left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-semantic/src/items/us.rs line 188 at r4 (raw file):

Previously, orizi wrote…

don't break everything in that case - just add to diagnostics.

Done.

Copy link
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:

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @gilbens-starkware)

@Tomer-StarkWare Tomer-StarkWare added this pull request to the merge queue Nov 26, 2024
Merged via the queue into main with commit 0759c7a Nov 26, 2024
48 checks passed
@orizi orizi deleted the tomerc/use-star-edition branch November 28, 2024 13:18
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