rust/compiler/rustc_hir/src
Guillaume Gomez 7dd0c8314d
Rollup merge of #133603 - dtolnay:precedence, r=lcnr
Eliminate magic numbers from expression precedence

Context: see https://github.com/rust-lang/rust/pull/133140.

This PR continues on backporting Syn's expression precedence design into rustc. Rustc's design used mysterious integer quantities represented variously as `i8` or `usize` (e.g. `PREC_CLOSURE = -40i8`), a special significance around `0` that is never named, and an extra `PREC_FORCE_PAREN` precedence level that does not correspond to any expression. Syn's design uses a C-like enum with variants that clearly correspond to specific sets of expression kinds.

This PR is a refactoring that has no intended behavior change on its own, but it unblocks other precedence work that rustc's precedence design was poorly suited to accommodate.

- Asymmetrical precedence, so that a pretty-printer can tell `(return 1) + 1` needs parens but `1 + return 1` does not.

- Squashing the `Closure` and `Jump` cases into a single precedence level.

- Numerous remaining false positives and false negatives in rustc pretty-printer's parenthesization of macro metavariables, for example in `$e < rhs` where $e is `lhs as Thing<T>`.

FYI `@fmease` &mdash; you don't need to review if rustbot picks someone else, but you mentioned being interested in the followup PRs.
2024-12-02 17:36:03 +01:00
..
arena.rs Remove unused arena kinds in rustc_hir and rustc_middle. 2023-11-20 15:05:26 +11:00
def_path_hash_map.rs Do not store stable crate id in on-disk hash map. 2023-12-24 17:22:48 +00:00
def.rs update comment 2024-11-28 12:22:02 +00:00
definitions.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
diagnostic_items.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
hir_id.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
hir.rs Rollup merge of #133603 - dtolnay:precedence, r=lcnr 2024-12-02 17:36:03 +01:00
intravisit.rs Remove hir::ArrayLen, introduce ConstArgKind::Infer 2024-11-30 21:00:31 +01:00
lang_items.rs Rollup merge of #132144 - adetaylor:receiver-trait-itself, r=wesleywiser 2024-11-11 21:58:29 +01:00
lib.rs dont regenerate new links for rexports 2024-09-20 21:49:37 +08:00
pat_util.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
stable_hash_impls.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
target.rs rm ItemKind::OpaqueTy 2024-10-04 23:28:22 +00:00
tests.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
weak_lang_items.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00