From 7f318256c908be1df494ae16c2d2dad94e9f66a7 Mon Sep 17 00:00:00 2001 From: klensy Date: Thu, 12 May 2022 19:26:52 +0300 Subject: [PATCH] fix clippy expect_fun_call --- compiler/rustc_const_eval/src/const_eval/valtrees.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_const_eval/src/const_eval/valtrees.rs b/compiler/rustc_const_eval/src/const_eval/valtrees.rs index 374179d0cc24d..f57f25c19f90f 100644 --- a/compiler/rustc_const_eval/src/const_eval/valtrees.rs +++ b/compiler/rustc_const_eval/src/const_eval/valtrees.rs @@ -58,7 +58,9 @@ fn slice_branches<'tcx>( ecx: &CompileTimeEvalContext<'tcx, 'tcx>, place: &MPlaceTy<'tcx>, ) -> Option> { - let n = place.len(&ecx.tcx.tcx).expect(&format!("expected to use len of place {:?}", place)); + let n = place + .len(&ecx.tcx.tcx) + .unwrap_or_else(|_| panic!("expected to use len of place {:?}", place)); let branches = (0..n).map(|i| { let place_elem = ecx.mplace_index(place, i).unwrap(); const_to_valtree_inner(ecx, &place_elem)