Skip to content

Fix lint diagnostics for write! inline macro #7827

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wawel37
Copy link
Contributor

@wawel37 wawel37 commented Jun 10, 2025

The (()) is not necessary here as the type is inferred. This change is applied to the cairo-lint standards of the code. For more context see https://github.com/software-mansion/cairo-lint/blob/84709c709d339740c6781b74a09e88ddd10ded38/src/lints/redundant_brackets_in_enum_call.rs#L47

@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.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion


crates/cairo-lang-semantic/src/inline_macros/write.rs line 392 at r1 (raw file):

        self.flush_pending_chars(builder, &mut pending_chars, ident_count);
        self.add_indentation(builder, ident_count);
        builder.add_str("core::result::Result::<(), core::fmt::Error>::Ok\n");

only explicit unit types should be done that way.
so i don't think this should be prefered (Result::Ok is incidentally a unit type, but not in the enum itself)

Copy link
Contributor Author

@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.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @orizi)


crates/cairo-lang-semantic/src/inline_macros/write.rs line 392 at r1 (raw file):

Previously, orizi wrote…

only explicit unit types should be done that way.
so i don't think this should be prefered (Result::Ok is incidentally a unit type, but not in the enum itself)

Are you sure about that? If it's because of the fact, that the generic types can be defined somewhere else, it's also applies to the enum being defined somewhere else. So in the end, user have to go to definition and look it up, whether it's from the explicit type or the generic one.

@wawel37 wawel37 requested a review from orizi June 10, 2025 15:08
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.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @wawel37)


crates/cairo-lang-semantic/src/inline_macros/write.rs line 392 at r1 (raw file):

Previously, wawel37 (Mateusz Kowalski) wrote…

Are you sure about that? If it's because of the fact, that the generic types can be defined somewhere else, it's also applies to the enum being defined somewhere else. So in the end, user have to go to definition and look it up, whether it's from the explicit type or the generic one.

WDYM the user? this should be our decision - Ok by itself seems weird to me - as in the replacement of the generic Result the definition would have been with Ok: () and not the shorthand.

in general i would expect the shorthand in usage to match a shorthand in the definition.

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