Skip to content

c-variadic: document Clone and Drop instances and require VaArgSafe: Copy#155821

Open
folkertdev wants to merge 3 commits intorust-lang:mainfrom
folkertdev:doc-va-list-clone
Open

c-variadic: document Clone and Drop instances and require VaArgSafe: Copy#155821
folkertdev wants to merge 3 commits intorust-lang:mainfrom
folkertdev:doc-va-list-clone

Conversation

@folkertdev
Copy link
Copy Markdown
Contributor

tracking issue: #44930

Fixing some things that came up in the stabilization PR

r? tgross35
cc @kpreid

@folkertdev folkertdev added the F-c_variadic `#![feature(c_variadic)]` label Apr 26, 2026
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 26, 2026

tgross35 is currently at their maximum review capacity.
They may take a while to respond.

Comment thread library/core/src/ffi/va_list.rs Outdated
Comment on lines +252 to +254
/// Clone the [`VaList`] producing a second independent cursor into the variable argument list.
///
/// Corresponds to `va_copy` in C.
Copy link
Copy Markdown
Contributor

@kpreid kpreid Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this documentation would be better placed on the fn than the impl.

  • in rustdoc, the display of an impl on a type’s page is to show the fn documentation, falling back to the trait’s fn’s documentation if there is no documentation on the impl’s fn. Putting documentation on the fn replaces that boilerplate instead of adding more text next to it.
  • In rust-analyzer, function documentation can be accessed by hovering the clone() call. So, overriding the function documentation here means that the user can quickly read about what this specific clone() means.
  • Also, semantically, this text specifies an effect of calling the function, so it should be function documentation.

View changes since the review

Comment thread library/core/src/ffi/va_list.rs Outdated
}
}

/// Clone the [`VaList`] producing a second independent cursor into the variable argument list.
Copy link
Copy Markdown
Contributor

@kpreid kpreid Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Clone the [`VaList`] producing a second independent cursor into the variable argument list.
/// Clone the [`VaList`], producing a second independent cursor into the variable argument list.

View changes since the review

because a VaList can be cloned, the same c-variadic argument can be read twice and that is only safe if the argument type is copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-c_variadic `#![feature(c_variadic)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants