From 64de5c6d728da15f38d5df3adb062c60b91c31ae Mon Sep 17 00:00:00 2001 From: benluelo <57334811+benluelo@users.noreply.github.com> Date: Fri, 15 Sep 2023 10:07:44 -0400 Subject: [PATCH] feat: feature gate uint > u32::MAX to 64 bit architectures (#197) --- build/generic_const_mappings.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build/generic_const_mappings.rs b/build/generic_const_mappings.rs index 20360e041..9ed761347 100644 --- a/build/generic_const_mappings.rs +++ b/build/generic_const_mappings.rs @@ -77,15 +77,25 @@ pub mod generic_const_mappings { write!( f, " + {cfg} impl ToUInt for Const<{uint}> {{ type Output = U{uint}; }} \ ", uint = uint, + cfg = feature_gate_to_64_bit(uint), )?; } write!(f, "}}")?; f.flush()?; Ok(()) } + +const fn feature_gate_to_64_bit(uint: u64) -> &'static str { + if uint > u32::MAX as u64 { + r#"#[cfg(target_pointer_width = "64")]"# + } else { + "" + } +}