Skip to content

Commit 730a946

Browse files
committed
remove an unwrap
1 parent b62c38f commit 730a946

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

+8-8
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::{
@@ -2908,18 +2907,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29082907
fn eval_unevaluated_mir_constant_to_valtree(
29092908
&self,
29102909
constant: ConstOperand<'tcx>,
2911-
) -> Result<(ty::ValTree<'tcx>, Ty<'tcx>), ErrorHandled> {
2910+
) -> (ty::ValTree<'tcx>, Ty<'tcx>) {
29122911
assert!(!constant.const_.ty().has_param());
29132912
let (uv, ty) = match constant.const_ {
29142913
mir::Const::Unevaluated(uv, ty) => (uv.shrink(), ty),
29152914
mir::Const::Ty(_, c) => match c.kind() {
29162915
// A constant that came from a const generic but was then used as an argument to
29172916
// old-style simd_shuffle (passing as argument instead of as a generic param).
2918-
ty::ConstKind::Value(cv) => return Ok((cv.valtree, cv.ty)),
2917+
ty::ConstKind::Value(cv) => return (cv.valtree, cv.ty),
29192918
other => span_bug!(constant.span, "{other:#?}"),
29202919
},
29212920
mir::Const::Val(mir::ConstValue::Scalar(mir::interpret::Scalar::Int(val)), ty) => {
2922-
return Ok((ValTree::from_scalar_int(self.tcx, val), ty));
2921+
return (ValTree::from_scalar_int(self.tcx, val), ty);
29232922
}
29242923
// We should never encounter `Const::Val` unless MIR opts (like const prop) evaluate
29252924
// a constant and write that value back into `Operand`s. This could happen, but is
@@ -2932,9 +2931,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
29322931
other => span_bug!(constant.span, "{other:#?}"),
29332932
};
29342933

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

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

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

29522952
match pat.ctor() {

0 commit comments

Comments
 (0)