Skip to content

Commit 8aa438a

Browse files
committed
cfg(kcfi)
1 parent 7b95216 commit 8aa438a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Diff for: core/src/fmt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::char::{EscapeDebugExtArgs, MAX_LEN_UTF8};
77
use crate::marker::PhantomData;
88
use crate::num::fmt as numfmt;
99
use crate::ops::Deref;
10-
use crate::{iter, result, str};
10+
use crate::{iter, mem, result, str};
1111

1212
mod builders;
1313
#[cfg(not(no_fp_fmt_parse))]

Diff for: core/src/fmt/rt.rs

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ macro_rules! argument_new {
7272
// a `fn(&T, ...)`, so the invariant is maintained.
7373
ty: ArgumentType::Placeholder {
7474
value: NonNull::<$t>::from_ref($x).cast(),
75+
#[cfg(not(any(sanitize = "cfi", sanitize = "kcfi")))]
76+
formatter: {
77+
let f: fn(&$t, &mut Formatter<'_>) -> Result = $f;
78+
// SAFETY: This is only called with `value`, which has the right type.
79+
unsafe { mem::transmute(f) }
80+
},
81+
#[cfg(any(sanitize = "cfi", sanitize = "kcfi"))]
7582
formatter: |ptr: NonNull<()>, fmt: &mut Formatter<'_>| {
7683
let func = $f;
7784
// SAFETY: This is the same type as the `value` field.

0 commit comments

Comments
 (0)