diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-06-06 09:30:35 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2018-06-26 10:31:49 -0400 |
| commit | 9b4fe442809271b862e487e6af6cccad05771785 (patch) | |
| tree | 30c93cc9a5fcc58df224c85f0117faed73216b87 | |
| parent | 2b52793f74484c9cb69901d34627210ad3a5ba70 (diff) | |
| download | rust-9b4fe442809271b862e487e6af6cccad05771785.tar.gz rust-9b4fe442809271b862e487e6af6cccad05771785.zip | |
introduce `Eq` type-op
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/type_check/mod.rs | 6 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/type_check/type_op.rs | 22 |
2 files changed, 23 insertions, 5 deletions
diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index dd2af3f6f27..9a51ec9cce9 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -839,11 +839,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { self.fully_perform_op( locations, || format!("eq_types({:?} = {:?})", a, b), - CustomTypeOp::new(|this| { - this.infcx - .at(&ObligationCause::dummy(), this.param_env) - .eq(b, a) - }), + type_op::Eq::new(b, a) ) } diff --git a/src/librustc_mir/borrow_check/nll/type_check/type_op.rs b/src/librustc_mir/borrow_check/nll/type_check/type_op.rs index e31af735d55..3598114ed8d 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/type_op.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/type_op.rs @@ -67,3 +67,25 @@ impl<'gcx, 'tcx> TypeOp<'gcx, 'tcx> for Subtype<'tcx> { } } +pub(super) struct Eq<'tcx> { + a: Ty<'tcx>, + b: Ty<'tcx>, +} + +impl<'tcx> Eq<'tcx> { + pub(super) fn new(a: Ty<'tcx>, b: Ty<'tcx>) -> Self { + Self { a, b } + } +} + +impl<'gcx, 'tcx> TypeOp<'gcx, 'tcx> for Eq<'tcx> { + type Output = (); + + fn perform(self, type_checker: &mut TypeChecker<'_, 'gcx, 'tcx>) -> InferResult<'tcx, Self::Output> { + type_checker.infcx + .at(&ObligationCause::dummy(), type_checker.param_env) + .eq(self.a, self.b) + } +} + + |
