Validate transmutation size using const
code
#239
Labels
compatibility-breaking
Changes that are (likely to be) breaking
const
code
#239
As discussed here and here, it would be great if we could replace
transmute!
with an equivalenttransmute
function that performs size verification usingconst
code. This would simplify the implementation, and would allowtransmute
to be used in type-generic contexts (transmute!
can only be called in a context in which all types are concrete). However, due to limitations with const generics, errors can only be reported at monomorphization time. This causes some problems:cargo build
but notcargo check
rust-lang/rust#112301, code that generates errors when compiled withcargo build
would not generate errors when compiled withcargo check
There are a few ways that we could lift this information into the type system and avoid these issues, but all of them rely on unstable features:
associated_const_equality
generic_const_exprs
Alternatively:
The text was updated successfully, but these errors were encountered: