From f346309562c1b894a822839bfddf7291993163a5 Mon Sep 17 00:00:00 2001 From: David Wood Date: Fri, 3 May 2019 22:36:35 +0100 Subject: [PATCH] Fix async fn lowering ICE with APIT. This commit 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`. --- src/librustc/hir/map/def_collector.rs | 4 +++- src/test/ui/async-await/issue-60518.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/async-await/issue-60518.rs diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index 78de85398594e..7f1352095d936 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -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); } } diff --git a/src/test/ui/async-await/issue-60518.rs b/src/test/ui/async-await/issue-60518.rs new file mode 100644 index 0000000000000..f603c5bd3f946 --- /dev/null +++ b/src/test/ui/async-await/issue-60518.rs @@ -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) {} + +fn main() {}