about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-10-13 03:37:25 +0000
committerbors <bors@rust-lang.org>2019-10-13 03:37:25 +0000
commit3da6836cc9fd654fa204fe7e113973f7b5b3e5f6 (patch)
tree2b4a2f46d6e4a5bee73b128e6c4431eea91a57c1
parent80b861bed17ba2ce001911f78a5316f56466642f (diff)
parent00bf29bded074ee20460f620cad04205a33df499 (diff)
downloadrust-3da6836cc9fd654fa204fe7e113973f7b5b3e5f6.tar.gz
rust-3da6836cc9fd654fa204fe7e113973f7b5b3e5f6.zip
Auto merge of #65099 - pnkfelix:issue-63154-needed-more-normalize, r=nagisa
MIR typeck needed more normalize

Add some missing normalization calls (@nagisa [was right](https://github.com/rust-lang/rust/issues/63154#issuecomment-517305589)).

Fix #63154
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/mod.rs3
-rw-r--r--src/test/ui/nll/issue-63154-normalize.rs34
2 files changed, 37 insertions, 0 deletions
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 1563a27250e..ed639e8eee7 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
@@ -1396,7 +1396,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)
                 {
@@ -1672,6 +1674,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),
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 00000000000..484c12879d3
--- /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 failing 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<I, T>: Fn(I) -> Option<T> {}
+impl<I, T, Q: Fn(I) -> Option<T>> Tr<I, T> for Q {}
+
+fn f<T: HasAssocType>() -> impl Tr<T, T::Inner> {
+    |_| None
+}
+
+fn g<T, Y>(f: impl Tr<T, Y>) -> impl Tr<T, Y> {
+    f
+}
+
+fn h() {
+    g(f())(());
+}
+
+fn main() {
+    h();
+}