From c59d33a063c34cf2b5da440947acb158b3755b99 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 4 Oct 2019 14:20:57 +0200 Subject: [PATCH 1/3] Add some missing normalization calls to fix #63154 --- src/librustc_mir/borrow_check/nll/type_check/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index b24ba596d7e93..60dfc43def792 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -1378,7 +1378,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { }; let place_ty = place.ty(body, tcx).ty; + let place_ty = self.normalize(place_ty, location); let rv_ty = rv.ty(body, tcx); + let rv_ty = self.normalize(rv_ty, location); if let Err(terr) = self.sub_types_or_anon(rv_ty, place_ty, location.to_locations(), category) { @@ -1654,6 +1656,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { match *destination { Some((ref dest, _target_block)) => { let dest_ty = dest.ty(body, tcx).ty; + let dest_ty = self.normalize(dest_ty, term_location); let category = match *dest { Place { base: PlaceBase::Local(RETURN_PLACE), From 6dd86b411f08b3287ea565b41582641d496b66bf Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 4 Oct 2019 14:21:12 +0200 Subject: [PATCH 2/3] Regression test for #63154. --- src/test/ui/nll/issue-63154-normalize.rs | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/ui/nll/issue-63154-normalize.rs diff --git a/src/test/ui/nll/issue-63154-normalize.rs b/src/test/ui/nll/issue-63154-normalize.rs new file mode 100644 index 0000000000000..2c18dc5d8e09a --- /dev/null +++ b/src/test/ui/nll/issue-63154-normalize.rs @@ -0,0 +1,34 @@ +// Regression test for rust-lang/rust#63154 +// +// Before, we would ICE after faiing to normalize the destination type +// when checking call destinations and also when checking MIR +// assignment statements. + +// check-pass + +trait HasAssocType { + type Inner; +} + +impl HasAssocType for () { + type Inner = (); +} + +trait Tr: Fn(I) -> Option {} +impl Option> Tr for Q {} + +fn f() -> impl Tr { + |_| None +} + +fn g(f: impl Tr) -> impl Tr { + f +} + +fn h() { + g(f())(()); +} + +fn main() { + h(); +} From 00bf29bded074ee20460f620cad04205a33df499 Mon Sep 17 00:00:00 2001 From: Felix S Klock II Date: Mon, 7 Oct 2019 10:19:38 +0200 Subject: [PATCH 3/3] Update src/test/ui/nll/issue-63154-normalize.rs review feedback Co-Authored-By: Mazdak Farrokhzad --- src/test/ui/nll/issue-63154-normalize.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/nll/issue-63154-normalize.rs b/src/test/ui/nll/issue-63154-normalize.rs index 2c18dc5d8e09a..484c12879d33a 100644 --- a/src/test/ui/nll/issue-63154-normalize.rs +++ b/src/test/ui/nll/issue-63154-normalize.rs @@ -1,6 +1,6 @@ // Regression test for rust-lang/rust#63154 // -// Before, we would ICE after faiing to normalize the destination type +// Before, we would ICE after failing to normalize the destination type // when checking call destinations and also when checking MIR // assignment statements.