From: Bastian Kauschke Date: Sun, 4 Oct 2020 22:25:51 +0000 (+0200) Subject: do not lower patterns in impl Trait X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=5ac268c43557102dabcd3dc45b2bcaf01cb228ee;p=rust.git do not lower patterns in impl Trait --- 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 @@ 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 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::() {} +}