From 678f7d0e20d5ca862788c66d6d21dba9b11eeb21 Mon Sep 17 00:00:00 2001 From: Ben Luelo Date: Thu, 6 Jul 2023 09:53:45 -0400 Subject: [PATCH] feat: feature gate uint > u32::MAX to 64 bit architectures --- 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 { + "" + } +}