@@ -2110,6 +2110,22 @@ impl<'tcx> LazyConst<'tcx> {
2110
2110
pub fn unwrap_usize ( & self , tcx : TyCtxt < ' _ , ' _ , ' _ > ) -> u64 {
2111
2111
self . assert_usize ( tcx) . expect ( "expected `LazyConst` to contain a usize" )
2112
2112
}
2113
+
2114
+ pub fn type_flags ( & self ) -> TypeFlags {
2115
+ // FIXME(const_generics): incorporate substs flags.
2116
+ let flags = match self {
2117
+ LazyConst :: Unevaluated ( ..) => {
2118
+ TypeFlags :: HAS_NORMALIZABLE_PROJECTION | TypeFlags :: HAS_PROJECTION
2119
+ }
2120
+ LazyConst :: Evaluated ( c) => {
2121
+ c. type_flags ( )
2122
+ }
2123
+ } ;
2124
+
2125
+ debug ! ( "type_flags({:?}) = {:?}" , self , flags) ;
2126
+
2127
+ flags
2128
+ }
2113
2129
}
2114
2130
2115
2131
/// Typed constant value.
@@ -2225,6 +2241,33 @@ impl<'tcx> Const<'tcx> {
2225
2241
self . assert_usize ( tcx) . unwrap_or_else ( ||
2226
2242
bug ! ( "expected constant usize, got {:#?}" , self ) )
2227
2243
}
2244
+
2245
+ pub fn type_flags ( & self ) -> TypeFlags {
2246
+ let mut flags = self . ty . flags ;
2247
+
2248
+ match self . val {
2249
+ ConstValue :: Param ( _) => {
2250
+ flags |= TypeFlags :: HAS_FREE_LOCAL_NAMES ;
2251
+ flags |= TypeFlags :: HAS_PARAMS ;
2252
+ }
2253
+ ConstValue :: Infer ( infer) => {
2254
+ flags |= TypeFlags :: HAS_FREE_LOCAL_NAMES ;
2255
+ flags |= TypeFlags :: HAS_CT_INFER ;
2256
+ match infer {
2257
+ InferConst :: Fresh ( _) |
2258
+ InferConst :: Canonical ( _, _) => { }
2259
+ InferConst :: Var ( _) => {
2260
+ flags |= TypeFlags :: KEEP_IN_LOCAL_TCX ;
2261
+ }
2262
+ }
2263
+ }
2264
+ _ => { }
2265
+ }
2266
+
2267
+ debug ! ( "type_flags({:?}) = {:?}" , self , flags) ;
2268
+
2269
+ flags
2270
+ }
2228
2271
}
2229
2272
2230
2273
impl < ' tcx > serialize:: UseSpecializedDecodable for & ' tcx LazyConst < ' tcx > { }
0 commit comments