2
2
3
3
use ty:: layout:: { Align , HasDataLayout , Size } ;
4
4
use ty;
5
+ use ty:: subst:: Substs ;
6
+ use hir:: def_id:: DefId ;
5
7
6
8
use super :: { EvalResult , Pointer , PointerArithmetic , Allocation } ;
7
9
8
10
/// Represents a constant value in Rust. ByVal and ScalarPair are optimizations which
9
11
/// matches Value's optimizations for easy conversions between these two types
10
- #[ derive( Clone , Copy , Debug , Eq , PartialEq , PartialOrd , Ord , RustcEncodable , RustcDecodable , Hash ) ]
12
+ #[ derive( Copy , Clone , Debug , Eq , PartialEq , PartialOrd , Ord , RustcEncodable , RustcDecodable , Hash ) ]
11
13
pub enum ConstValue < ' tcx > {
14
+ /// Never returned from the `const_eval` query, but the HIR contains these frequently in order
15
+ /// to allow HIR creation to happen for everything before needing to be able to run constant
16
+ /// evaluation
17
+ Unevaluated ( DefId , & ' tcx Substs < ' tcx > ) ,
12
18
/// Used only for types with layout::abi::Scalar ABI and ZSTs which use Scalar::undef()
13
19
Scalar ( Scalar ) ,
14
20
/// Used only for types with layout::abi::ScalarPair
@@ -30,6 +36,7 @@ impl<'tcx> ConstValue<'tcx> {
30
36
#[ inline]
31
37
pub fn to_byval_value ( & self ) -> Option < Value > {
32
38
match * self {
39
+ ConstValue :: Unevaluated ( ..) |
33
40
ConstValue :: ByRef ( ..) => None ,
34
41
ConstValue :: ScalarPair ( a, b) => Some ( Value :: ScalarPair ( a, b) ) ,
35
42
ConstValue :: Scalar ( val) => Some ( Value :: Scalar ( val) ) ,
@@ -44,7 +51,8 @@ impl<'tcx> ConstValue<'tcx> {
44
51
#[ inline]
45
52
pub fn to_scalar ( & self ) -> Option < Scalar > {
46
53
match * self {
47
- ConstValue :: ByRef ( ..) => None ,
54
+ ConstValue :: Unevaluated ( ..) |
55
+ ConstValue :: ByRef ( ..) |
48
56
ConstValue :: ScalarPair ( ..) => None ,
49
57
ConstValue :: Scalar ( val) => Some ( val) ,
50
58
}
0 commit comments