about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/errors.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-07-08 15:32:27 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-07-11 16:58:32 +1000
commit10144e29afb432425fc88cd2534577b4efa05937 (patch)
tree0fc9f573cb7135d0cc9d8f5c4c6e0aaf07f6da1b /compiler/rustc_const_eval/src/errors.rs
parent4bcbd76bc9f8e3a22b251cbdfb21ba7815d61c7f (diff)
downloadrust-10144e29afb432425fc88cd2534577b4efa05937.tar.gz
rust-10144e29afb432425fc88cd2534577b4efa05937.zip
Handle tags better.
Currently, for the enums and comparison traits we always check the tag
for equality before doing anything else. This is a bit clumsy. This
commit changes things so that the tags are handled very much like a
zeroth field in the enum.

For `eq`/ne` this makes the code slightly cleaner.

For `partial_cmp` and `cmp` it's a more notable change: in the case
where the tags aren't equal, instead of having a tag equality check
followed by a tag comparison, it just does a single tag comparison.

The commit also improves how `Hash` works for enums: instead of having
duplicated code to hash the tag for every arm within the match, we do
it just once before the match.

All this required replacing the `EnumNonMatchingCollapsed` value with a
new `EnumTag` value.

For fieldless enums the new code is particularly improved. All the code
now produced is close to optimal, being very similar to what you'd write
by hand.
Diffstat (limited to 'compiler/rustc_const_eval/src/errors.rs')
0 files changed, 0 insertions, 0 deletions