File tree 1 file changed +10
-10
lines changed
1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,16 @@ impl<'tcx> Const<'tcx> {
163
163
self . val . eval ( tcx, param_env) . try_to_bits ( size)
164
164
}
165
165
166
+ #[ inline]
167
+ pub fn try_eval_bool ( & self , tcx : TyCtxt < ' tcx > , param_env : ParamEnv < ' tcx > ) -> Option < bool > {
168
+ self . val . eval ( tcx, param_env) . try_to_bool ( )
169
+ }
170
+
171
+ #[ inline]
172
+ pub fn try_eval_usize ( & self , tcx : TyCtxt < ' tcx > , param_env : ParamEnv < ' tcx > ) -> Option < u64 > {
173
+ self . val . eval ( tcx, param_env) . try_to_machine_usize ( tcx)
174
+ }
175
+
166
176
#[ inline]
167
177
/// Tries to evaluate the constant if it is `Unevaluated`. If that doesn't succeed, return the
168
178
/// unevaluated constant.
@@ -177,16 +187,6 @@ impl<'tcx> Const<'tcx> {
177
187
}
178
188
}
179
189
180
- #[ inline]
181
- pub fn try_eval_bool ( & self , tcx : TyCtxt < ' tcx > , param_env : ParamEnv < ' tcx > ) -> Option < bool > {
182
- self . val . eval ( tcx, param_env) . try_to_bool ( )
183
- }
184
-
185
- #[ inline]
186
- pub fn try_eval_usize ( & self , tcx : TyCtxt < ' tcx > , param_env : ParamEnv < ' tcx > ) -> Option < u64 > {
187
- self . val . eval ( tcx, param_env) . try_to_machine_usize ( tcx)
188
- }
189
-
190
190
#[ inline]
191
191
/// Panics if the value cannot be evaluated or doesn't contain a valid integer of the given type.
192
192
pub fn eval_bits ( & self , tcx : TyCtxt < ' tcx > , param_env : ParamEnv < ' tcx > , ty : Ty < ' tcx > ) -> u128 {
You can’t perform that action at this time.
0 commit comments