Rollup merge of #120402 - compiler-errors:async-closure-def-tree, r=cjgillot
Make the coroutine def id of an async closure the child of the closure def id Adjust def collection to make the (inner) coroutine returned by an async closure be a def id child of the (outer) closure. This makes it easy to map from coroutine -> closure by using `tcx.parent`, since currently it's not trivial to do this.
This commit is contained in:
commit
a44b134770
3 changed files with 43 additions and 6 deletions
|
@ -289,12 +289,18 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
|
|||
// we must create two defs.
|
||||
let closure_def = self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span);
|
||||
match closure.coroutine_kind {
|
||||
Some(coroutine_kind) => self.create_def(
|
||||
coroutine_kind.closure_id(),
|
||||
kw::Empty,
|
||||
DefKind::Closure,
|
||||
expr.span,
|
||||
),
|
||||
Some(coroutine_kind) => {
|
||||
self.with_parent(closure_def, |this| {
|
||||
let coroutine_def = this.create_def(
|
||||
coroutine_kind.closure_id(),
|
||||
kw::Empty,
|
||||
DefKind::Closure,
|
||||
expr.span,
|
||||
);
|
||||
this.with_parent(coroutine_def, |this| visit::walk_expr(this, expr));
|
||||
});
|
||||
return;
|
||||
}
|
||||
None => closure_def,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue