Skip to content

Commit 1599877

Browse files
authored
Rollup merge of #60527 - davidtwco:issue-60518, r=cramertj
Fix async fn lowering ICE with APIT. Fixes #60518. This PR fixes an ICE where simple bindings (which aren't replaced with replacement arguments during async fn lowering) were not being visited in the def collector and thus caused an ICE during HIR lowering for types that use their `DefId` at that point - such as `impl Trait`. r? @cramertj
2 parents 10f5a36 + f346309 commit 1599877

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/librustc/hir/map/def_collector.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ impl<'a> DefCollector<'a> {
9292
visit::walk_generics(this, generics);
9393

9494
// Walk the generated arguments for the `async fn`.
95-
for a in arguments {
95+
for (i, a) in arguments.iter().enumerate() {
9696
use visit::Visitor;
9797
if let Some(arg) = &a.arg {
9898
this.visit_ty(&arg.ty);
99+
} else {
100+
this.visit_ty(&decl.inputs[i].ty);
99101
}
100102
}
101103

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// compile-pass
2+
// edition:2018
3+
4+
#![feature(async_await)]
5+
6+
// This is a regression test to ensure that simple bindings (where replacement arguments aren't
7+
// created during async fn lowering) that have their DefId used during HIR lowering (such as impl
8+
// trait) are visited during def collection and thus have a DefId.
9+
10+
async fn foo(ws: impl Iterator<Item = ()>) {}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)