From 1bf09933ed46d2063128218b9474430ffc694aff Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Mon, 13 Jul 2020 19:07:37 +0200 Subject: [PATCH] Group the try_eval functions before the eval functions --- src/librustc_middle/ty/consts.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/librustc_middle/ty/consts.rs b/src/librustc_middle/ty/consts.rs index d861b9323677..f3a863c3fce6 100644 --- a/src/librustc_middle/ty/consts.rs +++ b/src/librustc_middle/ty/consts.rs @@ -163,6 +163,16 @@ impl<'tcx> Const<'tcx> { self.val.eval(tcx, param_env).try_to_bits(size) } + #[inline] + pub fn try_eval_bool(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Option { + self.val.eval(tcx, param_env).try_to_bool() + } + + #[inline] + pub fn try_eval_usize(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Option { + self.val.eval(tcx, param_env).try_to_machine_usize(tcx) + } + #[inline] /// Tries to evaluate the constant if it is `Unevaluated`. If that doesn't succeed, return the /// unevaluated constant. @@ -177,16 +187,6 @@ impl<'tcx> Const<'tcx> { } } - #[inline] - pub fn try_eval_bool(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Option { - self.val.eval(tcx, param_env).try_to_bool() - } - - #[inline] - pub fn try_eval_usize(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Option { - self.val.eval(tcx, param_env).try_to_machine_usize(tcx) - } - #[inline] /// Panics if the value cannot be evaluated or doesn't contain a valid integer of the given type. pub fn eval_bits(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>) -> u128 {