about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-09-29 15:07:59 +0000
committerbors <bors@rust-lang.org>2018-09-29 15:07:59 +0000
commiteb50e75729bce449272ffb3bfbca2f7234f2ae13 (patch)
treee77070558ed0b335adc2d9f60776fc9dcc212b0a /src/test
parent9653f790333d1270f36f1614e85d8a7b54193e75 (diff)
parentbcfdfe4e5007867dcd2e80a36921dfc538aae9d9 (diff)
downloadrust-eb50e75729bce449272ffb3bfbca2f7234f2ae13.tar.gz
rust-eb50e75729bce449272ffb3bfbca2f7234f2ae13.zip
Auto merge of #54599 - nikomatsakis:issue-54593-impl-Trait, r=eddyb
use closure def-id in returns, but base def-id in locals

The refactorings to  handle `let x: impl Trait`  wound up breaking `impl Trait` in closure return types. I think there are some deeper problems with the code in question, but this a least should make @eddyb's example work.

Fixes #54593

r? @eddyb
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/impl-trait/closure-calling-parent-fn.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/closure-calling-parent-fn.rs b/src/test/ui/impl-trait/closure-calling-parent-fn.rs
new file mode 100644
index 00000000000..cb5f78bd6fc
--- /dev/null
+++ b/src/test/ui/impl-trait/closure-calling-parent-fn.rs
@@ -0,0 +1,14 @@
+#![feature(nll)]
+
+// Regression test for #54593: the MIR type checker was going wrong
+// when a closure returns the `impl Copy` from its parent fn. It was
+// (incorrectly) replacing the `impl Copy` in its return type with the
+// hidden type (`()`) but that type resulted from a recursive call to
+// `foo` and hence is treated opaquely within the closure body.  This
+// resulted in a failed subtype relationship.
+//
+// run-pass
+
+fn foo() -> impl Copy { || foo(); }
+fn bar() -> impl Copy { || bar(); }
+fn main() { }