use ConstantKind::Val in StaticRef

This commit is contained in:
b-naber 2022-02-08 12:14:44 +01:00
parent 6bf3008f07
commit 5e0fab6da5

View file

@ -27,7 +27,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Constant { span, user_ty, literal: literal.into() }
}
ExprKind::StaticRef { literal, .. } => {
Constant { span, user_ty: None, literal: literal.into() }
let const_val = literal.val.try_to_value().unwrap_or_else(|| {
bug!("expected `ConstKind::Value`, but found {:?}", literal.val)
});
let literal = ConstantKind::Val(const_val, literal.ty);
Constant { span, user_ty: None, literal }
}
ExprKind::ConstBlock { value } => {
Constant { span: span, user_ty: None, literal: value.into() }