diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2020-07-13 19:07:37 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2020-07-16 10:03:28 +0200 |
| commit | 1bf09933ed46d2063128218b9474430ffc694aff (patch) | |
| tree | da7de183a459de2f6c4da624f62fe2ff7df37ca4 | |
| parent | ef66bf067b4614cc57f07bcdc186b6344a0bdc6b (diff) | |
| download | rust-1bf09933ed46d2063128218b9474430ffc694aff.tar.gz rust-1bf09933ed46d2063128218b9474430ffc694aff.zip | |
Group the try_eval functions before the eval functions
| -rw-r--r-- | src/librustc_middle/ty/consts.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/librustc_middle/ty/consts.rs b/src/librustc_middle/ty/consts.rs index d861b932367..f3a863c3fce 100644 --- a/src/librustc_middle/ty/consts.rs +++ b/src/librustc_middle/ty/consts.rs @@ -164,6 +164,16 @@ impl<'tcx> Const<'tcx> { } #[inline] + pub fn try_eval_bool(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Option<bool> { + self.val.eval(tcx, param_env).try_to_bool() + } + + #[inline] + pub fn try_eval_usize(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Option<u64> { + 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. pub fn eval(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> &Const<'tcx> { @@ -178,16 +188,6 @@ impl<'tcx> Const<'tcx> { } #[inline] - pub fn try_eval_bool(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Option<bool> { - self.val.eval(tcx, param_env).try_to_bool() - } - - #[inline] - pub fn try_eval_usize(&self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Option<u64> { - 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 { self.try_eval_bits(tcx, param_env, ty) |
