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

Implement partial equivalence and extend forc migrate tool #6900

Merged
merged 7 commits into from
Feb 11, 2025

Conversation

ironcev
Copy link
Member

@ironcev ironcev commented Feb 6, 2025

Description

This PR:

  • implements partial equivalence in the core::ops, as explained in detail in Partial equivalence #6883. The implementation is opt-in and behind the partial_eq experimental feature flag.
  • implements forc migrate migration steps for automatic migration to partial_eq feature.
  • extends the infrastructure for writing forc migrate migrations.
  • preserves Annotations on LexedModules in the LexedProgram. (Those were before stripped off and not available in the compiled Programs. This resulted in loss off //! doc-comments that are represented as doc-comment annotations.)

Extensions in the forc migrate infrastructure include:

  • possibility to postpone migration steps. This allows writing multi-step migrations where the first step is usually early adopting an experimental feature by using cfg attributes in code. This possibility is crucial for migrating our own codebase where we want to early-adopt and test and stabilize experimental features.
  • possibility to match elements on both mutable and immutable parsed trees. The initial assumption that immutable matching on typed trees will always be sufficient does not hold. Experimental cfg attributes can remove parts of typed trees that might be needed in analysis.
  • LexedLocate(As)Annotated for easier location and retrieval of Annotated elements.
  • additional implementations of existing traits.
  • additional Modifiers for modifying existing elements in the lexed tree.
  • New struct for convenient creation of often needed lexed tree elements. Note that we do not expect migrations to generate large new parts of lexed trees, but mostly to modify or copy and modify existing ones.

Almost all of the changes in the Sway files are done automatically by the migration steps. The only manual change was in the core library (std library is also automatically migrated) and in slight extension of two of the tests.

Note that some of the tests have Eq traits in trait constraints. As explained in the #6883, it is not necessary to change those to PartialEq. We might consider changing some of them, for testing purposes, and such a change is done on one of the tests that was testing the behavior of the Eq trait. But for the majority of the tests, there is no strict need for switching from Eq to PartialEq.

Rolling PartialEq out in the tests provoked three existing issues that will be fixed in separate PRs: #6897, #6898, #6899.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@ironcev ironcev self-assigned this Feb 6, 2025
@ironcev ironcev added lib: std Standard library lib: core Core library forc-migrate Everything to do with the forc-migrate tool. labels Feb 6, 2025
Copy link

codspeed-hq bot commented Feb 6, 2025

CodSpeed Performance Report

Merging #6900 will not alter performance

Comparing ironcev/partial-equivalence (307375e) with master (70c84ca)

Summary

✅ 22 untouched benchmarks

@ironcev ironcev marked this pull request as ready for review February 6, 2025 22:40
@ironcev ironcev requested review from a team as code owners February 6, 2025 22:40
@JoshuaBatty JoshuaBatty requested review from a team February 9, 2025 00:31
@ironcev ironcev enabled auto-merge (squash) February 11, 2025 11:01
@ironcev ironcev merged commit bb7c99b into master Feb 11, 2025
41 checks passed
@ironcev ironcev deleted the ironcev/partial-equivalence branch February 11, 2025 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forc-migrate Everything to do with the forc-migrate tool. lib: core Core library lib: std Standard library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants