`repr(transparent)` ignores fields that do not have "trivial ABI"

Aperta
#166,183 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
compilers

Direzione di ricerca

Read the linked PRs #157973 and #155984 to understand the trivial ABI change and the stalled implementation. Then trace how repr(transparent) determines which fields it ignores and inspect the related compiler tests. Done means transparent representation ignores only fields with trivial ABI, with regression coverage for the two zero-sized array fields shown in the issue.

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

Descrizione

A-ABI C-bug T-lang T-opsem

In https://github.com/rust-lang/rust/pull/157973 we introduced the concept of "trivial ABI", and declared that types like [u8; 0] or repr(C) 1-ZST do not have trivial ABI. However, repr(transparent) still ignores such types, so we accept e.g.

#[repr(transparent)]
struct S {
  a: [u8; 0],
  b: [i8; 0],
}

Since it's not clear which field is being wrapped by S, we basically have to make S ABI-compatible with all its fields, but the two fields are not ABI-compatible so that does not work out. We should therefore transition repr(transparent) to only ignore fields that have "trivial ABI".

@Jules-Bertholet started working on that in https://github.com/rust-lang/rust/pull/155984. However, the work has stalled, so I figured it'd be worth opening an issue to track this. @Jules-Bertholet do you still plan to get back to that PR, or would you be fine with someone else picking up the work?

Lingua principale
Rust
Stelle
122k
Fork
16.7k
Merge medio
2g 16h
PR unite (30g)
515

Preparare l'ambiente

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/rust

Tutte le issue di rust-lang/rust

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.