From 7162f3dd95edcc3cf8498eb8919bc72729493178 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 28 Dec 2020 18:15:36 +0100 Subject: [PATCH] avoid relying on implicit promotion of const fn calls --- src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index af84af9..2cb1da9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -240,7 +240,7 @@ macro_rules! raw_one_const { [$type:ty: $a: expr] => {$a}; [str: $a: expr, $b: expr] => {{ - unsafe { + const _HIDDEN: &str = unsafe { $crate::ignore_feature::const_raw_ptr( &$crate::raw_one_const!{ u8: @@ -248,7 +248,8 @@ macro_rules! raw_one_const { $b.as_bytes() } ) - } + }; + _HIDDEN }}; [str: $a: expr, $($b: expr),*] => {{ @@ -257,7 +258,7 @@ macro_rules! raw_one_const { [$type:ty: $a: expr, $b: expr] => {{ #[allow(unused_unsafe)] - unsafe { + const _HIDDEN: [$type; $a.len() + $b.len()] = unsafe { $crate::const_concat::< [$type; $a.len()], [$type; $b.len()], @@ -265,7 +266,8 @@ macro_rules! raw_one_const { [$type; $a.len() + $b.len()], >($a, $b) - } + }; + _HIDDEN }}; [$type:ty: $a: expr, $($b: expr),*] => {{