Rollup merge of #117262 - celinval:issue-38-norm, r=oli-obk
Create a new ConstantKind variant (ZeroSized) for StableMIR ZeroSized constants can be represented as `mir::Const::Val` even if their layout is not yet known. In those cases, CrateItem::body() was crashing when trying to convert a `ConstValue::ZeroSized` into its stable counterpart `ConstantKind::Allocated`. Instead, we now map `ConstValue::ZeroSized` into a new variant: `ConstantKind::ZeroSized`. **Note:** I didn't add any new test here since we already have covering tests in our project repository which I manually confirmed that will fix the issue.
This commit is contained in:
commit
33744804fe
3 changed files with 18 additions and 6 deletions
|
@ -444,6 +444,9 @@ pub enum ConstantKind {
|
|||
Allocated(Allocation),
|
||||
Unevaluated(UnevaluatedConst),
|
||||
Param(ParamConst),
|
||||
/// Store ZST constants.
|
||||
/// We have to special handle these constants since its type might be generic.
|
||||
ZeroSized,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
|
@ -50,7 +50,7 @@ impl Visitable for Const {
|
|||
match &self.kind() {
|
||||
super::ty::ConstantKind::Allocated(alloc) => alloc.visit(visitor)?,
|
||||
super::ty::ConstantKind::Unevaluated(uv) => uv.visit(visitor)?,
|
||||
super::ty::ConstantKind::Param(_) => {}
|
||||
super::ty::ConstantKind::Param(_) | super::ty::ConstantKind::ZeroSized => {}
|
||||
}
|
||||
self.ty().visit(visitor)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue