How far does repr(transparent)'s transparentness stretch in repr(Rust)?

Aperta
#604 34 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Tranquilla
Stack tecnologico
rust
Ambito
compilers

Direzione di ricerca

Start by reading the issue examples involving repr(transparent), tuples, and generic structs, then review the 34-comment discussion for the current positions. Determine the intended transmutability rules and document a consensus covering transparent types used directly and as fields; done requires an agreed specification rather than a localized code change.

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

Descrizione

A-layout S-pending-design

As I understand it, generally two otherwise identical Rust type definitions (e.g. struct Foo(u8, usize), struct Bar(u8, usize)) do not need to produce transmutable types, trivially shown by using -Zrandomize-layout with identically defined structs with a couple fields.

However, of course (u8, usize) and (u8, usize) can be transmuted, after all, they are the same type. The same goes for Generic<u8> and Generic<u8>.

What if we have #[repr(transparent)] struct Wrap(u8);: Are (Wrap, usize) and (u8, usize) transmutable?

What about Generic<u8> and Generic<Wrap> where Generic is some generic struct?

How far does repr(transparent) stretch in its equivalency when the transparent type is used as a field elsewhere?

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 Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.