Skip to content

Commit 2b7d093

Browse files
authored
Merge pull request #2 from RalfJung/promotion
avoid relying on implicit promotion of const fn calls
2 parents a8e513a + 7162f3d commit 2b7d093

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,16 @@ macro_rules! raw_one_const {
240240
[$type:ty: $a: expr] => {$a};
241241

242242
[str: $a: expr, $b: expr] => {{
243-
unsafe {
243+
const _HIDDEN: &str = unsafe {
244244
$crate::ignore_feature::const_raw_ptr(
245245
&$crate::raw_one_const!{
246246
u8:
247247
$a.as_bytes(),
248248
$b.as_bytes()
249249
}
250250
)
251-
}
251+
};
252+
_HIDDEN
252253
}};
253254

254255
[str: $a: expr, $($b: expr),*] => {{
@@ -257,15 +258,16 @@ macro_rules! raw_one_const {
257258

258259
[$type:ty: $a: expr, $b: expr] => {{
259260
#[allow(unused_unsafe)]
260-
unsafe {
261+
const _HIDDEN: [$type; $a.len() + $b.len()] = unsafe {
261262
$crate::const_concat::<
262263
[$type; $a.len()],
263264
[$type; $b.len()],
264265
$type,
265266

266267
[$type; $a.len() + $b.len()],
267268
>($a, $b)
268-
}
269+
};
270+
_HIDDEN
269271
}};
270272

271273
[$type:ty: $a: expr, $($b: expr),*] => {{

0 commit comments

Comments
 (0)