Skip to content

Don't use typeck_root_def_id in codegen for finding closure's root #129716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,10 @@ impl<'tcx> TyCtxt<'tcx> {
/// Returns `true` if `def_id` refers to a definition that does not have its own
/// type-checking context, i.e. closure, coroutine or inline const.
pub fn is_typeck_child(self, def_id: DefId) -> bool {
matches!(self.def_kind(def_id), DefKind::Closure | DefKind::InlineConst)
matches!(
self.def_kind(def_id),
DefKind::Closure | DefKind::InlineConst | DefKind::SyntheticCoroutineBody
)
}

/// Returns `true` if `def_id` refers to a trait (i.e., `trait Foo { ... }`).
Expand Down
19 changes: 19 additions & 0 deletions tests/ui/async-await/async-closures/debuginfo-by-move-body.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ aux-build:block-on.rs
//@ edition: 2021
//@ build-pass
//@ compile-flags: -Cdebuginfo=2

#![feature(async_closure)]

extern crate block_on;

async fn call_once(f: impl async FnOnce()) {
f().await;
}

pub fn main() {
block_on::block_on(async {
let async_closure = async move || {};
call_once(async_closure).await;
});
}
Loading