-
Notifications
You must be signed in to change notification settings - Fork 59
Add fixed-size Rust primitive type support #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fixed-size Rust primitive type support #170
Conversation
7c45520 to
d8d1df7
Compare
Pull Request Review: Add fixed-size Rust primitive type supportI've reviewed this PR which adds support for ✅ Strengths
|
This change adds support for Rust's pointer-sized integer types (isize and usize) as superficial types at the model definition level. These types are internally mapped to i64 and u64, avoiding platform-dependent types throughout the database layer. Implementation approach: - isize/usize are only supported in Rust struct definitions via the Primitive trait - They map to I64/U64 internally - no new stmt::Type or stmt::Value variants - Conversions happen at the model boundary through TryFrom implementations - No driver changes needed - drivers only see i64/u64 values - Tests verify round-trip behavior works correctly This design keeps the codebase simple while providing ergonomic support for Rust's native pointer-sized types.
d8d1df7 to
3dbf684
Compare
PR Review: Add fixed-size Rust primitive type supportThank you for this contribution! I've reviewed the PR against Toasty's architecture and the documented pattern for adding primitive types (see docs/CHANGE_GUIDE.md § "Adding a New Primitive Type"). While the implementation looks well-structured, there are several critical missing pieces that need to be addressed. ❌ Critical Issues1. Missing Type and Value Enum VariantsThe PR title mentions "fixed-size" primitives, but the implementation actually adds pointer-sized types (isize/usize). However, the core type system is incomplete: Missing in
Missing in
Analysis: According to the documented pattern (docs/CHANGE_GUIDE.md steps 2-3), new primitive types should have dedicated variants in both enums. The current approach of converting through fixed-size types will work but:
2. Missing Helper Methods in TypeMissing in The
But isize/usize are not included in this macro invocation, which means:
This is inconsistent with other numeric types and will break code that expects these helper methods. 3. Missing Value::infer_ty() SupportIssue in The 4. Platform-Specific Test ValuesIssue in isize => &[isize::MIN, -1000000000000, -1, 0, 1, 1000000000000, 4611686018427387903, isize::MAX] => ty_isize;
usize => &[usize::MIN, 0, 1, 1000000000000, 9223372036854775807, 10000000000000000000, usize::MAX] => ty_usize;Problem: The literal values On 32-bit systems:
Fix needed: Use conditional compilation or platform-appropriate test values: #[cfg(target_pointer_width = "64")]
isize => &[isize::MIN, -1000000000000, -1, 0, 1, 1000000000000, isize::MAX] => ty_isize;
#[cfg(target_pointer_width = "32")]
isize => &[isize::MIN, -1000000, -1, 0, 1, 1000000, isize::MAX] => ty_isize;
|
The addition of isize and usize as Primitive types changes the compiler error messages that list all types implementing Primitive. Updated the expected stderr output to include isize in the list.
Pull Request ReviewThank you for working on adding isize/usize support to Toasty! I've reviewed the changes and have identified several critical issues and concerns. Critical Issues1. Missing Core Enum Variants ❌The most critical issue is that this PR does not actually add Isize/Usize variants to the core enums where they're required:
The PR description claims to "Add Isize and Usize variants to stmt::Type and stmt::Value enums", but these changes are not present in the diff. Without these fundamental changes, the code added in this PR cannot actually work. Expected pattern (following the guide in // In ty.rs Type enum:
pub enum Type {
// ... existing variants
I64,
Isize,
U64,
Usize,
// ...
}
// In value.rs Value enum:
pub enum Value {
// ... existing variants
I64(i64),
Isize(isize),
U64(u64),
Usize(usize),
// ...
}
// In num.rs impl_num! invocation:
impl_num! {
// ... existing entries
I64(i64) { to_i64 to_i64_unwrap is_i64 }
Isize(isize) { to_isize to_isize_unwrap is_isize }
U64(u64) { to_u64 to_u64_unwrap is_u64 }
Usize(usize) { to_usize to_usize_unwrap is_usize }
}2. Incorrect PR Title
|
This change adds support for Rust's pointer-sized integer types (isize and usize) to match the existing support for fixed-size integers (i8, i16, i32, i64, u8, u16, u32, u64).
Changes include: