Skip to content

Commit 5ac268c

Browse files
committed
do not lower patterns in impl Trait
1 parent 8f13705 commit 5ac268c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
538538
}
539539
self.visit_fn_ret_ty(&f.decl.output)
540540
}
541+
TyKind::ImplTrait(_, ref bounds) => {
542+
self.with_hir_id_owner(None, |this| {
543+
walk_list!(this, visit_param_bound, bounds);
544+
});
545+
}
541546
_ => visit::walk_ty(self, t),
542547
}
543548
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// run-pass
2+
#![allow(unused_must_use)]
3+
fn bug<T>() -> impl Iterator<Item = [(); { |x: u32| { x }; 4 }]> {
4+
std::iter::empty()
5+
}
6+
7+
fn ok<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> {
8+
Box::new(std::iter::empty())
9+
}
10+
11+
fn main() {
12+
for _item in ok::<u32>() {}
13+
for _item in bug::<u32>() {}
14+
}

0 commit comments

Comments
 (0)