-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NLL] check other sorts of rvalues beyond aggregates #45959
Comments
Mentoring instructionsAs noted above, the main thing we need is some kind of function to check that a given trait reference is satisfied at a particular location. Let's call it fn prove(&mut self, trait_ref: TraitRef<'tcx>, location: Location) Inernally, like self.fully_perform_op(location.at_self(), |this| {
let mut selcx = traits::SelectionContext::new(this.infcx);
let cause = traits::ObligationCause::misc(this.last_span, ast::CRATE_NODE_ID);
let obligation = traits::Obligation::new(cause, this.param_env, trait_ref.to_poly_trait_ref());
if let Some(vtable) = selcx.select(&obligation)? {
Ok(InferOk { value: (), obligations: vtable.nested_obligations() })
} else {
mir_span_bug!(...) // typeck should have ensured that this will succeed
}
}).unwrap() This basically invokes the trait checker ( |
I'm taking this one, I've already talk with @nikomatsakis about it :). |
…ielb1 typeck aggregate rvalues in MIR type checker This branch is an attempt to land content by @spastorino and @Nashenas88 that was initially landed on nll-master while we waited for #45825 to land. The biggest change it contains is that it extends the MIR type-checker to also type-check MIR aggregate rvalues (at least partially). Specifically, it checks that the operands provided for each field have the right type. It does not yet check that their well-formedness predicates are met. That is #45827. It also does not check other kinds of rvalues (that is #45959). @spastorino is working on those issues now. r? @arielb1
OK, so, some notes. ReifyFnPointer. This coercion casts from the To compute the signature, we do |
Done (in nll-master) |
@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
Sized
? Do that for every operand?Rvalue::Repeat(Operand, ConstUsize)
--let y = [x; N]
Copy
.Rvalue::Ref(Region, BorrowKind, Lvalue)
--let y = &x
Rvalue::Len(X)
Rvalue::Cast(CastKind, Operand, Ty)
, let's break this down byCastKind
:Misc
-- some form of bitcast I think, no action neededReifyFnPointer
- added by @arielb1 the signatures must matchClosureFnPointer
- added by @arielb1 the signatures must matchUnsafeFnPointer
- added by @arielb1 the signatures must matchUnsize
- 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.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 sizedbox
the sameThe text was updated successfully, but these errors were encountered: