Skip to content

Rust Reference documents operator associativity incorrectly #34386

Closed
@jameysharp

Description

@jameysharp

In section 7.2.12.8 "Operator precedence", the Rust reference says, "Operators at the same precedence level are evaluated left-to-right." I assume this is intended to mean that the binary operators are all left-associative.

However, the comparison operators (== != < > <= >=) are apparently non-associative, requiring explicit parentheses if you want to apply one to the result of another, as in (2 < 3) == true. (That's a silly example, but I have in the past found utility in expressions like (a < b) != (c < d).)

I think the implemented behavior is both reasonable and a good idea, so this is just a documentation bug, but I'm not really sure how to fix the documentation to be clear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions