1
Fork 0

Auto merge of #127575 - chenyukang:yukang-fix-struct-fields-ice, r=compiler-errors

Avoid "no field" error and ICE on recovered ADT variant

Fixes https://github.com/rust-lang/rust/issues/126744
Fixes https://github.com/rust-lang/rust/issues/126344, a more general fix compared with https://github.com/rust-lang/rust/pull/127426

r? `@oli-obk`

From `@compiler-errors` 's comment https://github.com/rust-lang/rust/pull/127502#discussion_r1669538204
Seems most of the ADTs don't have taint, so maybe it's not proper to change `TyCtxt::type_of` query.
This commit is contained in:
bors 2024-07-11 03:12:38 +00:00
commit 8c39ac9ecc
10 changed files with 131 additions and 32 deletions

View file

@ -1125,7 +1125,10 @@ fn lower_variant(
vis: tcx.visibility(f.def_id),
})
.collect();
let recovered = matches!(def, hir::VariantData::Struct { recovered: Recovered::Yes(_), .. });
let recovered = match def {
hir::VariantData::Struct { recovered: Recovered::Yes(guar), .. } => Some(*guar),
_ => None,
};
ty::VariantDef::new(
ident.name,
variant_did.map(LocalDefId::to_def_id),