@@ -793,44 +793,45 @@ impl Drop for Guard {
793
793
/// We also make things panic if this type is ever implicitly dropped.
794
794
#[derive(Debug)]
795
795
#[must_use]
796
- pub struct InterpResult_ <'tcx, T> {
796
+ pub struct InterpResult <'tcx, T = () > {
797
797
res: Result<T, InterpErrorInfo<'tcx>>,
798
798
guard: Guard,
799
799
}
800
800
801
- // Type alias to be able to set a default type argument.
802
- pub type InterpResult<'tcx, T = ()> = InterpResult_<'tcx, T>;
803
-
804
- impl<'tcx, T> ops::Try for InterpResult_<'tcx, T> {
801
+ impl<'tcx, T> ops::Try for InterpResult<'tcx, T> {
805
802
type Output = T;
806
- type Residual = InterpResult_ <'tcx, convert::Infallible>;
803
+ type Residual = InterpResult <'tcx, convert::Infallible>;
807
804
808
805
#[inline]
809
806
fn from_output(output: Self::Output) -> Self {
810
- InterpResult_ ::new(Ok(output))
807
+ InterpResult ::new(Ok(output))
811
808
}
812
809
813
810
#[inline]
814
811
fn branch(self) -> ops::ControlFlow<Self::Residual, Self::Output> {
815
812
match self.disarm() {
816
813
Ok(v) => ops::ControlFlow::Continue(v),
817
- Err(e) => ops::ControlFlow::Break(InterpResult_ ::new(Err(e))),
814
+ Err(e) => ops::ControlFlow::Break(InterpResult ::new(Err(e))),
818
815
}
819
816
}
820
817
}
821
818
822
- impl<'tcx, T> ops::FromResidual for InterpResult_<'tcx, T> {
819
+ impl<'tcx, T> ops::Residual<T> for InterpResult<'tcx, convert::Infallible> {
820
+ type TryType = InterpResult<'tcx, T>;
821
+ }
822
+
823
+ impl<'tcx, T> ops::FromResidual for InterpResult<'tcx, T> {
823
824
#[inline]
824
825
#[track_caller]
825
- fn from_residual(residual: InterpResult_ <'tcx, convert::Infallible>) -> Self {
826
+ fn from_residual(residual: InterpResult <'tcx, convert::Infallible>) -> Self {
826
827
match residual.disarm() {
827
828
Err(e) => Self::new(Err(e)),
828
829
}
829
830
}
830
831
}
831
832
832
833
// Allow `yeet`ing `InterpError` in functions returning `InterpResult_`.
833
- impl<'tcx, T> ops::FromResidual<ops::Yeet<InterpErrorKind<'tcx>>> for InterpResult_ <'tcx, T> {
834
+ impl<'tcx, T> ops::FromResidual<ops::Yeet<InterpErrorKind<'tcx>>> for InterpResult <'tcx, T> {
834
835
#[inline]
835
836
fn from_residual(ops::Yeet(e): ops::Yeet<InterpErrorKind<'tcx>>) -> Self {
836
837
Self::new(Err(e.into()))
@@ -840,7 +841,7 @@ impl<'tcx, T> ops::FromResidual<ops::Yeet<InterpErrorKind<'tcx>>> for InterpResu
840
841
// Allow `?` on `Result<_, InterpError>` in functions returning `InterpResult_`.
841
842
// This is useful e.g. for `option.ok_or_else(|| err_ub!(...))`.
842
843
impl<'tcx, T, E: Into<InterpErrorInfo<'tcx>>> ops::FromResidual<Result<convert::Infallible, E>>
843
- for InterpResult_ <'tcx, T>
844
+ for InterpResult <'tcx, T>
844
845
{
845
846
#[inline]
846
847
fn from_residual(residual: Result<convert::Infallible, E>) -> Self {
@@ -863,7 +864,7 @@ impl<'tcx, T, V: FromIterator<T>> FromIterator<InterpResult<'tcx, T>> for Interp
863
864
}
864
865
}
865
866
866
- impl<'tcx, T> InterpResult_ <'tcx, T> {
867
+ impl<'tcx, T> InterpResult <'tcx, T> {
867
868
#[inline(always)]
868
869
fn new(res: Result<T, InterpErrorInfo<'tcx>>) -> Self {
869
870
Self { res, guard: Guard }
@@ -890,31 +891,31 @@ impl<'tcx, T> InterpResult_<'tcx, T> {
890
891
891
892
#[inline]
892
893
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> InterpResult<'tcx, U> {
893
- InterpResult_ ::new(self.disarm().map(f))
894
+ InterpResult ::new(self.disarm().map(f))
894
895
}
895
896
896
897
#[inline]
897
898
pub fn map_err_info(
898
899
self,
899
900
f: impl FnOnce(InterpErrorInfo<'tcx>) -> InterpErrorInfo<'tcx>,
900
901
) -> InterpResult<'tcx, T> {
901
- InterpResult_ ::new(self.disarm().map_err(f))
902
+ InterpResult ::new(self.disarm().map_err(f))
902
903
}
903
904
904
905
#[inline]
905
906
pub fn map_err_kind(
906
907
self,
907
908
f: impl FnOnce(InterpErrorKind<'tcx>) -> InterpErrorKind<'tcx>,
908
909
) -> InterpResult<'tcx, T> {
909
- InterpResult_ ::new(self.disarm().map_err(|mut e| {
910
+ InterpResult ::new(self.disarm().map_err(|mut e| {
910
911
e.0.kind = f(e.0.kind);
911
912
e
912
913
}))
913
914
}
914
915
915
916
#[inline]
916
917
pub fn inspect_err_kind(self, f: impl FnOnce(&InterpErrorKind<'tcx>)) -> InterpResult<'tcx, T> {
917
- InterpResult_ ::new(self.disarm().inspect_err(|e| f(&e.0.kind)))
918
+ InterpResult ::new(self.disarm().inspect_err(|e| f(&e.0.kind)))
918
919
}
919
920
920
921
#[inline]
@@ -937,7 +938,7 @@ impl<'tcx, T> InterpResult_<'tcx, T> {
937
938
938
939
#[inline]
939
940
pub fn and_then<U>(self, f: impl FnOnce(T) -> InterpResult<'tcx, U>) -> InterpResult<'tcx, U> {
940
- InterpResult_ ::new(self.disarm().and_then(|t| f(t).disarm()))
941
+ InterpResult ::new(self.disarm().and_then(|t| f(t).disarm()))
941
942
}
942
943
943
944
/// Returns success if both `self` and `other` succeed, while ensuring we don't
@@ -952,13 +953,13 @@ impl<'tcx, T> InterpResult_<'tcx, T> {
952
953
// Discard the other error.
953
954
drop(other.disarm());
954
955
// Return `self`.
955
- InterpResult_ ::new(Err(e))
956
+ InterpResult ::new(Err(e))
956
957
}
957
958
}
958
959
}
959
960
}
960
961
961
962
#[inline(always)]
962
963
pub fn interp_ok<'tcx, T>(x: T) -> InterpResult<'tcx, T> {
963
- InterpResult_ ::new(Ok(x))
964
+ InterpResult ::new(Ok(x))
964
965
}
0 commit comments