Repository navigation
v.iter() over elements that own something yields views; every iterator adapter is a for iterable (#2145, #2152) - #2150
Merged
Conversation
Contributor
Author
|
Battery GREEN on the stack top cef3897, driven by the pinned seed (gate 759 s, uat 30 s, battery-checks 1361 s); green recorded with :last-green. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
names.iter()on aVec[str](any element that is not Copy) resolves to the view iterator (VecIterRef[T], items&T), as §13.1 says a vector's iterator yields. The by-valueVecIter[T]handed each element out as a byte copy with a second owner; every.iter() |> filter/map/collect, and.next(), double-freed. Sema records the resolved method (method_call_fields), so MirLower reads it and not the spelling.A Copy element keeps the by-value iterator for now: switching it changes what
collectandsumsee (xs.iter_ref() |> sum()is invalid LLVM today), which is D22's contextual Copy reaching pipelines and its own change.Test:
test/debug_alloc/da_2145_vec_iter_views_owned_elements.w(filter, map, any, take, collect, clone-collect, next, for, an enum element), leak count 0, no double free.Gaps seen on the way, same on main:
for (i, x) in v.iter() |> enumerate()is refused;|> position(it == "a")andkept[0] == "a"on aVec[&str]are "comparison operands must have compatible types".