borrow_check/type_check: normalize Aggregate and Call operands.

This commit is contained in:
Eduard-Mihai Burtescu 2020-04-04 21:26:34 +03:00
parent ad1617bb49
commit 8989029476
2 changed files with 17 additions and 0 deletions

View file

@ -1760,6 +1760,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
for (n, (fn_arg, op_arg)) in sig.inputs().iter().zip(args).enumerate() {
let op_arg_ty = op_arg.ty(body, self.tcx());
let op_arg_ty = self.normalize(op_arg_ty, term_location);
let category = if from_hir_call {
ConstraintCategory::CallArgument
} else {
@ -2402,6 +2403,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
};
let operand_ty = operand.ty(body, tcx);
let operand_ty = self.normalize(operand_ty, location);
if let Err(terr) = self.sub_types(
operand_ty,

View file

@ -0,0 +1,15 @@
// run-pass
const HASH_LEN: usize = 20;
struct Hash([u8; HASH_LEN]);
fn init_hash(_: &mut [u8; HASH_LEN]) {}
fn foo<'a>() -> &'a () {
Hash([0; HASH_LEN]);
init_hash(&mut [0; HASH_LEN]);
&()
}
fn main() {
foo();
}