From 7bafb5704d9727b3897f086d9f159e62bc40ce42 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 23 Apr 2020 18:14:01 -0300 Subject: [PATCH] normalize field projection ty to fix broken MIR issue --- src/librustc_mir/borrow_check/type_check/mod.rs | 1 + src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/librustc_mir/borrow_check/type_check/mod.rs b/src/librustc_mir/borrow_check/type_check/mod.rs index 796efd2bab9..8ed5993acbb 100644 --- a/src/librustc_mir/borrow_check/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/type_check/mod.rs @@ -686,6 +686,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { let fty = self.sanitize_type(place, fty); match self.field_ty(place, base, field, location) { Ok(ty) => { + let ty = self.cx.normalize(ty, location); if let Err(terr) = self.cx.eq_types( ty, fty, diff --git a/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs b/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs index 07af8310424..9d44aa1361c 100644 --- a/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs +++ b/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs @@ -7,6 +7,7 @@ fn init_hash(_: &mut [u8; HASH_LEN]) {} fn foo<'a>() -> &'a () { Hash([0; HASH_LEN]); init_hash(&mut [0; HASH_LEN]); + let (_array,) = ([0; HASH_LEN],); &() }