transmutability: remove NFA intermediate representation

Prior to this commit, the transmutability analysis used an intermediate
NFA representation of type layout. We then determinized this
representation into a DFA, upon which we ran the core transmutability
analysis. Unfortunately, determinizing NFAs is expensive. In this
commit, we avoid NFAs entirely by observing that Rust `union`s are the
only source of nondeterminism and that it is comparatively cheap to
compute the DFA union of DFAs.

We also implement Graphviz DOT debug formatting of DFAs.

Fixes rust-lang/project-safe-transmute#23
Fixes rust-lang/project-safe-transmute#24
This commit is contained in:
Jack Wrenn
2025-04-17 17:58:34 +00:00
parent 883f9f72e8
commit 957b5488a5
6 changed files with 236 additions and 292 deletions

View File

@@ -2,7 +2,7 @@
#![feature(never_type)]
// tidy-alphabetical-end
pub(crate) use rustc_data_structures::fx::{FxIndexMap as Map, FxIndexSet as Set};
pub(crate) use rustc_data_structures::fx::FxIndexMap as Map;
pub mod layout;
mod maybe_transmutable;