rust-lang / rust-lang/rust

c-variadic: improve implicit `&'reg VaList` argument diagnostics

Open
#160,495 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

F-c_variadic needs-triage
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

cc #160504

see that PR for more detail and the FIXME(#160495) in the code, e.g.

https://github.com/rust-lang/rust/blob/c9ff496891c278ad660bc0ab85c1f0b72059464a/tests/ui/c-variadic/not-async.rs#L2-L14

results in

error: functions cannot be both `async` and C-variadic
  --> $DIR/not-async.rs:4:1
   |
LL | async unsafe extern "C" fn fn_cannot_be_async(x: isize, _: ...) {}
   | ^^^^^ `async` because of this                           ^^^^^^ C-variadic because of this

error: functions cannot be both `async` and C-variadic
  --> $DIR/not-async.rs:11:5
   |
LL |     async unsafe extern "C" fn method_cannot_be_async(x: isize, _: ...) {}
   |     ^^^^^ `async` because of this                               ^^^^^^ C-variadic because of this

error[E0700]: hidden type for `impl Future<Output = ()>` captures lifetime that does not appear in bounds
  --> $DIR/not-async.rs:4:65
   |
LL | async unsafe extern "C" fn fn_cannot_be_async(x: isize, _: ...) {}
   | ----------------------------------------------------------------^^
   | |                                                              |
   | |                                                              opaque type defined here
   | hidden type `{async fn body of fn_cannot_be_async()}` captures the anonymous lifetime as defined here

error[E0700]: hidden type for `impl Future<Output = ()>` captures lifetime that does not appear in bounds
  --> $DIR/not-async.rs:11:73
   |
LL |     async unsafe extern "C" fn method_cannot_be_async(x: isize, _: ...) {}
   |     --------------------------------------------------------------------^^
   |     |                                                                  |
   |     |                                                                  opaque type defined here
   |     hidden type `{async fn body of S::method_cannot_be_async()}` captures the anonymous lifetime as defined here

error: aborting due to 4 previous errors

with #160491 but should instead explicitly talk about the fact that we're capturing the &VaList here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the FIXME(#160495) referenced in the issue and review PR #160504 for context. Run tests/ui/c-variadic/not-async.rs and inspect its diagnostics, then update the compiler behavior and expected output so the error explicitly describes capturing the &VaList argument rather than reporting the unrelated lifetime error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.