Re: [PATCH] Fix handling of discriminantless univariant enums in Rust

Tom Tromey
2016-10-30T02:48:00Z

>>>>> "Manish" == Manish Goregaokar <manish@mozilla.com> writes:

Manish> + else if (TYPE_NFIELDS (type) == 1) {
Manish> + /* Sometimes univariant enums are encoded without a
Manish> + discriminant. In that case, treating it as an encoded enum
Manish> + with the first field being the actual type works. */
Manish> + const char* field_name = TYPE_NAME (TYPE_FIELD_TYPE (type, 0));
Manish> + ret.name = concat (TYPE_NAME (type), "::",
Manish> + rust_last_path_segment (field_name),
Manish> + (char *) NULL);
Manish> + ret.field_no = RUST_ENCODED_ENUM_REAL;
Manish> + ret.is_encoded = 1;
Manish> + return ret;
Manish> + }

This needs some small changes to conform to the GNU coding style.

Also, I suspect this will wind up doing the wrong thing in the
STRUCTOP_ANONYMOUS case in rust_evaluate_subexp. In particular I wonder
if an additional "print univariant.0.a" test will work correctly?

Tom