about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2017-08-21 14:11:57 +0300
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2017-08-21 14:11:57 +0300
commite00263438c95e1e31eb76548b1e08b81e5f50a4a (patch)
treec91e3a80f2eced3474f41664932a1a9255e19dcf
parenta7e001833e3a40ddcccbc6f6764205162c83c027 (diff)
downloadrust-e00263438c95e1e31eb76548b1e08b81e5f50a4a.tar.gz
rust-e00263438c95e1e31eb76548b1e08b81e5f50a4a.zip
register fn-ptr coercion obligations out of a snapshot
Fixes #43923.
-rw-r--r--src/librustc_typeck/check/coercion.rs3
-rw-r--r--src/test/run-pass/issue-43923.rs19
2 files changed, 20 insertions, 2 deletions
diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs
index 48671e864b2..0ec30fb26d6 100644
--- a/src/librustc_typeck/check/coercion.rs
+++ b/src/librustc_typeck/check/coercion.rs
@@ -807,8 +807,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
             let lub_ty = self.commit_if_ok(|_| {
                 self.at(cause, self.param_env)
                     .lub(prev_ty, new_ty)
-                    .map(|ok| self.register_infer_ok_obligations(ok))
-            });
+            }).map(|ok| self.register_infer_ok_obligations(ok));
 
             if lub_ty.is_ok() {
                 // We have a LUB of prev_ty and new_ty, just return it.
diff --git a/src/test/run-pass/issue-43923.rs b/src/test/run-pass/issue-43923.rs
new file mode 100644
index 00000000000..e1992e4fc50
--- /dev/null
+++ b/src/test/run-pass/issue-43923.rs
@@ -0,0 +1,19 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct A<T: ?Sized> { ptr: T }
+
+fn foo<T>(x: &A<[T]>) {}
+
+fn main() {
+    let a = foo;
+    let b = A { ptr: [a, a, a] };
+    a(&A { ptr: [()] });
+}