You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to suggest another attempt to the one of @pitaj (which I guess could be summarized by "stop recursion if the last 2 elements of the current list are of the same kind, e.g. both arrays, both tuples, etc").
This overflow_delimited_expr feature has a notion of recursion through the nesting of list-like syntax. I suggest looking at the height of this nesting to decide when to stop recursion. I define the height of a list as one plus the maximum height of its elements (zero if there are none). Recursion through the last element should stop if there is another element (in that list) with a greater or equal height as that last element. Equivalently, recursion should continue if the last element has the greatest (unmatched) height in the list. Here are some formatted examples with explanations:
// `write()` elements: we recurse because the last one has a height of 2// which is greater than all other elements (`i * 3` has a height of 1).// `Bar` elements: we stop recursion because all elements have a height of 1,// so the last one does not have a height greater than all other elements.
vbuf.write(i *3,Bar(Foo{x:1,y:2,z:3},Foo{x:1,y:2,z:3},Foo{x:1,y:2,z:3},));// Same reasoning here. The last element of `Bar` has a height matched by the first element.
vbuf.write(i *3,Bar(Foo{x:1,y:2,z:3},42,Foo{x:1,y:2,z:3},));// Now, the last element of `Bar` has the greatest unmatched height, so we recurse.// `Foo` elements: They all have the same height, so we don't recurse (anyway, 3 is not a list).
vbuf.write(i *3,Bar(13,42,Foo{x:1,y:2,z:3,}));
cc @rust-lang/style @rust-lang/rustfmt
The text was updated successfully, but these errors were encountered:
traviscross
changed the title
Heuristic for overflow-delimited_expr
Heuristic for overflow_delimited_exprDec 31, 2024
Refiling the comment...
overflow_delimited_expr
rust#123751 (comment)...so it's not lost.
@ia0 writes:
cc @rust-lang/style @rust-lang/rustfmt
The text was updated successfully, but these errors were encountered: