Skip to content

Commit 1bf0993

Browse files
committed
Group the try_eval functions before the eval functions
1 parent ef66bf0 commit 1bf0993

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/librustc_middle/ty/consts.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ impl<'tcx> Const<'tcx> {
163163
self.val.eval(tcx, param_env).try_to_bits(size)
164164
}
165165

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+
166176
#[inline]
167177
/// Tries to evaluate the constant if it is `Unevaluated`. If that doesn't succeed, return the
168178
/// unevaluated constant.
@@ -177,16 +187,6 @@ impl<'tcx> Const<'tcx> {
177187
}
178188
}
179189

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-
190190
#[inline]
191191
/// Panics if the value cannot be evaluated or doesn't contain a valid integer of the given type.
192192
pub fn eval_bits(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>) -> u128 {

0 commit comments

Comments
 (0)