New lints: Changes to enum variant discriminants #898
Labels
A-lint
Area: new or existing lint
E-help-wanted
Call for participation: Help is requested to fix this issue.
E-mentor
Call for participation: Mentorship is available for this issue.
Background on discriminants: https://doc.rust-lang.org/reference/items/enumerations.html#discriminants
We're looking for four lints total:
#[repr(u8)]
or#[repr(i64)]
#[repr(u8)]
or#[repr(i64)]
We distinguish between the repr/no-repr cases so that we can offer better error messages. When an enum has an explicit repr, that imposes an ABI (application binary interface) constraint in addition to the API constraint. Without a repr, the numeric value of the discriminant is fixed but its binary representation is not and could be anything.
For examples of querying the
repr
properly, please look at theenum_repr_int_changed
lint. Make sure to include test cases where the repr is#[repr(C, i64)]
or#[repr(u8, C)]
since both variants are allowed too. The lints must appropriately detect the integer repr in both these cases and more straightforward ones like#[repr(i8)]
.The text was updated successfully, but these errors were encountered: