What is windows-rs doing with `MaybeUninit` in bindgen?

Aperta
#632 8 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
12/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
documentation

Direzione di ricerca

This is a discussion thread, not a scoped change: it asks @kennykerr to explain why crates/libs/bindgen/src/types/mod.rs (around lines 812-819) wraps types in MaybeUninit at the ABI level. Start by reading that block alongside #631, then try to reproduce it by running the binding generator over an API that would trigger the MaybeUninit emission and checking whether the pre-baked bindings in the crate ever contain it. Done here means a posted explanation of what the code does and whether generated-vs-prebuilt bindings differ, since no patch is requested.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

This is part of https://github.com/rust-lang/unsafe-code-guidelines/issues/631:

@N1ark found this fun bit of code:
https://github.com/microsoft/windows-rs/blob/aa019b4f7828eb4786bad52181bd5a3a8972a156/crates/libs/bindgen/src/types/mod.rs#L812-L819

This wraps some types in MaybeUninit on the ABI level. That's quite concerning if we're taking back the ABI compatibility promise (see #631). We should understand what happens here.

@kennykerr could you help us understand this, and explain what that code does / why it uses MaybeUninit? What kinds of APIs would cause it to emit a MaybeUninit? It seems like the files in the repo don't actually use MaybeUninit for their bindings (at least, GH code search doesn't seem to find anything), so does this only affect people that generate their own bindings? I'd expect the pre-baked bindings to use the same binding generator though so we should see the MaybeUninit somewhere in that crate, right?

Lingua principale
Nessun dato sulla lingua
Stelle
760
Fork
68
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-lang/unsafe-code-guidelines

Tutte le issue di rust-lang/unsafe-code-guidelines

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.