Skip to content

Ensure all precedence rules are covered. #577

Open
@ehuss

Description

@ehuss
Contributor

I think there are various bits of precedence rules that are not covered in the reference. expressions.md covers most of them, and patterns.md has one precedence rule noted.

I'm not sure what is missing, some that I can think of:

Attribute precedence. #[attr] x = 1; the attribute (I think) goes to the place expression, not the statement. RFC 16 says "Attributes bind tighter than any operator".

I think the way let _ = ||{}(); fails to parse isn't clear to me. The precedence rules just say "closures", but doesn't specify what that encompasses. See rust-lang/rust#55851.

impl precedence in types. This is briefly mentioned in rust-lang/rust#34511. I think there are other various precedence rules in type expressions.

I feel like there are various other precedence rules that are missing, but I can't think of any others right now. Perhaps at some point the gll grammar could inform all the rules?

Activity

ehuss

ehuss commented on Dec 31, 2024

@ehuss
ContributorAuthor

Range precedence can be unusual. See rust-lang/rust#105701 and rust-lang/rust#134900.

dtolnay

dtolnay commented on Dec 31, 2024

@dtolnay
Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-grammarArea: Syntax and parsing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ehuss@dtolnay

        Issue actions

          Ensure all precedence rules are covered. · Issue #577 · rust-lang/reference