-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
designSomething needing thoughtSomething needing thoughtnew builtin ruleA brand new builtin ruleA brand new builtin rule
Description
Needs thought, just quick brain dump
Add built-in lint rule to discourage potentially unsafe platform-dependent integer usage. e.g., serialising usize and isize where you can't guarantee the deserialising system will be 32 or 64 bit.
Safe usages would be like arithmetic on pointers, array lengths, allocating memory... 🤔
A simple start could be a configurable rule:
allow_usize_in_struct: bool = false,
allow_usize_in_public_api:bool = false,
allow_isize_in_struct: bool = false,
allow_isize_in_public_api:bool = false,
or could go for an allowlist approach to also restrict fixed width types if your project desires (in this case maybe no_unsafe_int would be a better rule name)
allow_in_struct: []const[]const int_type = &.{u8, u16, u32, u64, i32, i64 },
allow_in_public_api: []const[]const int_type = &.{u8, u16, u32, u64, i32, i64 },
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
designSomething needing thoughtSomething needing thoughtnew builtin ruleA brand new builtin ruleA brand new builtin rule