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() {}