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 OwnershipGraph for Borrowing Rules in Rust #10

Merged
merged 7 commits into from
Jun 7, 2023

Conversation

notJoon
Copy link
Owner

@notJoon notJoon commented Jun 6, 2023

In this PR, we have implemented the OwnershipGraph data structure to enforce borrowing rules in this language.

Changes made:

  1. Implementation of OwnershipGraph: We've introduced a new data structure, OwnershipGraph, which stores variables and their borrowed values in a collections::BTreeMap to maintain a consistent output order. This helps us to understand and verify the borrowing rules for each variable in the language.

  2. Introduction of build_ownership_graph function: This function takes a vector of Statements as an argument and generates an OwnershipGraph. This graph will be used to enforce borrowing rules and prevent multiple mutable references or simultaneous mutable and immutable references.

  3. Writing Test Cases: We have added comprehensive test cases for the build_ownership_graph function. These tests ensure that our implementation correctly handles variable declarations, borrowing, and the restrictions of Rust's ownership rules. Also, modefied other files tests too.

TODO

  • should implement the borrow checker's functionality for nested scope.

@notJoon notJoon self-assigned this Jun 6, 2023
@notJoon notJoon added the enhancement New feature or request label Jun 6, 2023
@notJoon notJoon changed the title add test for validate nested sscope case Implement OwnershipGraph for Borrowing Rules in Rust Jun 7, 2023
@notJoon notJoon marked this pull request as ready for review June 7, 2023 11:06
@notJoon notJoon merged commit c82d857 into main Jun 7, 2023
1 check failed
@notJoon notJoon deleted the support_nested_scope_in_borrow_checker branch June 7, 2023 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant