Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a0b99cc

Browse files
RalfJungDarksonn
authored andcommitted
Apply suggestions from code review
1 parent 9e27a00 commit a0b99cc

File tree

1 file changed

+11
-0
lines changed
  • library/core/src/fmt

1 file changed

+11
-0
lines changed

library/core/src/fmt/rt.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ macro_rules! argument_new {
8080
// To avoid this crash, we use a helper function when CFI is enabled. To avoid the
8181
// cost of this helper function (mainly code-size) when it is not needed, we
8282
// transmute the function pointer otherwise.
83+
//
84+
// This is is similar to what the Rust compiler does internally with vtables when
85+
// CFI is enabled, where it generates trampoline functions that only serve to adjust
86+
// the expected type of the argument. `ArgumentType::Placeholder` is a bit like a
87+
// manually constructed trait object, so it is not surprising that the same approach
88+
// has to be applied here as well.
89+
//
90+
// It is still considered problematic (from the Rust side) that CFI rejects entirely
91+
// legal Rust programs, so we do not consider anything done here a stable guarantee,
92+
// but meanwhile we carry this work-around to keep Rust compatible with CFI
93+
// runtimes.
8394
#[cfg(not(any(sanitize = "cfi", sanitize = "kcfi")))]
8495
formatter: {
8596
let f: fn(&$t, &mut Formatter<'_>) -> Result = $f;

0 commit comments

Comments
 (0)