Skip to content

crucible-mir: Remove clone shim logic for arrays #1646

@RyanGlScott

Description

@RyanGlScott

As of rust-lang/rust#86041, Clone impls for array types are now implemented in library code rather than using clone shims. As such, the TyArray case in crucible-mir's clone shim logic is now unreachable, and we can remove it to simplify things:

cloneShimDef (TyArray ty len) parts
| [part] <- parts = CustomMirOp $ \ops -> do
lv <- case ops of
[Move lv] -> return lv
[Copy lv] -> return lv
[op] -> mirFail $ "cloneShimDef: expected lvalue operand, but got " ++ show op
_ -> mirFail $ "cloneShimDef: expected exactly one argument, but got " ++ show (length ops)
-- The argument to the clone shim is `&[T; n]`. The clone method for
-- elements requires `&T`, computed as `&arg[i]`.
let elementRefRvs = map (\i ->
Ref Shared (LProj (LProj lv Deref) (ConstantIndex i len False)) "_") [0 .. len - 1]
elementRefExps <- mapM evalRval elementRefRvs
elementRefOps <- mapM (\expr -> makeTempOperand (TyRef ty Immut) expr) elementRefExps
clonedExps <- mapM (\op -> callExp part [op]) elementRefOps
Some tpr <- tyToReprM ty
buildArrayLit tpr clonedExps
| otherwise = CustomOp $ \_ _ -> mirFail $
"expected exactly one clone function for in array clone shim, but got " ++ show parts

See GaloisInc/mir-json#197 for the corresponding mir-json-side issue.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions