rust/tests/pretty
Stuart Cook 3538bc18fe
Rollup merge of #143619 - beetrees:varargs-named, r=jdonszelmann
`c_variadic`: Add future-incompatibility warning for `...` arguments without a pattern outside of `extern` blocks

This PR makes `...` arguments without a pattern in non-foreign functions (such as the argument in `unsafe extern "C" fn f(...) {}`) a future-compatibility warning; making this error would be consistent with how `unsafe extern "C" fn f(u32) {}` is handled. Allowing `...` arguments without a pattern in non-foreign functions is a source of confusion for programmers coming from C, where the `...` parameter is never named and instead calling `va_start` is required; disallowing `...` arguments without a pattern also improves the overall consistency of the Rust language by matching the treatment of other arguments without patterns. `...` arguments without a pattern in `extern` blocks (such as `unsafe extern "C" { fn f(...); }`) continue to compile without warnings after this PR, as they are already stable and heavily used (and don't cause the mentioned confusion as they are just being used in function declarations).

As all the syntax gating for `c_variadic` has been done post-expansion, this is technically a breaking change. In particular, code like this has compiled on stable since Rust 1.35.0:
```rust
#[cfg(any())] // Equivalent to the more recent #[cfg(false)]
unsafe extern "C" fn bar(_: u32, ...) {}
```
Since this is more or less a stability hole and a Crater run shows only the `binrw` crate is using this, I think it would be ok to break this. This will require a lang FCP.

The idea of rejecting `...` pre-expansion was first raised here https://github.com/rust-lang/rust/pull/143546#issuecomment-3043142052.

Tracking issue: rust-lang/rust#44930
cc `@folkertdev` `@workingjubilee`
r? `@joshtriplett`
2025-11-11 21:09:33 +11:00
..
autodiff Update autodiff tests for the new intrinsics impl 2025-08-14 18:33:43 +00:00
auxiliary Update tests to use new proc-macro header 2024-11-27 07:18:25 -08:00
postfix-match expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
asm.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
asm.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
ast-stmt-expr-attr.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
async.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
attr-derive.rs Update tests to use new proc-macro header 2024-11-27 07:18:25 -08:00
attr-fn-inner.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
attr-literals.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
attr-tokens-raw-ident.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
auto-trait.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
blank-lines.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
block-comment-multiple-asterisks.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
block-comment-trailing-whitespace.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
block-comment-trailing-whitespace2.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
block-comment-wchar.pp Re-bless tests/pretty 2024-02-22 16:04:05 +00:00
block-comment-wchar.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
block-disambig.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
cast-lt.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
cast-lt.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
closure-reform-pretty.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
delegation.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
delimited-token-groups.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
disamb-stmt-expr.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
do1.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
doc-comments.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
dollar-crate.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
dollar-crate.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
empty-impl.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
empty-lines.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
enum-variant-vis.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
example1.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
example2.pp Re-bless tests/pretty 2024-02-22 16:04:05 +00:00
example2.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
expanded-and-path-remap-80832.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
expanded-and-path-remap-80832.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
fn-return.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
fn-types.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
fn-variadic.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
for-comment.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
format-args-str-escape.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
format-args-str-escape.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
gat-bounds.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
hir-delegation.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
hir-delegation.rs Add a HIR pretty printing test for delegation. 2025-04-10 14:09:37 +10:00
hir-fn-params.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
hir-fn-params.rs Add a pretty printing test for fn params. 2025-03-14 06:29:24 +11:00
hir-fn-variadic.pp c_variadic: Add future-incompatibility warning for ... arguments without a pattern outside of extern blocks 2025-11-10 14:33:56 +01:00
hir-fn-variadic.rs c_variadic: Add future-incompatibility warning for ... arguments without a pattern outside of extern blocks 2025-11-10 14:33:56 +01:00
hir-if-else.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
hir-if-else.rs Add pretty printing tests for if/else. 2025-04-25 14:33:14 +10:00
hir-lifetimes.pp Remove QPath::LangItem from ranges 2025-10-27 21:19:38 -05:00
hir-lifetimes.rs Add a HIR pretty-printing test focused on lifetimes. 2025-03-28 08:25:06 +11:00
hir-pretty-attr.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
hir-pretty-attr.rs pretty print hir attributes 2025-02-24 14:31:19 +01:00
hir-pretty-loop.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
hir-pretty-loop.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
hir-struct-expr.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
hir-struct-expr.rs Improve hir_pretty for struct expressions. 2025-03-30 11:21:51 +02:00
if-attr.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
if-else.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
if-else.rs Add pretty printing tests for if/else. 2025-04-25 14:33:14 +10:00
import-renames.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-4264.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
issue-4264.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-12590-a.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-12590-b.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-12590-c.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
issue-12590-c.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-19077.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-25031.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-30731.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-31073.pp Re-bless tests/pretty 2024-02-22 16:04:05 +00:00
issue-31073.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-68710-field-attr-proc-mac-lost.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-73626.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-74745.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-85089.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
issue-85089.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
let.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
lifetime.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
macro.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
macro_rules.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
match-block-expr.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
match-naked-expr-medium.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
match-naked-expr.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
nested-item-vis-defaultness.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
never-pattern.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
never-pattern.rs Add a pretty printing test involving a never pattern. 2025-04-24 19:19:51 +10:00
offset_of.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
path-type-bounds.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
pin-ergonomics-hir.pp Implement &pin patterns and ref pin bindings 2025-11-10 09:57:08 +08:00
pin-ergonomics-hir.rs Implement &pin patterns and ref pin bindings 2025-11-10 09:57:08 +08:00
pin-ergonomics.rs Implement &pin patterns and ref pin bindings 2025-11-10 09:57:08 +08:00
postfix-yield.rs Update tests. 2025-04-15 11:14:23 +02:00
qpath-associated-type-bound.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
raw-address-of.rs stabilize raw_ref_op 2024-08-18 19:46:53 +02:00
raw-str-nonexpr.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
shebang-at-top.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
shebang-at-top.rs Put shebang at the top of pretty-print 2025-02-23 10:51:22 +01:00
stmt_expr_attributes.rs fix pretty test 2025-03-21 09:35:31 +01:00
struct-pattern.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
struct-tuple.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
tag-blank-lines.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
tests-are-sorted.pp expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
tests-are-sorted.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
top-level-doc-comments.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
trait-inner-attr.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
trait-polarity.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
trait-safety.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
unary-op-disambig.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
use-tree.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
vec-comments.pp Re-bless tests/pretty 2024-02-22 16:04:05 +00:00
vec-comments.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
where-clauses.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
yeet-expr.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00