about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_ast_lowering/src/lib.rs5
-rw-r--r--src/test/ui/impl-trait/closure-in-impl-trait.rs14
2 files changed, 19 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index a28d022c661..64c034f7ec9 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -538,6 +538,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                         }
                         self.visit_fn_ret_ty(&f.decl.output)
                     }
+                    TyKind::ImplTrait(_, ref bounds) => {
+                        self.with_hir_id_owner(None, |this| {
+                            walk_list!(this, visit_param_bound, bounds);
+                        });
+                    }
                     _ => visit::walk_ty(self, t),
                 }
             }
diff --git a/src/test/ui/impl-trait/closure-in-impl-trait.rs b/src/test/ui/impl-trait/closure-in-impl-trait.rs
new file mode 100644
index 00000000000..3593a1d5c8d
--- /dev/null
+++ b/src/test/ui/impl-trait/closure-in-impl-trait.rs
@@ -0,0 +1,14 @@
+// run-pass
+#![allow(unused_must_use)]
+fn bug<T>() -> impl Iterator<Item = [(); { |x: u32| { x }; 4 }]> {
+    std::iter::empty()
+}
+
+fn ok<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> {
+    Box::new(std::iter::empty())
+}
+
+fn main() {
+    for _item in ok::<u32>() {}
+    for _item in bug::<u32>() {}
+}