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

internal: Standardize how we take iterator parameters in SyntaxFactory #18718

Merged

Conversation

Giga-Bowser
Copy link
Contributor

In my PR for migrating wrap/unwrap return type, I remarked about two different ways of taking many elements as a parameter, and it seemed like a matter of style at the time, but it turns out it actually matters a lot! Because if you provide a parameter taking IntoIterator + Clone using something a .map(), in which you construct additional elements using the same SyntaxFactory you're providing the parameter to, then by the lazy nature of iterators, there will be a looming mutable borrow on the RefCell for mappings, and the code will panic. So we need to be collecting the iterator to force any internal references be dropped.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 18, 2024
@Giga-Bowser Giga-Bowser force-pushed the fix-syntaxfactory-intoiterator branch from 81c7cda to 025e804 Compare December 18, 2024 16:20
@Giga-Bowser Giga-Bowser force-pushed the fix-syntaxfactory-intoiterator branch from 025e804 to 2b6e7ce Compare December 20, 2024 17:06
@Veykril Veykril added this pull request to the merge queue Dec 24, 2024
Merged via the queue into rust-lang:master with commit 633a10c Dec 24, 2024
9 checks passed
@Giga-Bowser Giga-Bowser deleted the fix-syntaxfactory-intoiterator branch January 10, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants