Closed
Description
@Nashenas88 implemented aggregate type-checking in nikomatsakis#13, but we still need to handle other sorts of rvalues.
This is a meta-issue to cover the various cases. As PRs come in, I can check things off. Here is a list. In practice, all of the issues boil down to needing to verify various trait requirements, so the main step here will be building a subroutine for checking that a given trait reference is satisfied at a particular location (somewhat similar to normalize
-- instructions to come shortly).
-
Rvalue::Use(Operand)
--let y = x
- Nothing to do here, I think. added by @arielb1 verify that the operand is
Sized
? Do that for every operand?
- Nothing to do here, I think. added by @arielb1 verify that the operand is
-
Rvalue::Repeat(Operand, ConstUsize)
--let y = [x; N]
- We must check that the operand is
Copy
.
- We must check that the operand is
-
Rvalue::Ref(Region, BorrowKind, Lvalue)
--let y = &x
- The only special rules here are region-specific -- e.g., reborrowing constraints -- so we'll let the NLL region inference handle them.
-
Rvalue::Len(X)
- No special rules.
-
Rvalue::Cast(CastKind, Operand, Ty)
, let's break this down byCastKind
:-
Misc
-- some form of bitcast I think, no action needed -
ReifyFnPointer
- added by @arielb1 the signatures must match -
ClosureFnPointer
- added by @arielb1 the signatures must match -
UnsafeFnPointer
- added by @arielb1 the signatures must match -
Unsize
- I think we should verify a trait obligation here, something likeT: Unsize<U>
whereT is the operand's type and
U` is the target type. Have to double check this. - all these cases are handled in Check other rvalues nikomatsakis/rust#19
-
-
Rvalue::BinaryOp(..)
-- built-in binary operators. Probably we should check that e.g. the LHS and RHS are of the same type, but I'm not sure if that must be true and it doesn't really affect NLL anyhow. Leave it for now. -
Rvalue::CheckedBinaryOp(..)
-- as above. -
Rvalue::UnaryOp(..)
-- as above. -
Rvalue::Discriminant(..)
-- no special rule. -
Rvalue::NullaryOp(..)
---
sizeof
should require that the type is sized -
box
the same
-