diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-12-20 10:15:05 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-04-03 10:23:03 +1100 |
| commit | eaaf3ab6210c722f9e757715ba54ad94da4a70b5 (patch) | |
| tree | d09ac20ebe2037d6792c43e29832fde9dea8538a /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 1f4abb4b0cee2d2f8e0216149d7aa488b70ad6c9 (diff) | |
| download | rust-eaaf3ab6210c722f9e757715ba54ad94da4a70b5.tar.gz rust-eaaf3ab6210c722f9e757715ba54ad94da4a70b5.zip | |
Tighten up assignment operator representations.
In the AST, currently we use `BinOpKind` within `ExprKind::AssignOp` and `AssocOp::AssignOp`, even though this allows some nonsensical combinations. E.g. there is no `&&=` operator. Likewise for HIR and THIR. This commit introduces `AssignOpKind` which only includes the ten assignable operators, and uses it in `ExprKind::AssignOp` and `AssocOp::AssignOp`. (And does similar things for `hir::ExprKind` and `thir::ExprKind`.) This avoids the possibility of nonsensical combinations, as seen by the removal of the `bug!` case in `lang_item_for_binop`. The commit is mostly plumbing, including: - Adds an `impl From<AssignOpKind> for BinOpKind` (AST) and `impl From<AssignOp> for BinOp` (MIR/THIR). - `BinOpCategory` can now be created from both `BinOpKind` and `AssignOpKind`. - Replaces the `IsAssign` type with `Op`, which has more information and a few methods. - `suggest_swapping_lhs_and_rhs`: moves the condition to the call site, it's easier that way. - `check_expr_inner`: had to factor out some code into a separate method. I'm on the fence about whether avoiding the nonsensical combinations is worth the extra code.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
