Skip to content

Commit

Permalink
avoid relying on implicit promotion of const fn calls
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Dec 28, 2020
1 parent a8e513a commit 7162f3d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,16 @@ 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:
$a.as_bytes(),
$b.as_bytes()
}
)
}
};
_HIDDEN
}};

[str: $a: expr, $($b: expr),*] => {{
Expand All @@ -257,15 +258,16 @@ 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()],
$type,

[$type; $a.len() + $b.len()],
>($a, $b)
}
};
_HIDDEN
}};

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

0 comments on commit 7162f3d

Please sign in to comment.