diff options
| author | lcnr <rust@lcnr.de> | 2022-11-15 14:05:30 +0100 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2022-11-15 14:13:47 +0100 |
| commit | b2e6d08e3f88aee01d84412e0ea8369c48e0f419 (patch) | |
| tree | 4b2a8cb084f2f8cc3ee86164730987cbb56d4a21 /compiler/rustc_trait_selection/src/traits | |
| parent | f5f67618e25be01d8580e3d49033e0f39a3e7781 (diff) | |
| download | rust-b2e6d08e3f88aee01d84412e0ea8369c48e0f419.tar.gz rust-b2e6d08e3f88aee01d84412e0ea8369c48e0f419.zip | |
use `ocx` type relation routines
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/engine.rs | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index ae29c9f5617..f8346e515d7 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -125,6 +125,21 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> { .map(|infer_ok| self.register_infer_ok_obligations(infer_ok)) } + /// Checks whether `expected` is a subtype of `actual`: `expected <: actual`. + pub fn sub<T: ToTrace<'tcx>>( + &self, + cause: &ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + expected: T, + actual: T, + ) -> Result<(), TypeError<'tcx>> { + self.infcx + .at(cause, param_env) + .sup(expected, actual) + .map(|infer_ok| self.register_infer_ok_obligations(infer_ok)) + } + + /// Checks whether `expected` is a supertype of `actual`: `expected :> actual`. pub fn sup<T: ToTrace<'tcx>>( &self, cause: &ObligationCause<'tcx>, @@ -132,13 +147,10 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> { expected: T, actual: T, ) -> Result<(), TypeError<'tcx>> { - match self.infcx.at(cause, param_env).sup(expected, actual) { - Ok(InferOk { obligations, value: () }) => { - self.register_obligations(obligations); - Ok(()) - } - Err(e) => Err(e), - } + self.infcx + .at(cause, param_env) + .sup(expected, actual) + .map(|infer_ok| self.register_infer_ok_obligations(infer_ok)) } pub fn select_where_possible(&self) -> Vec<FulfillmentError<'tcx>> { |
