Skip to content

Commit

Permalink
Rollup merge of rust-lang#60527 - davidtwco:issue-60518, r=cramertj
Browse files Browse the repository at this point in the history
Fix async fn lowering ICE with APIT.

Fixes rust-lang#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
  • Loading branch information
Centril authored May 4, 2019
2 parents 10f5a36 + f346309 commit 1599877
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/librustc/hir/map/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ impl<'a> DefCollector<'a> {
visit::walk_generics(this, generics);

// Walk the generated arguments for the `async fn`.
for a in arguments {
for (i, a) in arguments.iter().enumerate() {
use visit::Visitor;
if let Some(arg) = &a.arg {
this.visit_ty(&arg.ty);
} else {
this.visit_ty(&decl.inputs[i].ty);
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/async-await/issue-60518.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// compile-pass
// edition:2018

#![feature(async_await)]

// This is a regression test to ensure that simple bindings (where replacement arguments aren't
// created during async fn lowering) that have their DefId used during HIR lowering (such as impl
// trait) are visited during def collection and thus have a DefId.

async fn foo(ws: impl Iterator<Item = ()>) {}

fn main() {}

0 comments on commit 1599877

Please sign in to comment.