about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-05-04 09:21:34 +0200
committerGitHub <noreply@github.com>2019-05-04 09:21:34 +0200
commit1599877c7e246dc7e7cca4830734bde7d93a3c1b (patch)
tree0fe4a4b339119c497a066dca4c9229b3cbde56d7
parent10f5a36664825bb22ae7132a31d5749fd84ac912 (diff)
parentf346309562c1b894a822839bfddf7291993163a5 (diff)
downloadrust-1599877c7e246dc7e7cca4830734bde7d93a3c1b.tar.gz
rust-1599877c7e246dc7e7cca4830734bde7d93a3c1b.zip
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
-rw-r--r--src/librustc/hir/map/def_collector.rs4
-rw-r--r--src/test/ui/async-await/issue-60518.rs12
2 files changed, 15 insertions, 1 deletions
diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs
index 78de8539859..7f1352095d9 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 00000000000..f603c5bd3f9
--- /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<Item = ()>) {}
+
+fn main() {}