This branch updates mir_op to respect the new FIXED flag, thereby stopping most rewriting of already-safe code.
The main effect is that when emit_cast_* sees a FIXED type on one side of the cast, it tries to obtain a TypeDesc by deconstructing the existing Ty, rather than by looking at the perms and flags the analysis came up with. This ensure we keep the original Ty unchanged, even if the perms and flags would result in a different type. For example, given a FIXED pointer of type &[T], we would produce (Ownership::Ref, Quantity::Slice, T), which accurately reflects the type &[T], regardless of what the perms and flags say.
Currently this is only used to preserve existing refs, and in that case, the perms and flags should generally agree with the FIXEDTy. But in the future we'll extend this to raw pointers (such as FFI and unanalyzed functions), where perms and flags will normally suggest some kind of safe rewrite (e.g. *mut T -> &[T]), but we don't actually want to perform that rewrite.
Depends on #920; once #920 is merged, I'll rebase this onto master
This branch updates
mir_op
to respect the newFIXED
flag, thereby stopping most rewriting of already-safe code.The main effect is that when
emit_cast_*
sees aFIXED
type on one side of the cast, it tries to obtain aTypeDesc
by deconstructing the existingTy
, rather than by looking at theperms
andflags
the analysis came up with. This ensure we keep the originalTy
unchanged, even if theperms
andflags
would result in a different type. For example, given aFIXED
pointer of type&[T]
, we would produce(Ownership::Ref, Quantity::Slice, T)
, which accurately reflects the type&[T]
, regardless of what theperms
andflags
say.Currently this is only used to preserve existing refs, and in that case, the
perms
andflags
should generally agree with theFIXED
Ty
. But in the future we'll extend this to raw pointers (such as FFI and unanalyzed functions), whereperms
andflags
will normally suggest some kind of safe rewrite (e.g.*mut T
->&[T]
), but we don't actually want to perform that rewrite.Depends on #920; once #920 is merged, I'll rebase this onto master