about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/Linker.cpp
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-07-05 09:04:41 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-07-09 09:02:50 +1000
commit7f1dfcab679a1c8248b16e34902a578c2f7bf5e2 (patch)
tree80851c2d1732e81d49c66e29e80994c46caaca21 /compiler/rustc_llvm/llvm-wrapper/Linker.cpp
parent27571da5fae9ee5f4eb34582a91ba06ad0a2ab13 (diff)
downloadrust-7f1dfcab679a1c8248b16e34902a578c2f7bf5e2.tar.gz
rust-7f1dfcab679a1c8248b16e34902a578c2f7bf5e2.zip
Avoid transposes in deriving code.
The deriving code has some complex parts involving iterations over
selflike args and also fields within structs and enum variants.

The return types for a few functions demonstrate this:

- `TraitDef::create_{struct_pattern,enum_variant_pattern}` returns a
  `(P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>)>)`
- `TraitDef::create_struct_field_accesses` returns a `Vec<(Span,
  Option<Ident>, P<Expr>)>`.

This results in per-field data stored within per-selflike-arg data, with
lots of repetition within the per-field data elements. This then has to
be "transposed" in two places (`expand_struct_method_body` and
`expand_enum_method_body`) into per-self-like-arg data stored within
per-field data. It's all quite clumsy and confusing.

This commit rearranges things greatly. Data is obtained in the needed
form up-front, avoiding the need for transposition. Also, various
functions are split, removed, and added, to make things clearer and
avoid tuple return values.

The diff is hard to read, which reflects the messiness of the original
code -- there wasn't an easy way to break these changes into small
pieces. (Sorry!) It's a net reduction of 35 lines and a readability
improvement. The generated code is unchanged.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/Linker.cpp')
0 files changed, 0 insertions, 0 deletions