Skip to content

Commit c3b4c9b

Browse files
committed
remove an unwrap
1 parent 9b600fb commit c3b4c9b

File tree

1 file changed

+8
-8
lines changed
  • compiler/rustc_mir_build/src/builder/matches

1 file changed

+8
-8
lines changed

compiler/rustc_mir_build/src/builder/matches/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use tracing::{debug, instrument};
2727

2828
use crate::builder::ForGuard::{self, OutsideGuard, RefWithinGuard};
2929
use crate::builder::expr::as_place::PlaceBuilder;
30-
use crate::builder::interpret::ErrorHandled;
3130
use crate::builder::matches::user_ty::ProjectedUserTypesNode;
3231
use crate::builder::scope::DropKind;
3332
use crate::builder::{
@@ -2909,18 +2908,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29092908
fn eval_unevaluated_mir_constant_to_valtree(
29102909
&self,
29112910
constant: ConstOperand<'tcx>,
2912-
) -> Result<(ty::ValTree<'tcx>, Ty<'tcx>), ErrorHandled> {
2911+
) -> (ty::ValTree<'tcx>, Ty<'tcx>) {
29132912
assert!(!constant.const_.ty().has_param());
29142913
let (uv, ty) = match constant.const_ {
29152914
mir::Const::Unevaluated(uv, ty) => (uv.shrink(), ty),
29162915
mir::Const::Ty(_, c) => match c.kind() {
29172916
// A constant that came from a const generic but was then used as an argument to
29182917
// old-style simd_shuffle (passing as argument instead of as a generic param).
2919-
ty::ConstKind::Value(cv) => return Ok((cv.valtree, cv.ty)),
2918+
ty::ConstKind::Value(cv) => return (cv.valtree, cv.ty),
29202919
other => span_bug!(constant.span, "{other:#?}"),
29212920
},
29222921
mir::Const::Val(mir::ConstValue::Scalar(mir::interpret::Scalar::Int(val)), ty) => {
2923-
return Ok((ValTree::from_scalar_int(self.tcx, val), ty));
2922+
return (ValTree::from_scalar_int(self.tcx, val), ty);
29242923
}
29252924
// We should never encounter `Const::Val` unless MIR opts (like const prop) evaluate
29262925
// a constant and write that value back into `Operand`s. This could happen, but is
@@ -2933,9 +2932,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29332932
other => span_bug!(constant.span, "{other:#?}"),
29342933
};
29352934

2936-
match self.tcx.const_eval_resolve_for_typeck(self.typing_env(), uv, constant.span)? {
2937-
Ok(valtree) => Ok((valtree, ty)),
2938-
Err(ty) => bug!("could not convert {ty:?} to a valtree"),
2935+
match self.tcx.const_eval_resolve_for_typeck(self.typing_env(), uv, constant.span) {
2936+
Ok(Ok(valtree)) => (valtree, ty),
2937+
Ok(Err(ty)) => span_bug!(constant.span, "could not convert {ty:?} to a valtree"),
2938+
Err(_) => span_bug!(constant.span, "unable to evaluate this constant"),
29392939
}
29402940
}
29412941

@@ -2947,7 +2947,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29472947
use rustc_pattern_analysis::constructor::{IntRange, MaybeInfiniteInt};
29482948
use rustc_pattern_analysis::rustc::Constructor;
29492949

2950-
let (valtree, ty) = self.eval_unevaluated_mir_constant_to_valtree(constant).unwrap();
2950+
let (valtree, ty) = self.eval_unevaluated_mir_constant_to_valtree(constant);
29512951
assert!(!ty.has_param());
29522952

29532953
match pat.ctor() {

0 commit comments

Comments
 (0)