Skip to content

Commit 1aff65f

Browse files
folkertdevRalfJung
andauthored
Apply suggestions from code review
Co-authored-by: Ralf Jung <post@ralfj.de>
1 parent 936b529 commit 1aff65f

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

library/core/src/ffi/va_list.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,9 @@ impl Clone for VaList<'_> {
190190
#[inline]
191191
fn clone(&self) -> Self {
192192
// We only implement Clone and not Copy because some future target might not be able to
193-
// implement Copy (e.g. because it allocates).
194-
195-
// We still use a `va_copy` intrinsic to provide a hook for const evaluation. The hook is
196-
// used to report UB when a variable argument list is duplicated with a manual `memcpy`.
197-
// While that works in practice for all current targets, we want to be able to support
198-
// targets in the future where that is not the case.
193+
// implement Copy (e.g. because it allocates). For the same reason we use an intrinsic
194+
// to do the copying: the fact that on all current targets, this is just `memcpy`, is an implementation
195+
// detail. The intrinsic lets Miri catch UB from code incorrectly relying on that implementation detail.
199196
va_copy(self)
200197
}
201198
}

library/core/src/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3473,7 +3473,7 @@ pub unsafe fn va_arg<T: VaArgSafe>(ap: &mut VaList<'_>) -> T;
34733473
#[rustc_intrinsic]
34743474
#[rustc_nounwind]
34753475
pub fn va_copy<'f>(src: &VaList<'f>) -> VaList<'f> {
3476-
// NOTE: this intrinsic exists only as a hook for constant evaluation, and is used to detect UB
3476+
// NOTE: this intrinsic exists only as a hook for Miri and constant evaluation, and is used to detect UB
34773477
// when `VaList` is used incorrectly. Codegen backends should not have custom behavior for this
34783478
// intrinsic, they should always use this fallback implementation.
34793479
src.duplicate()

0 commit comments

Comments
 (0)