From 5ac268c43557102dabcd3dc45b2bcaf01cb228ee Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Mon, 5 Oct 2020 00:25:51 +0200 Subject: [PATCH] do not lower patterns in impl Trait --- compiler/rustc_ast_lowering/src/lib.rs | 5 +++++ src/test/ui/impl-trait/closure-in-impl-trait.rs | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/test/ui/impl-trait/closure-in-impl-trait.rs 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() -> impl Iterator { + std::iter::empty() +} + +fn ok() -> Box> { + Box::new(std::iter::empty()) +} + +fn main() { + for _item in ok::() {} + for _item in bug::() {} +}