]> git.lizzy.rs Git - rust.git/commitdiff
do not lower patterns in impl Trait
authorBastian Kauschke <bastian_kauschke@hotmail.de>
Sun, 4 Oct 2020 22:25:51 +0000 (00:25 +0200)
committerBastian Kauschke <bastian_kauschke@hotmail.de>
Wed, 7 Oct 2020 08:19:04 +0000 (10:19 +0200)
compiler/rustc_ast_lowering/src/lib.rs
src/test/ui/impl-trait/closure-in-impl-trait.rs [new file with mode: 0644]

index a28d022c66139c01e2c7de0e93e821dd0ee6d064..64c034f7ec9358b5f5309f05f272988c9acf21fe 100644 (file)
@@ -538,6 +538,11 @@ fn visit_ty(&mut self, t: &'tcx Ty) {
                         }
                         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 (file)
index 0000000..3593a1d
--- /dev/null
@@ -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>() {}
+}