Merge pull request #4100 from rust-lang/rustup-2024-12-20

Automatic Rustup
This commit is contained in:
Ralf Jung 2024-12-20 06:29:50 +00:00 committed by GitHub
commit e693a9988b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View file

@ -813,7 +813,7 @@ impl Evaluator<'_> {
ProjectionElem::Field(Either::Left(f)) => {
let layout = self.layout(&prev_ty)?;
let variant_layout = match &layout.variants {
Variants::Single { .. } => &layout,
Variants::Single { .. } | Variants::Empty => &layout,
Variants::Multiple { variants, .. } => {
&variants[match f.parent {
hir_def::VariantId::EnumVariantId(it) => {
@ -1638,6 +1638,7 @@ impl Evaluator<'_> {
return Ok(0);
};
match &layout.variants {
Variants::Empty => unreachable!(),
Variants::Single { index } => {
let r = self.const_eval_discriminant(self.db.enum_data(e).variants[index.0].0)?;
Ok(r)
@ -1800,7 +1801,7 @@ impl Evaluator<'_> {
}
let layout = self.layout_adt(adt, subst)?;
Ok(match &layout.variants {
Variants::Single { .. } => (layout.size.bytes_usize(), layout, None),
Variants::Single { .. } | Variants::Empty => (layout.size.bytes_usize(), layout, None),
Variants::Multiple { variants, tag, tag_encoding, .. } => {
let enum_variant_id = match it {
VariantId::EnumVariantId(it) => it,

View file

@ -334,6 +334,7 @@ pub(crate) fn detect_variant_from_bytes<'a>(
e: EnumId,
) -> Option<(EnumVariantId, &'a Layout)> {
let (var_id, var_layout) = match &layout.variants {
hir_def::layout::Variants::Empty => unreachable!(),
hir_def::layout::Variants::Single { index } => {
(db.enum_data(e).variants[index.0].0, layout)
}