diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-10-05 00:25:51 +0200 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-10-07 10:19:04 +0200 |
| commit | 5ac268c43557102dabcd3dc45b2bcaf01cb228ee (patch) | |
| tree | 67ce4a4ff7b4444eaed2aea70bb8c8c1ef97aa2e | |
| parent | 8f13705e3b5cb563cee1c43446c0a682514a6f15 (diff) | |
| download | rust-5ac268c43557102dabcd3dc45b2bcaf01cb228ee.tar.gz rust-5ac268c43557102dabcd3dc45b2bcaf01cb228ee.zip | |
do not lower patterns in impl Trait
| -rw-r--r-- | compiler/rustc_ast_lowering/src/lib.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/closure-in-impl-trait.rs | 14 |
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>() {} +} |
