Explain how we encode enums at the encoding site
This commit is contained in:
parent
f646c1e434
commit
c01c49430c
1 changed files with 4 additions and 3 deletions
|
@ -69,10 +69,11 @@ fn const_to_valtree_inner<'tcx>(
|
||||||
let field = ecx.mplace_field(&place, i).unwrap();
|
let field = ecx.mplace_field(&place, i).unwrap();
|
||||||
const_to_valtree_inner(ecx, &field)
|
const_to_valtree_inner(ecx, &field)
|
||||||
});
|
});
|
||||||
|
// For enums, we preped their variant index before the variant's fields so we can figure out
|
||||||
|
// the variant again when just seeing a valtree.
|
||||||
|
let branches = variant.into_iter().chain(fields);
|
||||||
Some(ty::ValTree::Branch(
|
Some(ty::ValTree::Branch(
|
||||||
ecx.tcx
|
ecx.tcx.arena.alloc_from_iter(branches.collect::<Option<Vec<_>>>()?),
|
||||||
.arena
|
|
||||||
.alloc_from_iter(variant.into_iter().chain(fields).collect::<Option<Vec<_>>>()?),
|
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
match place.layout.ty.kind() {
|
match place.layout.ty.kind() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue