Skip to content

refactor: Made Kind an inherent part of DiagnosticEntry.#9301

Closed
orizi wants to merge 1 commit intoorizi/12-23-added_validation_of_error_code_not_being_duplicatedfrom
orizi/12-23-refactor_made_kind_an_inherent_part_of_diagnosticentry
Closed

refactor: Made Kind an inherent part of DiagnosticEntry.#9301
orizi wants to merge 1 commit intoorizi/12-23-added_validation_of_error_code_not_being_duplicatedfrom
orizi/12-23-refactor_made_kind_an_inherent_part_of_diagnosticentry

Conversation

@orizi
Copy link
Collaborator

@orizi orizi commented Dec 23, 2025

Summary

Refactored the DiagnosticEntry trait to use an associated type Kind for diagnostic kinds instead of the is_same_kind method. This change improves type safety by enforcing that diagnostic kinds are compared with the same type, rather than relying on a custom comparison method.


Why is this change needed?

The current implementation uses an is_same_kind method to compare diagnostic entries, which requires manual implementation for each diagnostic type. This approach is error-prone and less type-safe. By using an associated type for the diagnostic kind, we leverage the type system to ensure that comparisons are done correctly, while also simplifying the code.


What was the behavior or documentation before?

Previously, each diagnostic implementation had to provide an is_same_kind method that manually compared diagnostic kinds. This required boilerplate code in each implementation and could lead to bugs if not implemented correctly.


What is the behavior or documentation after?

Now, diagnostic entries have an associated Kind type that represents the kind of diagnostic. Equality comparison is done directly on these kinds using the standard == operator, which is more type-safe and requires less code. The implementation is also more consistent across different diagnostic types.


Additional context

This change is part of ongoing efforts to improve the type safety and maintainability of the diagnostic system. It removes redundant code while making the comparison of diagnostic kinds more robust.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator Author

orizi commented Dec 23, 2025

Copy link
Collaborator

@TomerStarkware TomerStarkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@TomerStarkware reviewed 6 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @orizi).

@orizi orizi closed this Dec 23, 2025
@orizi orizi deleted the orizi/12-23-refactor_made_kind_an_inherent_part_of_diagnosticentry branch December 23, 2025 12: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