Skip to content

Commit

Permalink
(c2rust-analyze) Formally defined the safe transmutability definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkysen committed Feb 19, 2023
1 parent da4d961 commit 62ec8dc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions c2rust-analyze/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,16 @@ pub fn lty_project<'tcx, L: Debug>(
///
/// Thus, [`true`] means it is definitely transmutable,
/// while [`false`] means it may not be transmutable.
///
/// Formally, safe transmutability defines
/// an equivalence relation on types, named `~` here.
/// `A ~ B` iff `*(a as *const B)` and `*(b as *const A)` are safe,
/// where `a: *const A` and `b: *const B`.
///
/// And the current incomplete implementation is defined as:
/// * `A = B => A ~ B`
/// * `A ~ B => *A ~ *B`
/// * `uN ~ iN`, where `N` is an integer width
pub fn are_transmutable<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
let transmutable_ints = || {
use IntTy::*;
Expand Down

0 comments on commit 62ec8dc

Please sign in to comment.