c-variadic: tweak std docs#155613
Conversation
|
|
| /// | ||
| /// When C passes variable arguments, integers smaller than [`c_int`] and floats smaller | ||
| /// than [`c_double`] are implicitly promoted to [`c_int`] and [`c_double`] respectively. | ||
| /// Implementing this trait for types that are subject to this promotion rule is invalid. |
There was a problem hiding this comment.
Nit while you're here, "integers smaller than [c_int] and floats smaller than [c_double] are implicitly promoted to [c_int] and [c_double] respectively" could probably be rephrased to "integers smaller than [c_int] are promoted to [c_int], and [c_float] is promoted to [c_double]. Since not all floats smaller than double are promoted.
| /// The standard library implements this trait for primitive types that are | ||
| /// expected to have a variable argument application-binary interface (ABI) on all | ||
| /// platforms. | ||
| /// Support for other types is not portable. |
There was a problem hiding this comment.
Perhaps something like "Support for other c_ types is not portable and may not be available on all platforms." to account for platforms where you might get c_float in the list? Or maybe mention specifically that u* and i* shouldn't be relied upon directly even though they may happen to get the trait impl on some platforms.
There was a problem hiding this comment.
I tweaked it a bit more. The thing is that practically you can rely on e.g. usize having an implementation. It's really only in very niche cases that f32 is implemented, and the future i128 impl is very much non-portable.
but given that VaList is specifically for FFI, it feels OK to just recommend people use c_ types.
838e305 to
2c06c62
Compare
This comment has been minimized.
This comment has been minimized.
2c06c62 to
6ca836b
Compare
…r=tgross35 c-variadic: tweak `std` docs tracking issue: rust-lang#44930 In preparation of a rename of `arg` to `next_arg` cc @workingjubilee r? tgross35
Rollup of 7 pull requests Successful merges: - #155589 (Forbid `check-pass`/`build-pass`/`run-pass` directives in incremental tests) - #155610 (Add missing `dyn` keyword to `trait_alias` page of the Unstable Book) - #155615 (test cleanups for `ui/derives` and `ui/deriving`) - #154874 (Fix ICE for inherited const conditions on const closures) - #155605 (std: Update support for `wasm32-wasip3`) - #155613 (c-variadic: tweak `std` docs) - #155619 (Remove a bunch of unnecessary explicit lifetimes from the ast validator)
Rollup merge of #155613 - folkertdev:c-variadic-doc-tweaks, r=tgross35 c-variadic: tweak `std` docs tracking issue: #44930 In preparation of a rename of `arg` to `next_arg` cc @workingjubilee r? tgross35
Rollup of 7 pull requests Successful merges: - rust-lang/rust#155589 (Forbid `check-pass`/`build-pass`/`run-pass` directives in incremental tests) - rust-lang/rust#155610 (Add missing `dyn` keyword to `trait_alias` page of the Unstable Book) - rust-lang/rust#155615 (test cleanups for `ui/derives` and `ui/deriving`) - rust-lang/rust#154874 (Fix ICE for inherited const conditions on const closures) - rust-lang/rust#155605 (std: Update support for `wasm32-wasip3`) - rust-lang/rust#155613 (c-variadic: tweak `std` docs) - rust-lang/rust#155619 (Remove a bunch of unnecessary explicit lifetimes from the ast validator)
tracking issue: #44930
In preparation of a rename of
argtonext_argcc @workingjubilee
r? tgross35