diff options
| author | bors <bors@rust-lang.org> | 2024-09-16 10:16:32 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-16 10:16:32 +0000 | 
| commit | 13b5a4e43b92cf738acad403ea56900947f9d37b (patch) | |
| tree | 6b47e74d96ccd723d992761ac567fd1602a13142 /compiler/rustc_middle/src/ty/util.rs | |
| parent | 170d6cb845c8c3f0dcec5cdd4210df9ecf990244 (diff) | |
| parent | 63405fc2b3a15194e47712b738275c6d76de6b27 (diff) | |
| download | rust-13b5a4e43b92cf738acad403ea56900947f9d37b.tar.gz rust-13b5a4e43b92cf738acad403ea56900947f9d37b.zip | |
Auto merge of #129716 - compiler-errors:closure-debuginfo, r=cjgillot
Don't use `typeck_root_def_id` in codegen for finding closure's root Generating debuginfo in codegen currently peels off all the closure-specific generics (which presumably is done because they're redundant). This doesn't currently work correctly for the bodies we synthesize for async closures's returned coroutines (#128506), leading to #129702. Specifically, `typeck_root_def_id` for some `DefKind::SyntheticCoroutineBody` just returns itself (because it loops while `is_typeck_child` is `true`, and that returns `false` for this defkind), which means we don't end up peeling off the coroutine-specific generics, and we end up encountering an otherwise unreachable `CoroutineWitness` type leading to an ICE. This PR fixes `is_typeck_child` to consider `DefKind::SyntheticCorotuineBody` to be a typeck child, fixing `typeck_root_def_id` and suppressing this debuginfo bug. Fixes #129702
Diffstat (limited to 'compiler/rustc_middle/src/ty/util.rs')
| -rw-r--r-- | compiler/rustc_middle/src/ty/util.rs | 5 | 
1 files changed, 4 insertions, 1 deletions
| diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index d70ff8258d0..a0262f12cb5 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -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 { ... }`). | 
