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

tree: remove unsafe with ouroboros for self-referential iterators #2547

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

arxanas
Copy link
Contributor

@arxanas arxanas commented Nov 8, 2023

Closes #2127. This is fairly clumsy right now using with_mut, so I'm open to alternative ways of writing those cases. Basically, we use it to destructure the struct in question and get immutable/mutable references to all the fields at once.

Feel free to commandeer this PR if you are waiting impatiently, as I'm not sure when I'll get time to respond to feedback.

After this, these are the remaining unsafe sites:

https://github.com/martinvonz/jj/blob/084b99e1e2c42c40f2d52038cdc97687b76fed89/cli/src/cleanup_guard.rs#L60

https://github.com/martinvonz/jj/blob/084b99e1e2c42c40f2d52038cdc97687b76fed89/lib/testutils/src/lib.rs#L56

https://github.com/martinvonz/jj/blob/084b99e1e2c42c40f2d52038cdc97687b76fed89/lib/src/repo.rs#L275

The first two look like unavoidable instances of unsafe to me.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@yuja yuja left a comment

Choose a reason for hiding this comment

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

#2127 can be closed?

lib/src/merged_tree.rs Outdated Show resolved Hide resolved
@arxanas arxanas enabled auto-merge (rebase) November 10, 2023 05:35
@arxanas arxanas merged commit a60733f into main Nov 10, 2023
15 checks passed
@arxanas arxanas deleted the arxanas/unsafe branch November 10, 2023 05:50
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.

Can we use owning_ref to avoid some unsafe blocks?
3 participants