Skip to content

Commit 5e0fab6

Browse files
committed
use ConstantKind::Val in StaticRef
1 parent 6bf3008 commit 5e0fab6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/rustc_mir_build/src/build/expr/as_constant.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2727
Constant { span, user_ty, literal: literal.into() }
2828
}
2929
ExprKind::StaticRef { literal, .. } => {
30-
Constant { span, user_ty: None, literal: literal.into() }
30+
let const_val = literal.val.try_to_value().unwrap_or_else(|| {
31+
bug!("expected `ConstKind::Value`, but found {:?}", literal.val)
32+
});
33+
let literal = ConstantKind::Val(const_val, literal.ty);
34+
35+
Constant { span, user_ty: None, literal }
3136
}
3237
ExprKind::ConstBlock { value } => {
3338
Constant { span: span, user_ty: None, literal: value.into() }

0 commit comments

Comments
 (0)