From 8bf37cecf6b22b3bc14d2a9d4800a0475d6dce7a Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 26 Jul 2026 12:58:08 +0200 Subject: [PATCH] Fix decoding attributes of `SyntheticCoroutineBody` --- compiler/rustc_metadata/src/rmeta/decoder.rs | 29 +++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 91252ae6727..560d39403d4 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1432,17 +1432,26 @@ impl CrateMetadata { .attributes .get(self, id) .unwrap_or_else(|| { - // Structure and variant constructors don't have any attributes encoded for them, - // but we assume that someone passing a constructor ID actually wants to look at - // the attributes on the corresponding struct or variant. let def_key = self.def_key(id); - assert_eq!(def_key.disambiguated_data.data, DefPathData::Ctor); - let parent_id = def_key.parent.expect("no parent for a constructor"); - self.root - .tables - .attributes - .get(self, parent_id) - .expect("no encoded attributes for a structure or variant") + match def_key.disambiguated_data.data { + DefPathData::Ctor => { + // Structure and variant constructors don't have any attributes encoded for them, + // but we assume that someone passing a constructor ID actually wants to look at + // the attributes on the corresponding struct or variant. + assert_eq!(def_key.disambiguated_data.data, DefPathData::Ctor); + let parent_id = def_key.parent.expect("no parent for a constructor"); + self.root + .tables + .attributes + .get(self, parent_id) + .expect("no encoded attributes for a structure or variant") + } + DefPathData::SyntheticCoroutineBody => { + // SyntheticCoroutineBodies cannot have attributes + LazyArray::default() + } + _ => panic!("Definition key {def_key:?} of type `{:?}` did not have any attributes stored", def_key.disambiguated_data.data) + } }) .decode((self, tcx)) }