Repository navigation
Borrow operator operands - #1610
Merged
Merged
Conversation
check_ops_trait recorded the coerced parameter type as the right-hand operand's own type, so `a == b` read `b` into a view temporary; when `b` had no storage slot, that read moved it. Check the operand against the parameter like a call argument and keep its type. The call boundary forms the view, as it already does for `a.eq(b)`. Lowering no longer strips views from tuple, array, record and cast literals, and scalar operands are no longer given memory to be viewed. The loop-prefix certifier accepts a bound reached through copies of the parameter, the shape `i < count` now shares with `i.lt(count)`.
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.
a == bmoved a non-Copyb, even thoughEq::eqtakes its operand as a view anda.eq(b)borrows it. Operator type checking recorded the coerced parameter type (view T) as the right-hand operand's own type, so lowering readbinto a view temporary, which movedbwhenever it had no storage slot.Operator operands are now checked against the parameter type like call arguments and keep their own type; the call boundary forms the view.
i < countnow has the same shape asi.lt(count), which the certifier previously rejected.semantic_borrowck/aggregate_equalityfixture, which pinned the moves, is replaced by runtime checks infe_test/aggregate_equality.fethat reuse the right-hand operands.Field operands such as
a.x == b.xadditionally rely on #1581.