reference icon indicating copy to clipboard operation
reference copied to clipboard

Ensure all precedence rules are covered.

Open ehuss opened this issue 6 years ago • 2 comments

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 https://github.com/rust-lang/rust/issues/55851.

impl precedence in types. This is briefly mentioned in https://github.com/rust-lang/rust/issues/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?

ehuss avatar Apr 21 '19 17:04 ehuss

Range precedence can be unusual. See https://github.com/rust-lang/rust/pull/105701 and https://github.com/rust-lang/rust/pull/134900.

ehuss avatar Dec 31 '24 13:12 ehuss

This rabbit hole goes deep. See https://x.com/davidtolnay/status/1874146148405174509.

dtolnay avatar Dec 31 '24 23:12 dtolnay