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

Tom Tromey
2016-10-30T02:53:06Z

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

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

Oh duh, I see that this isn't a correct counter-example.
What about just "print univariant.a"?
It seems to me that this will hit this:

start = disr.is_encoded ? 0 : 1;

... choosing 1 here, but:

for (i = start; i < TYPE_NFIELDS (variant_type); i++)

... failing this because TYPE_NFIELDS == 1; and then:

if (i == TYPE_NFIELDS (variant_type))
/* We didn't find it. */
error(_("Could not find field %s of struct variant %s"),

Tom